Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 1796a29ed997e9661433b83ae796b7cb7772bded (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/*******************************************************************************
 * Copyright (c) 2005, 2008 BEA Systems, Inc.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *    tyeung@bea.com - initial API and implementation
 *******************************************************************************/
package org.eclipse.jdt.apt.tests.annotations.readannotation;


public class CodeExample {

	public static final String PACKAGE_QUESTION = "question";

	public static final String ANNOTATION_TEST_CLASS = "AnnotationTest";
	public static final String ANNOTATION_TEST_CODE =
			"package question;\n" +
	        "\n" +
	        "@Deprecated\n" +
	        "@RTVisibleAnno(anno=@SimpleAnnotation(\"test\"), clazzes={})\n" +
	        "@RTInvisibleAnno(\"question\")\n" +
	        "public interface AnnotationTest{\n" +
	        "\n" +
	        "    @RTVisibleAnno(name = \"Foundation\",\n" +
	        "                   boolValue   = false, \n"  +
	        "                   byteValue   = 0x10,  \n"  +
	        "                   charValue   = 'c', \n"    +
	        "                   doubleValue = 99.0, \n"   +
	        "                   floatValue  = (float)9.0, \n"    +
	        "                   intValue    = 999, \n"    +
	        "                   longValue = 3333,  \n"    +
	        "                   shortValue = 3,    \n"    +
	        "                   colors ={ Color.RED, Color.BLUE }, \n"    +
	        "                   anno = @SimpleAnnotation(\"core\"),\n"    +
	        "                   simpleAnnos = {@SimpleAnnotation(\"org\"),    \n" +
			"              	                   @SimpleAnnotation(\"eclipse\"),\n" +
			"        		                   @SimpleAnnotation(\"jdt\") },  \n" +
			"                   clazzes = {Object.class, String.class},\n " +
			"		            clazz = Object.class)\n " +
	        "    @RTInvisibleAnno(\"org.eclipse.jdt.core\")\n " +
		    "    @Deprecated \n " +
		    "    public int field0 = 0; \n" +
	        "\n" +
	        "    @Deprecated \n" +
	    	"    public int field1 = 1; \n" +
	    	"\n" +
	    	"    @RTVisibleAnno(anno=@SimpleAnnotation(\"field\"), clazzes={})\n " +
	    	"    @RTInvisibleAnno(\"2\") \n " +
	    	"    public int field2 = 2; \n" +
	    	"\n" +
	    	"    @RTInvisibleAnno(\"3\") \n" +
	    	"    public int field3 = 3; \n"  +
	    	"\n" +
	    	"    @SimpleAnnotation(\"4\") \n" +
	    	"    public int field4 = 4; \n" +
	    	"\n" +
	    	"    @RTVisibleAnno(anno=@SimpleAnnotation(\"method0\"), clazzes={}) \n" +
	    	"    @RTInvisibleAnno(\"0\") \n" +
	    	"    @Deprecated \n " +
	    	"    public int method0();  \n " +
	    	"\n" +
	    	"    @Deprecated \n " +
	    	"    public int method1(); \n " +
	    	"\n" +
	    	"    @RTVisibleAnno(anno=@SimpleAnnotation(\"method2\"), clazzes={}) \n " +
	    	"    @RTInvisibleAnno(\"2\") \n" +
	    	"    public int method2(); \n" +
	    	"\n" +
	    	"   @RTInvisibleAnno(\"3\") \n" +
	    	"   public int method3(); \n" +
	    	"\n" +
	    	"   @SimpleAnnotation(\"method4\") \n" +
	    	"   public int method4(); \n" +
	    	"\n" +
	    	"   public int method5(int p0, \n" +
	    	"   				   @Deprecated  \n" +
	    	"   				   int p1, \n" +
	    	"   				   @RTVisibleAnno(anno=@SimpleAnnotation(\"param2\"), clazzes={}) \n" +
	    	"   				   @RTInvisibleAnno(\"2\") \n" +
	    	"   				   int p2); \n" +
	    	"\n" +
	    	"   public int method6(int p0, int p1, int p2); \n" +
	    	"\n" +
	    	"   @RTVisibleAnno(name = \"I'm \\\"special\\\": \\t\\\\\\n\",\n" +
	    	"		          charValue = '\\'',\n" +
	    	"		          clazzes = {},\n" +
	    	"		          anno = @SimpleAnnotation(\"\"))\n" +
	    	"   public int method7();" +
	    	"\n }";

	public static final String COLOR_CLASS = "Color";
	public static final String COLOR_CODE =
		"package question;\n" +
		"\n" +
		"public enum Color { RED, WHITE, BLUE; } ";

	public static final String PACKAGE_INFO_CLASS = "package-info";
	public static final String PACKAGE_INFO_CODE =
		"@Deprecated package question; ";

	public static final String RTINVISIBLE_CLASS = "RTInvisibleAnno";
	public static final String RTINVISIBLE_ANNOTATION_CODE =
		"package question;  \n" +
		"\n" +
		"   public @interface RTInvisibleAnno{  \n" +
		"   	String value(); \n" +
		"   }";

	public static final String RTVISIBLE_CLASS = "RTVisibleAnno";
	public static final String RTVISIBLE_ANNOTATION_CODE =
		"package question; \n" +
		"\n" +
		"import java.lang.annotation.*; \n" +
		"\n" +
		"@Retention(value=RetentionPolicy.RUNTIME) \n" +
		"public @interface RTVisibleAnno  \n" +
		"{	\n" +
		"	String name() default \"eclipse\"; \n" +
		"	boolean boolValue() default true; \n" +
		"	byte byteValue() default 0x0001; \n" +
		"	char charValue() default 'e'; \n" +
		"	double doubleValue() default 0.0; \n" +
		"	float floatValue()  default 0; \n" +
		"	int intValue() default 17; \n" +
		"	long longValue() default 43; \n" +
		"	short shortValue() default 1; \n" +
		"	Color[] colors() default {Color.RED, Color.WHITE, Color.BLUE}; \n" +
		"	SimpleAnnotation anno(); \n" +
		"	SimpleAnnotation[] simpleAnnos() default { @SimpleAnnotation(\"org.eclipse.org\") }; \n" +
		"	Class<?>[] clazzes(); \n" +
		"	Class<?> clazz() default java.lang.String.class; \n" +
		"\n }";

	public static final String SIMPLE_ANNOTATION_CLASS = "SimpleAnnotation";
	public static final String SIMPLE_ANNOTATION_CODE =
		"package question; \n" +
		"\n" +
		"import java.lang.annotation.Retention; \n" +
		"import java.lang.annotation.RetentionPolicy; \n" +
		"\n" +
		"@Retention(value=RetentionPolicy.RUNTIME) \n" +
		"public @interface SimpleAnnotation { \n" +
		"\n" +
		"	String value(); \n" +
		"}";

	public static final String PACKAGE_TRIGGER = "trigger";
	public static final String TRIGGER_CLASS = "Trigger";
	public static final String TRIGGER_CODE =
		"package trigger; \n" +
		"\n" +
		"@MyMarkerAnnotation \n" +
		"public class Trigger {}";

	public static final String MYMARKERANNOTATION_CLASS = "MyMarkerAnnotation";
	public static final String MYMARKERANNOTATION_CODE =
		"package trigger; \n" +
		"\n" +
		"public @interface MyMarkerAnnotation {}";

	public static final String PACKAGE_NOTYPES = "notypes";
	public static final String PACKAGE_INFO_NOTYPES_CLASS = "package-info";
	public static final String PACKAGE_INFO_NOTYPES_CODE =
		"@question.SimpleAnnotation(\"foo\") package notypes;\n";

}

Back to the top