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 aCollection
implementation best matching the specified instance.static CollectionType
resolveCollectionType
(Class<?> javaType) ResolvesCollectionType
from the specified Java class.
-
Method Details
-
createInstance
Creates an instance of aCollection
implementation 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
ResolvesCollectionType
from the specified Java class.- Parameters:
javaType
- Java type whose collection type to resolve- Returns:
CollectionType
value- Throws:
IllegalArgumentException
- When unsupported java type is provided
-