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
223 C asDecl(Class c);
224
225 /**
226 * Checks if the type is an array type.
227 */
228 boolean isArray(T t);
229
230 /**
231 * Checks if the type is an array type but not byte[].
232 */
233 boolean isArrayButNotByteArray(T t);
234
235 /**
236 * Gets the component type of the array.
237 *
238 * @param t
239 * must be an array.
240 */
241 T getComponentType(T t);
242
243
244 /** The singleton instance. */
245 public static final ReflectionNavigator REFLECTION = new ReflectionNavigator();
246
247 /**
248 * Gets the i-th type argument from a parameterized type.
249 *
250 * For example, {@code getTypeArgument([Map<Integer,String>],0)=Integer}
251 *
252 * @throws IllegalArgumentException
253 * If t is not a parameterized type
254 * @throws IndexOutOfBoundsException
255 * If i is out of range.
256 *
257 * @see #isParameterizedType(Object)
258 */
259 T getTypeArgument(T t, int i);
260
261 /**
262 * Returns true if t is a parameterized type.
263 */
264 boolean isParameterizedType(T t);
265
266 /**
340 *
341 * @return
342 * can be empty but never null.
343 */
344 F[] getEnumConstants(C clazz);
345
346 /**
347 * Gets the representation of the primitive "void" type.
348 */
349 T getVoidType();
350
351 /**
352 * Gets the package name of the given class.
353 *
354 * @return
355 * i.e. "", "java.lang" but not null.
356 */
357 String getPackageName(C clazz);
358
359 /**
360 * Finds the class/interface/enum/annotation of the given name.
361 *
362 * @param referencePoint
363 * The class that refers to the specified class.
364 * @return
365 * null if not found.
366 */
367 C findClass(String className, C referencePoint);
368
369 /**
370 * Returns true if this method is a bridge method as defined in JLS.
371 */
372 boolean isBridgeMethod(M method);
373
374 /**
375 * Returns true if the given method is overriding another one
376 * defined in the base class 'base' or its ancestors.
377 */
378 boolean isOverriding(M method, C base);
379
380 /**
381 * Returns true if 'clazz' is an interface.
382 */
383 boolean isInterface(C clazz);
384
385 /**
386 * Returns true if the field is transient.
387 */
|
1 /*
2 * Copyright (c) 1997, 2014, 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
223 C asDecl(Class c);
224
225 /**
226 * Checks if the type is an array type.
227 */
228 boolean isArray(T t);
229
230 /**
231 * Checks if the type is an array type but not byte[].
232 */
233 boolean isArrayButNotByteArray(T t);
234
235 /**
236 * Gets the component type of the array.
237 *
238 * @param t
239 * must be an array.
240 */
241 T getComponentType(T t);
242
243 /**
244 * Gets the i-th type argument from a parameterized type.
245 *
246 * For example, {@code getTypeArgument([Map<Integer,String>],0)=Integer}
247 *
248 * @throws IllegalArgumentException
249 * If t is not a parameterized type
250 * @throws IndexOutOfBoundsException
251 * If i is out of range.
252 *
253 * @see #isParameterizedType(Object)
254 */
255 T getTypeArgument(T t, int i);
256
257 /**
258 * Returns true if t is a parameterized type.
259 */
260 boolean isParameterizedType(T t);
261
262 /**
336 *
337 * @return
338 * can be empty but never null.
339 */
340 F[] getEnumConstants(C clazz);
341
342 /**
343 * Gets the representation of the primitive "void" type.
344 */
345 T getVoidType();
346
347 /**
348 * Gets the package name of the given class.
349 *
350 * @return
351 * i.e. "", "java.lang" but not null.
352 */
353 String getPackageName(C clazz);
354
355 /**
356 * Finds ObjectFactory for the given referencePoint.
357 *
358 * @param referencePoint
359 * The class that refers to the specified class.
360 * @return
361 * null if not found.
362 */
363 C loadObjectFactory(C referencePoint, String packageName);
364
365 /**
366 * Returns true if this method is a bridge method as defined in JLS.
367 */
368 boolean isBridgeMethod(M method);
369
370 /**
371 * Returns true if the given method is overriding another one
372 * defined in the base class 'base' or its ancestors.
373 */
374 boolean isOverriding(M method, C base);
375
376 /**
377 * Returns true if 'clazz' is an interface.
378 */
379 boolean isInterface(C clazz);
380
381 /**
382 * Returns true if the field is transient.
383 */
|