Package org.osgi.util.converter
Class TypeReference<T>
java.lang.Object
org.osgi.util.converter.TypeReference<T>
- Type Parameters:
T
- The target type for the conversion.
An object does not carry any runtime information about its generic type.
However sometimes it is necessary to specify a generic type, that is the
purpose of this class. It allows you to specify an generic type by defining a
type T, then subclassing it. The subclass will have a reference to the super
class that contains this generic information. Through reflection, we pick
this reference up and return it with the getType() call.
List<String> result = converter.convert(Arrays.asList(1, 2, 3)) .to(new TypeReference<List<String>>() { });
- "Immutable"
-
Constructor Summary
-
Method Summary
-
Constructor Details
-
TypeReference
protected TypeReference()ATypeReference
cannot be directly instantiated. To use it, it has to be extended, typically as an anonymous inner class.
-
-
Method Details
-
getType
Return the actual type of this Type Reference- Returns:
- the type of this reference.
-