2 * Copyright 2011-2012 BitMeister Inc.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package jp.bitmeister.asn1.annotation;
18 import java.lang.annotation.ElementType;
19 import java.lang.annotation.Retention;
20 import java.lang.annotation.RetentionPolicy;
21 import java.lang.annotation.Target;
23 import jp.bitmeister.asn1.type.SelectiveType;
24 import jp.bitmeister.asn1.type.builtin.CHOICE;
27 * Indicates that a field is a 'CHOICE' alternative.
30 * If an {@code @ASN1Alternative} annotation is present on a field, the field is
31 * treated as an alternative of a sub-class of {@code SelectiveType}. A field
32 * annotated as {@code @ASN1Alternative} must be declared as {@code public}
33 * non-{@code final} non-{@code static}, and the type shall be a sub-class of
34 * {@code ASN1Type}. The {@code value} parameter represents an order of
35 * appearance of a field in an ASN.1 type definition and is used for automatic
39 * For example, following ASN.1 definition :
47 * can be translated as :
50 * public class Sample extends CHOICE {
52 * @ASN1Alternative(0)
53 * public INTEGER number;
55 * @ASN1Alternative(1)
56 * public BOOLEAN bool;
61 * @author WATANABE, Jun. <jwat at bitmeister.jp>
66 @Target(ElementType.FIELD)
67 @Retention(RetentionPolicy.RUNTIME)
68 public @interface ASN1Alternative {
71 * Indicates defined order of this element.
73 * @return Order of this element.
75 public int value() default 0;