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 publicTypesAPI.- Author:
- jessewilson@google.com (Jesse Wilson)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMoreTypes.GenericArrayTypeImplstatic classMoreTypes.MemberImplWe cannot serialize the built-in Java member classes, which prevents us from using Members in our exception types.static classMoreTypes.ParameterizedTypeImplstatic classMoreTypes.WildcardTypeImplThe WildcardType interface supports multiple upper bounds and multiple lower bounds.
-
Field Summary
Fields Modifier and Type Field Description static Type[]EMPTY_TYPE_ARRAY
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Typecanonicalize(Type type)Returns a type that is functionally equal but not necessarily equal according toObject.equals().static booleanequals(Type a, Type b)Returns true ifaandbare equal.static TypegetGenericSupertype(Type type, Class<?> rawType, Class<?> toResolve)Returns the generic supertype forsupertype.static Class<?>getRawType(Type type)static inthashCode(Type type)Returns the hashCode oftype.static <T> TypeLiteral<T>makeKeySafe(TypeLiteral<T> type)Returns an equivalent type that's safe for use in a key.static StringmemberKey(Member member)static Class<? extends Member>memberType(Member member)ReturnsField.class,Method.classorConstructor.class.static TyperesolveTypeVariable(Type type, Class<?> rawType, TypeVariable unknown)static StringtoString(Member member)Formats a member as concise string, such asjava.util.ArrayList.size,java.util.ArrayList<init>()orjava.util.List.remove().static StringtoString(Type type)
-
-
-
Field Detail
-
EMPTY_TYPE_ARRAY
public static final Type[] EMPTY_TYPE_ARRAY
-
-
Method Detail
-
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- iftypecontains a type variable
-
canonicalize
public static Type canonicalize(Type type)
Returns a type that is functionally equal but not necessarily equal according toObject.equals().
-
hashCode
public static int hashCode(Type type)
Returns the hashCode oftype.
-
memberType
public static Class<? extends Member> memberType(Member member)
ReturnsField.class,Method.classorConstructor.class.
-
toString
public static String toString(Member member)
Formats a member as concise string, such asjava.util.ArrayList.size,java.util.ArrayList<init>()orjava.util.List.remove().
-
getGenericSupertype
public static Type getGenericSupertype(Type type, Class<?> rawType, Class<?> toResolve)
Returns the generic supertype forsupertype. For example, given a classIntegerSet, the result for when supertype isSet.classisSet<Integer>and the result when the supertype isCollection.classisCollection<Integer>.
-
resolveTypeVariable
public static Type resolveTypeVariable(Type type, Class<?> rawType, TypeVariable unknown)
-
-