Package org.pkl.config.java
Class JavaType<T>
java.lang.Object
org.pkl.config.java.JavaType<T>
- Type Parameters:
T- the type reified by thisJavaTypeinstance
Runtime representation of a possibly parameterized Java type. Factory methods are provided to
ease construction of commonly used Java standard library types. For example, a
JavaType
for List<String> can be constructed using JavaType.listOf(String.class).
Parameterizations of other types can be constructed using the super type token idiom:
class Mapping<T> {} // some user-defined type
Config config = ...
Mapping<String> container = config.as(
// construct super type token for Mapping<String>
new JavaType<Mapping<String>>() {}
);
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <E> JavaType<E[]> Creates an array type with the given element type.static <E> JavaType<E[]> Creates an array type with the given element type.static <E> JavaType<Collection<E>> collectionOf(Class<E> elementType) Creates aCollectiontype with the given element type.static <E> JavaType<Collection<E>> collectionOf(JavaType<E> elementType) Creates aCollectiontype with the given element type.booleangetType()Returns the underlyingType.inthashCode()iterableOf(Class<E> elementType) Creates anIterabletype with the given element type.iterableOf(JavaType<E> elementType) Creates anIterabletype with the given element type.Creates aListtype with the given element type.Creates aListtype with the given element type.Creates aMaptype with the given key and value types.Creates aMaptype with the given key and value types.static <T> JavaType<T> Creates aJavaTypefor the givenClass.static <T> JavaType<T> Creates aJavaTypefor the givenType.optionalOf(Class<E> elementType) Creates anOptionaltype with the given element type.optionalOf(JavaType<E> elementType) Creates anOptionaltype with the given element type.static <F,S> JavaType <org.pkl.core.Pair<F, S>> Creates aPairtype with the given first and second element types.static <F,S> JavaType <org.pkl.core.Pair<F, S>> Creates aPairtype with the given first and second element types.Creates aSettype with the given element type.Creates aSettype with the given element type.toString()
-
Constructor Details
-
JavaType
protected JavaType()
-
-
Method Details
-
of
Creates aJavaTypefor the givenClass. -
of
Creates aJavaTypefor the givenType.Note: This method is not type safe, and should be used with care.
-
optionalOf
Creates anOptionaltype with the given element type. -
optionalOf
Creates anOptionaltype with the given element type. -
pairOf
public static <F,S> JavaType<org.pkl.core.Pair<F,S>> pairOf(Class<F> firstType, Class<S> secondType) Creates aPairtype with the given first and second element types. -
pairOf
public static <F,S> JavaType<org.pkl.core.Pair<F,S>> pairOf(JavaType<F> firstType, JavaType<S> secondType) Creates aPairtype with the given first and second element types. -
arrayOf
Creates an array type with the given element type. -
arrayOf
Creates an array type with the given element type. -
iterableOf
Creates anIterabletype with the given element type. -
iterableOf
Creates anIterabletype with the given element type. -
collectionOf
Creates aCollectiontype with the given element type. -
collectionOf
Creates aCollectiontype with the given element type. -
listOf
Creates aListtype with the given element type. -
listOf
Creates aListtype with the given element type. -
setOf
Creates aSettype with the given element type. -
setOf
Creates aSettype with the given element type. -
mapOf
Creates aMaptype with the given key and value types. -
mapOf
Creates aMaptype with the given key and value types. -
getType
Returns the underlyingType. -
equals
-
hashCode
public int hashCode() -
toString
-