Class MoreTypes
java.lang.Object
org.elasticsearch.common.inject.internal.MoreTypes
public class MoreTypes
extends java.lang.Object
Static methods for working with types that we aren't publishing in the
public
Types
API.-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MoreTypes.GenericArrayTypeImpl
static class
MoreTypes.MemberImpl
We cannot serialize the built-in Java member classes, which prevents us from using Members in our exception types.static class
MoreTypes.ParameterizedTypeImpl
static class
MoreTypes.WildcardTypeImpl
The WildcardType interface supports multiple upper bounds and multiple lower bounds. -
Field Summary
Fields Modifier and Type Field Description static java.lang.reflect.Type[]
EMPTY_TYPE_ARRAY
-
Method Summary
Modifier and Type Method Description static java.lang.reflect.Type
canonicalize(java.lang.reflect.Type type)
Returns a type that is functionally equal but not necessarily equal according toObject.equals()
.static boolean
equals(java.lang.reflect.Type a, java.lang.reflect.Type b)
Returns true ifa
andb
are equal.static java.lang.reflect.Type
getGenericSupertype(java.lang.reflect.Type type, java.lang.Class<?> rawType, java.lang.Class<?> toResolve)
Returns the generic supertype forsupertype
.static java.lang.Class<?>
getRawType(java.lang.reflect.Type type)
static int
hashCode(java.lang.reflect.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 java.lang.String
memberKey(java.lang.reflect.Member member)
static java.lang.Class<? extends java.lang.reflect.Member>
memberType(java.lang.reflect.Member member)
ReturnsField.class
,Method.class
orConstructor.class
.static java.lang.reflect.Type
resolveTypeVariable(java.lang.reflect.Type type, java.lang.Class<?> rawType, java.lang.reflect.TypeVariable unknown)
static java.lang.String
toString(java.lang.reflect.Member member)
Formats a member as concise string, such asjava.util.ArrayList.size
,java.util.ArrayList<init>()
orjava.util.List.remove()
.static java.lang.String
toString(java.lang.reflect.Type type)
-
Field Details
-
EMPTY_TYPE_ARRAY
public static final java.lang.reflect.Type[] EMPTY_TYPE_ARRAY
-
-
Method Details
-
makeKeySafe
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
- iftype
contains a type variable
-
canonicalize
public static java.lang.reflect.Type canonicalize(java.lang.reflect.Type type)Returns a type that is functionally equal but not necessarily equal according toObject.equals()
. -
getRawType
public static java.lang.Class<?> getRawType(java.lang.reflect.Type type) -
equals
public static boolean equals(java.lang.reflect.Type a, java.lang.reflect.Type b)Returns true ifa
andb
are equal. -
hashCode
public static int hashCode(java.lang.reflect.Type type)Returns the hashCode oftype
. -
toString
public static java.lang.String toString(java.lang.reflect.Type type) -
memberType
public static java.lang.Class<? extends java.lang.reflect.Member> memberType(java.lang.reflect.Member member)ReturnsField.class
,Method.class
orConstructor.class
. -
toString
public static java.lang.String toString(java.lang.reflect.Member member)Formats a member as concise string, such asjava.util.ArrayList.size
,java.util.ArrayList<init>()
orjava.util.List.remove()
. -
memberKey
public static java.lang.String memberKey(java.lang.reflect.Member member) -
getGenericSupertype
public static java.lang.reflect.Type getGenericSupertype(java.lang.reflect.Type type, java.lang.Class<?> rawType, java.lang.Class<?> toResolve)Returns the generic supertype forsupertype
. For example, given a classIntegerSet
, the result for when supertype isSet.class
isSet<Integer>
and the result when the supertype isCollection.class
isCollection<Integer>
. -
resolveTypeVariable
public static java.lang.reflect.Type resolveTypeVariable(java.lang.reflect.Type type, java.lang.Class<?> rawType, java.lang.reflect.TypeVariable unknown)
-