Class TypeUtils

java.lang.Object
com.googlecode.objectify.impl.TypeUtils

public class TypeUtils
extends Object
  • Method Details

    • 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.
    • field_get

      public static Object field_get(Field field, Object obj)
      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