Class ValueType<T>
java.lang.Object
cc.carm.lib.configuration.adapter.ValueType<T>
ValueType used to get the generic type of the value,
It can be used to check if an object is an instance of a specific type,
and to cast objects to the correct type.
Java's type system is not capable of retaining generic type information at runtime. This class is used to represent a type with its generic parameters.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCasts the object to the type represented by this ValueType.booleanExtracts the raw type from the generic type.getType()inthashCode()booleanisInstance(Object obj) Checks if the given object is an instance of the type represented by this ValueType.booleanisSubtypeOf(ValueType<?> target) Checks if this ValueType is a subtype of the given ValueType.booleanisSubtypeOf(Class<?> target) Checks if this ValueType is a subtype of the given Class.static <T> ValueType<T> static <T> ValueType<T> Get the generic type of the complex type.static <T> ValueType<T> static <T> ValueType<T> of(T value) toString()Returns a string representation of the type.
-
Field Details
-
OBJECT
-
STRING
-
INTEGER
-
INTEGER_TYPE
-
LONG
-
LONG_TYPE
-
DOUBLE
-
DOUBLE_TYPE
-
FLOAT
-
FLOAT_TYPE
-
BOOLEAN
-
BOOLEAN_TYPE
-
BYTE
-
BYTE_TYPE
-
SHORT
-
SHORT_TYPE
-
CHAR
-
CHAR_TYPE
-
PRIMITIVE_TYPES
-
-
Constructor Details
-
ValueType
protected ValueType()
-
-
Method Details
-
of
-
of
-
of
-
ofList
-
ofList
-
ofMap
-
ofMap
-
of
Get the generic type of the complex type.- Type Parameters:
T- The type- Parameters:
rawType- The raw typetypes- The type arguments- Returns:
- The
ValueType
-
getType
-
isSubtypeOf
Checks if this ValueType is a subtype of the given Class.- Parameters:
target- The target Class to check against- Returns:
- true if this ValueType is a subtype of the target Class, false otherwise
-
isSubtypeOf
Checks if this ValueType is a subtype of the given ValueType.- Parameters:
target- The target ValueType to check against- Returns:
- true if this ValueType is a subtype of the target, false otherwise
-
isInstance
Checks if the given object is an instance of the type represented by this ValueType.- Parameters:
obj- The object to check- Returns:
- true if the object is an instance of the type, false otherwise
-
getRawType
Extracts the raw type from the generic type.- Returns:
- The raw type of the generic type
- Throws:
IllegalStateException- if the type is not a Class or ParameterizedType
-
cast
Casts the object to the type represented by this ValueType.- Parameters:
obj- The object to cast- Returns:
- The object cast to the type represented by this ValueType
-
toString
Returns a string representation of the type. Like "java.util.List<java.lang.String>" or "java.lang.Integer". -
equals
-
hashCode
public int hashCode()
-