osglworks / java-tool

Some simple common Java utilities
Apache License 2.0
52 stars 18 forks source link

TypeReference - provide helper method to generate type for container and map #212

Closed greenlaw110 closed 4 years ago

greenlaw110 commented 5 years ago

So once we have the class of element or key, value, we can create generic type for containers (List, Set, Collection, Iterable) and Map.

Proposed factory method:

public static Type listOf(Class<?> elementType);
public static Type setOf(Class<?> elementType);
public static Type collectionOf(Class<?> elementType);
public static Type IterableOf(Class<?> elementType);
public static Type mapOf(Class<?> keyType, Class<?> valType);