001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.harmony.lang.annotation;
018:
019: import java.lang.annotation.Annotation;
020: import java.lang.annotation.Retention;
021: import java.lang.annotation.RetentionPolicy;
022:
023: /**
024: * The annotation containing all possible types of elements with default values.
025: *
026: * @author Alexey V. Varlamov
027: * @version $Revision$
028: */
029: @Retention(RetentionPolicy.RUNTIME)
030: @AllTypesAntn
031: @SuppressWarnings(value={"all"})
032: public @interface AllTypesAntn {
033: public enum TheEnum {
034: A, B, C,
035: }
036:
037: public @interface TheAntn {
038: }
039:
040: int intValue() default 345;
041:
042: byte byteValue() default (byte) 28;
043:
044: short shortValue() default (short) 3247;
045:
046: long longValue() default 234956955L;
047:
048: char charValue() default 'q';
049:
050: float floatValue() default 213235.34546546f;
051:
052: double doubleValue() default 7E-34;
053:
054: boolean booleanValue() default true;
055:
056: Class classValue() default AllTypesAntn.class;
057:
058: TheEnum enumValue() default TheEnum.A;
059:
060: TheAntn antnValue() default @TheAntn;
061:
062: int[] intArrayValue() default 345;
063:
064: byte[] byteArrayValue() default (byte) 28;
065:
066: short[] shortArrayValue() default (short) 3247;
067:
068: long[] longArrayValue() default 234956955L;
069:
070: char[] charArrayValue() default 'q';
071:
072: float[] floatArrayValue() default 213235.34546546f;
073:
074: double[] doubleArrayValue() default 7E-34;
075:
076: boolean[] booleanArrayValue() default true;
077:
078: Class[] classArrayValue() default AllTypesAntn.class;
079:
080: TheEnum[] enumArrayValue() default TheEnum.A;
081:
082: TheAntn[] antnArrayValue() default @TheAntn;
083:
084: /**
085: * Elementary implementation of the enclosing interface.
086: */
087: public static class MockedImpl implements AllTypesAntn {
088: public static class TheAntnImpl implements TheAntn {
089: public Class<? extends Annotation> annotationType() {
090: return TheAntn.class;
091: }
092: }
093:
094: public Class<? extends Annotation> annotationType() {
095: return AllTypesAntn.class;
096: }
097:
098: public int intValue() {
099: return 345;
100: }
101:
102: public byte byteValue() {
103: return (byte) 28;
104: }
105:
106: public short shortValue() {
107: return (short) 3247;
108: }
109:
110: public long longValue() {
111: return 234956955L;
112: }
113:
114: public char charValue() {
115: return 'q';
116: }
117:
118: public float floatValue() {
119: return 213235.34546546f;
120: }
121:
122: public double doubleValue() {
123: return 7E-34;
124: }
125:
126: public boolean booleanValue() {
127: return true;
128: }
129:
130: public Class classValue() {
131: return AllTypesAntn.class;
132: }
133:
134: public TheEnum enumValue() {
135: return TheEnum.A;
136: }
137:
138: public TheAntn antnValue() {
139: return new TheAntnImpl();
140: }
141:
142: public int[] intArrayValue() {
143: return new int[] { 345 };
144: }
145:
146: public byte[] byteArrayValue() {
147: return new byte[] { (byte) 28 };
148: }
149:
150: public short[] shortArrayValue() {
151: return new short[] { (short) 3247 };
152: }
153:
154: public long[] longArrayValue() {
155: return new long[] { 234956955L };
156: }
157:
158: public char[] charArrayValue() {
159: return new char[] { 'q' };
160: }
161:
162: public float[] floatArrayValue() {
163: return new float[] { 213235.34546546f };
164: }
165:
166: public double[] doubleArrayValue() {
167: return new double[] { 7E-34 };
168: }
169:
170: public boolean[] booleanArrayValue() {
171: return new boolean[] { true };
172: }
173:
174: public Class[] classArrayValue() {
175: return new Class[] { AllTypesAntn.class };
176: }
177:
178: public TheEnum[] enumArrayValue() {
179: return new TheEnum[] { TheEnum.A };
180: }
181:
182: public TheAntn[] antnArrayValue() {
183: return new TheAntn[] { new TheAntnImpl() };
184: }
185: }
186: }
|