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.boolean
Extracts the raw type from the generic type.getType()
int
hashCode()
boolean
isInstance
(Object obj) Checks if the given object is an instance of the type represented by this ValueType.boolean
isSubtypeOf
(ValueType<?> target) Checks if this ValueType is a subtype of the given ValueType.boolean
isSubtypeOf
(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
-
Constructor Details
-
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()
-