OSDN Git Service

08cd10eae4f6bd34e720017a9d1ede4d348746a2
[bm-asn1/bm-asn1.git] / jp / bitmeister / asn1 / annotation / ASN1Enumeration.java
1 /*
2  * Copyright 2011-2012 BitMeister Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package jp.bitmeister.asn1.annotation;
17
18 import java.lang.annotation.ElementType;
19 import java.lang.annotation.Retention;
20 import java.lang.annotation.RetentionPolicy;
21 import java.lang.annotation.Target;
22
23 import jp.bitmeister.asn1.type.builtin.ENUMERATED;
24 import jp.bitmeister.asn1.type.builtin.INTEGER;
25
26 /**
27  * Indicates that a field is an element of enumerations.
28  * 
29  * <p>
30  * If a field annotated as {@code @ASN1Enumeration} is present in a definition
31  * of a sub-class of {@code INTEGER} or {@code ENUMERATED}, value that can be
32  * contained in the type is limited to values of {@code @ASN1Enumeration}
33  * fields. An {@code @ASN1Enumeration} field must be a {@code public}
34  * {@code static} {@code final} field and the type shall be {@code int},
35  * {@code long} or {@code BigInteger}. Each value of {@code @ASN1Enumeration}
36  * fields appearing in definition of a type must be distinct from the others. A
37  * sub-class of {@code ENUMERATED} must have at least one
38  * {@code @ASN1Enumeration} field.
39  * </p>
40  * <p>
41  * For example, following ASN.1 definition :
42  * 
43  * <pre>
44  * Sample ::= ENUMERATED {
45  *      zero(0),
46  *      one(1) }
47  * </pre>
48  * 
49  * can be translated as :
50  * 
51  * <code><pre>
52  * public class Sample extends ENUMERATED {
53  * 
54  *      &#064;ASN1Enumeration
55  *      public static final int zero = 0;
56  * 
57  *      &#064;ASN1Enumeration
58  *      public static final int one = 1;
59  * 
60  * }
61  * </pre></code>
62  * 
63  * </p>
64  * 
65  * @author WATANABE, Jun. <jwat at bitmeister.jp>
66  * 
67  * @see INTEGER
68  * @see ENUMERATED
69  */
70 @Target(ElementType.FIELD)
71 @Retention(RetentionPolicy.RUNTIME)
72 public @interface ASN1Enumeration {
73 }