Class MoreTypes

java.lang.Object
org.elasticsearch.common.inject.internal.MoreTypes

public class MoreTypes extends Object
Static methods for working with types that we aren't publishing in the public Types API.
  • Field Details

    • EMPTY_TYPE_ARRAY

      public static final Type[] EMPTY_TYPE_ARRAY
  • Method Details

    • makeKeySafe

      public static <T> TypeLiteral<T> makeKeySafe(TypeLiteral<T> type)
      Returns an equivalent type that's safe for use in a key. The returned type will be free of primitive types. Type literals of primitives will return the corresponding wrapper types.
      Throws:
      ConfigurationException - if type contains a type variable
    • canonicalize

      public static Type canonicalize(Type type)
      Returns a type that is functionally equal but not necessarily equal according to Object.equals().
    • getRawType

      public static Class<?> getRawType(Type type)
    • equals

      public static boolean equals(Type a, Type b)
      Returns true if a and b are equal.
    • hashCode

      public static int hashCode(Type type)
      Returns the hashCode of type.
    • toString

      public static String toString(Type type)
    • memberType

      public static Class<? extends Member> memberType(Member member)
      Returns Field.class, Method.class or Constructor.class.
    • toString

      public static String toString(Member member)
      Formats a member as concise string, such as java.util.ArrayList.size, java.util.ArrayList<init>() or java.util.List.remove().
    • memberKey

      public static String memberKey(Member member)
    • getGenericSupertype

      public static Type getGenericSupertype(Type type, Class<?> rawType, Class<?> toResolve)
      Returns the generic supertype for supertype. For example, given a class IntegerSet, the result for when supertype is Set.class is Set<Integer> and the result when the supertype is Collection.class is Collection<Integer>.
    • resolveTypeVariable

      public static Type resolveTypeVariable(Type type, Class<?> rawType, TypeVariable unknown)