| 1 |
|
| 2 |
/* |
| 3 |
* |
| 4 |
* Licensed to the Apache Software Foundation (ASF) under one |
| 5 |
* or more contributor license agreements. See the NOTICE file |
| 6 |
* distributed with this work for additional information |
| 7 |
* regarding copyright ownership. The ASF licenses this file |
| 8 |
* to you under the Apache License, Version 2.0 (the |
| 9 |
* "License"); you may not use this file except in compliance |
| 10 |
* with the License. You may obtain a copy of the License at |
| 11 |
* |
| 12 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 13 |
* |
| 14 |
* Unless required by applicable law or agreed to in writing, |
| 15 |
* software distributed under the License is distributed on an |
| 16 |
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 17 |
* KIND, either express or implied. See the License for the |
| 18 |
* specific language governing permissions and limitations |
| 19 |
* under the License. |
| 20 |
* |
| 21 |
*/ |
| 22 |
|
| 23 |
|
| 24 |
package org.apache.qpid.proton.amqp.messaging; |
| 25 |
|
| 26 |
import java.util.HashMap; |
| 27 |
import java.util.Map; |
| 28 |
import org.apache.qpid.proton.amqp.Symbol; |
| 29 |
|
| 30 |
public enum TerminusExpiryPolicy |
| 31 |
{ |
| 32 |
LINK_DETACH("link-detach"), |
| 33 |
SESSION_END("session-end"), |
| 34 |
CONNECTION_CLOSE("connection-close"), |
| 35 |
NEVER("never"); |
| 36 |
|
| 37 |
private Symbol _policy; |
| 38 |
private static final Map<Symbol, TerminusExpiryPolicy> _map = new HashMap<Symbol, TerminusExpiryPolicy>(); |
| 39 |
|
| 40 |
TerminusExpiryPolicy(String policy) |
| 41 |
{ |
| 42 |
_policy = Symbol.valueOf(policy); |
| 43 |
} |
| 44 |
|
| 45 |
public Symbol getPolicy() |
| 46 |
{ |
| 47 |
return _policy; |
| 48 |
} |
| 49 |
|
| 50 |
static |
| 51 |
{ |
| 52 |
_map.put(LINK_DETACH.getPolicy(), LINK_DETACH); |
| 53 |
_map.put(SESSION_END.getPolicy(), SESSION_END); |
| 54 |
_map.put(CONNECTION_CLOSE.getPolicy(), CONNECTION_CLOSE); |
| 55 |
_map.put(NEVER.getPolicy(), NEVER); |
| 56 |
} |
| 57 |
|
| 58 |
public static TerminusExpiryPolicy valueOf(Symbol policy) |
| 59 |
{ |
| 60 |
TerminusExpiryPolicy expiryPolicy = _map.get(policy); |
| 61 |
if(expiryPolicy == null) |
| 62 |
{ |
| 63 |
throw new IllegalArgumentException("Unknown TerminusExpiryPolicy: " + policy); |
| 64 |
} |
| 65 |
return expiryPolicy; |
| 66 |
} |
| 67 |
} |