Package cz.cvut.kbss.jopa.utils
Class CollectionFactory
java.lang.Object
cz.cvut.kbss.jopa.utils.CollectionFactory
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Collection<T>createDefaultCollection(CollectionType collectionType) Creates default collection for the specified collection type.Creates default instance ofMap.static <T> Collection<T>createDefaultQueryCollection(CollectionType collectionType) Creates a default collection for the specified collection type in the context of Queries.static Collection<?>createInstance(Collection<?> collection) Creates an instance of aCollectionimplementation best matching the specified instance.static CollectionTyperesolveCollectionType(Class<?> javaType) ResolvesCollectionTypefrom the specified Java class.
-
Method Details
-
createInstance
Creates an instance of aCollectionimplementation best matching the specified instance.- Parameters:
collection- Create matching instance for this collection- Returns:
- Best matching collection instance
-
createDefaultCollection
Creates default collection for the specified collection type.- Parameters:
collectionType- Type of the collection to create- Returns:
- Collection implementation instance
-
createDefaultQueryCollection
Creates a default collection for the specified collection type in the context of Queries. This differs fromcreateDefaultCollection(cz.cvut.kbss.jopa.model.metamodel.CollectionType), because SPARQL results are treated as lists, so Collections should be handled as Lists, not as Sets- Parameters:
collectionType- Type of the collection to create- Returns:
- Collection implementation instance
-
createDefaultMap
Creates default instance ofMap.- Returns:
- Default Map implementation instance
-
resolveCollectionType
ResolvesCollectionTypefrom the specified Java class.- Parameters:
javaType- Java type whose collection type to resolve- Returns:
CollectionTypevalue- Throws:
IllegalArgumentException- When unsupported java type is provided
-