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.
@ConsumerType public class TypeReference<T> extends java.lang.Object
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>>() { });
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.reflect.Type
getType()
Return the actual type of this Type Reference
-