Package com.googlecode.objectify.impl
Class TypeUtils
- java.lang.Object
-
- com.googlecode.objectify.impl.TypeUtils
-
public class TypeUtils extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Object
field_get(Field field, Object obj)
Checked exceptions are LAME.static <A extends Annotation>
AgetAnnotation(Annotation[] annotations, Class<A> annotationType)
Gets the annotation that has the specified type, or null if there isn't onestatic MethodHandle
getConstructor(Class<?> clazz, Class<?>... args)
Gets a constructor that has the specified types of arguments.static <A extends Annotation>
AgetDeclaredAnnotation(Class<?> onClass, Class<A> annotationType)
Get the declared annotation, ignoring any inherited annotationsstatic <T> Constructor<T>
getNoArgConstructor(Class<T> clazz)
Throw an IllegalStateException if the class does not have a no-arg constructor.static <T> T
invoke(MethodHandle methodHandle, Object... params)
Wraps any non-runtime exceptions with a runtime exceptionstatic boolean
isAssignableFrom(Class<?> to, Class<?> from)
Just like Class.isAssignableFrom(), but does the right thing when considering autoboxing.static <A extends Annotation>
booleanisDeclaredAnnotationPresent(Class<?> onClass, Class<A> annotationType)
Is the declared annotation present, ignoring any inherited annotationsstatic <T> T
newInstance(Constructor<T> ctor, Object... params)
Checked exceptions are LAME.
-
-
-
Method Detail
-
getNoArgConstructor
public static <T> Constructor<T> getNoArgConstructor(Class<T> clazz)
Throw an IllegalStateException if the class does not have a no-arg constructor.
-
getConstructor
public static MethodHandle getConstructor(Class<?> clazz, Class<?>... args)
Gets a constructor that has the specified types of arguments. Throw an IllegalStateException if the class does not have such a constructor.
-
invoke
public static <T> T invoke(MethodHandle methodHandle, Object... params)
Wraps any non-runtime exceptions with a runtime exception
-
newInstance
public static <T> T newInstance(Constructor<T> ctor, Object... params)
Checked exceptions are LAME.
-
isAssignableFrom
public static boolean isAssignableFrom(Class<?> to, Class<?> from)
Just like Class.isAssignableFrom(), but does the right thing when considering autoboxing.
-
getAnnotation
public static <A extends Annotation> A getAnnotation(Annotation[] annotations, Class<A> annotationType)
Gets the annotation that has the specified type, or null if there isn't one
-
getDeclaredAnnotation
public static <A extends Annotation> A getDeclaredAnnotation(Class<?> onClass, Class<A> annotationType)
Get the declared annotation, ignoring any inherited annotations
-
isDeclaredAnnotationPresent
public static <A extends Annotation> boolean isDeclaredAnnotationPresent(Class<?> onClass, Class<A> annotationType)
Is the declared annotation present, ignoring any inherited annotations
-
-