1 /*
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
206 public NType getPrimitive(Class primitiveType) {
207 return create(primitiveType);
208 }
209
210 @SuppressWarnings("FinalStaticMethod")
211 public static final NType create(Type t) {
212 if(t==null) return null;
213 if(t instanceof Class)
214 return create((Class)t);
215
216 return new EagerNType(t);
217 }
218
219 public static NClass create( Class c ) {
220 if(c==null) return null;
221 return new EagerNClass(c);
222 }
223
224 /**
225 * Creates a {@link NType} representation for a parameterized type
226 * {@code RawType<ParamType1,ParamType2,...> }.
227 */
228 public static NType createParameterizedType( NClass rawType, NType... args ) {
229 return new NParameterizedType(rawType,args);
230 }
231
232 public static NType createParameterizedType( Class rawType, NType... args ) {
233 return new NParameterizedType(create(rawType),args);
234 }
235
236 public Location getClassLocation(final NClass c) {
237 // not really needed for XJC but doesn't hurt to have one
238 return new Location() {
239 @Override
240 public String toString() {
241 return c.fullName();
242 }
243 };
244 }
245
246 public Location getFieldLocation(Void v) {
|
1 /*
2 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
206 public NType getPrimitive(Class primitiveType) {
207 return create(primitiveType);
208 }
209
210 @SuppressWarnings("FinalStaticMethod")
211 public static final NType create(Type t) {
212 if(t==null) return null;
213 if(t instanceof Class)
214 return create((Class)t);
215
216 return new EagerNType(t);
217 }
218
219 public static NClass create( Class c ) {
220 if(c==null) return null;
221 return new EagerNClass(c);
222 }
223
224 /**
225 * Creates a {@link NType} representation for a parameterized type
226 * {@code RawType<ParamType1,ParamType2,...> }.
227 */
228 public static NType createParameterizedType( NClass rawType, NType... args ) {
229 return new NParameterizedType(rawType,args);
230 }
231
232 public static NType createParameterizedType( Class rawType, NType... args ) {
233 return new NParameterizedType(create(rawType),args);
234 }
235
236 public Location getClassLocation(final NClass c) {
237 // not really needed for XJC but doesn't hurt to have one
238 return new Location() {
239 @Override
240 public String toString() {
241 return c.fullName();
242 }
243 };
244 }
245
246 public Location getFieldLocation(Void v) {
|