|
31 | 31 |
|
32 | 32 | package org.scijava.util; |
33 | 33 |
|
34 | | -import com.googlecode.gentyref.GenericTypeReflector; |
35 | | - |
36 | 34 | import java.io.File; |
37 | 35 | import java.lang.annotation.Annotation; |
38 | 36 | import java.lang.reflect.Array; |
@@ -341,96 +339,6 @@ public static Field getField(final Class<?> c, final String fieldName) { |
341 | 339 | } |
342 | 340 | } |
343 | 341 |
|
344 | | - /** |
345 | | - * Returns the "safe" type(s) of the given field, as viewed from the specified |
346 | | - * type. This may be narrower than what {@link Field#getType()} returns, if |
347 | | - * the field is declared in a superclass, or {@code type} has a type parameter |
348 | | - * that is used in the type of the field. |
349 | | - * <p> |
350 | | - * For example, suppose we have the following three classes: |
351 | | - * </p> |
352 | | - * |
353 | | - * <pre> |
354 | | - * public class Thing<T> { |
355 | | - * public T thing; |
356 | | - * } |
357 | | - * |
358 | | - * public class NumberThing<N extends Number> extends Thing<N> { } |
359 | | - * |
360 | | - * public class IntegerThing extends NumberThing<Integer> { } |
361 | | - * </pre> |
362 | | - * |
363 | | - * Then this method operates as follows: |
364 | | - * |
365 | | - * <pre> |
366 | | - * field = ClassUtils.getField(Thing.class, "thing"); |
367 | | - * |
368 | | - * field.getType(); // Object |
369 | | - * |
370 | | - * ClassUtils.getTypes(field, Thing.class).get(0); // Object |
371 | | - * ClassUtils.getTypes(field, NumberThing.class).get(0); // Number |
372 | | - * ClassUtils.getTypes(field, IntegerThing.class).get(0); // Integer |
373 | | - * </pre> |
374 | | - * |
375 | | - * <p> |
376 | | - * In cases of complex generics which take the intersection of |
377 | | - * multiple types using the {@code &} operator, there may be multiple types |
378 | | - * returned by this method. For example: |
379 | | - * </p> |
380 | | - * |
381 | | - * <pre> |
382 | | - * public class ComplexThing<T extends Serializable & Cloneable> extends Thing<T> { } |
383 | | - * |
384 | | - * ClassUtils.getTypes(field, ComplexThing.class); // Serializable, Cloneable |
385 | | - * </pre> |
386 | | - * |
387 | | - * @see #getGenericType(Field, Class) |
388 | | - */ |
389 | | - public static List<Class<?>> getTypes(final Field field, final Class<?> type) |
390 | | - { |
391 | | - final Type genericType = getGenericType(field, type); |
392 | | - return GenericTypeReflector.getUpperBoundClassAndInterfaces(genericType); |
393 | | - } |
394 | | - |
395 | | - /** |
396 | | - * Returns the "safe" generic type of the given field, as viewed from the |
397 | | - * given type. This may be narrower than what {@link Field#getGenericType()} |
398 | | - * returns, if the field is declared in a superclass, or {@code type} has a |
399 | | - * type parameter that is used in the type of the field. |
400 | | - * <p> |
401 | | - * For example, suppose we have the following three classes: |
402 | | - * </p> |
403 | | - * |
404 | | - * <pre> |
405 | | - * public class Thing<T> { |
406 | | - * public T thing; |
407 | | - * } |
408 | | - * |
409 | | - * public class NumberThing<N extends Number> extends Thing<N> { } |
410 | | - * |
411 | | - * public class IntegerThing extends NumberThing<Integer> { } |
412 | | - * </pre> |
413 | | - * |
414 | | - * Then this method operates as follows: |
415 | | - * |
416 | | - * <pre> |
417 | | - * field = ClassUtils.getField(Thing.class, "thing"); |
418 | | - * |
419 | | - * field.getType(); // Object |
420 | | - * field.getGenericType(); // T |
421 | | - * |
422 | | - * ClassUtils.getGenericType(field, Thing.class); // T |
423 | | - * ClassUtils.getGenericType(field, NumberThing.class); // N extends Number |
424 | | - * ClassUtils.getGenericType(field, IntegerThing.class); // Integer |
425 | | - * </pre> |
426 | | - * |
427 | | - * @see #getTypes(Field, Class) |
428 | | - */ |
429 | | - public static Type getGenericType(final Field field, final Class<?> type) { |
430 | | - final Type wildType = GenericTypeReflector.addWildcardParameters(type); |
431 | | - return GenericTypeReflector.getExactFieldType(field, wildType); |
432 | | - } |
433 | | - |
434 | 342 | /** |
435 | 343 | * Gets the given field's value of the specified object instance, or null if |
436 | 344 | * the value cannot be obtained. |
@@ -599,4 +507,17 @@ public static <T> T getNullValue(final Class<T> type) { |
599 | 507 | return ConversionUtils.getNullValue(type); |
600 | 508 | } |
601 | 509 |
|
| 510 | + /** @deprecated use {@link GenericUtils#getFieldClasses(Field, Class)} */ |
| 511 | + @Deprecated |
| 512 | + public static List<Class<?>> getTypes(final Field field, final Class<?> type) |
| 513 | + { |
| 514 | + return GenericUtils.getFieldClasses(field, type); |
| 515 | + } |
| 516 | + |
| 517 | + /** @deprecated use {@link GenericUtils#getFieldType(Field, Class)} */ |
| 518 | + @Deprecated |
| 519 | + public static Type getGenericType(final Field field, final Class<?> type) { |
| 520 | + return GenericUtils.getFieldType(field, type); |
| 521 | + } |
| 522 | + |
602 | 523 | } |
0 commit comments