Class CollectionFactory

java.lang.Object
cz.cvut.kbss.jopa.utils.CollectionFactory

public final class CollectionFactory extends Object
  • Method Details

    • createInstance

      public static Collection<?> createInstance(Collection<?> collection)
      Creates an instance of a Collection implementation best matching the specified instance.

      E.g. for any kind of List, an ArrayList is returned.

      Parameters:
      collection - Create matching instance for this collection
      Returns:
      Best matching collection instance
    • createDefaultCollection

      public static <T> Collection<T> createDefaultCollection(CollectionType collectionType)
      Creates default collection for the specified collection type.
      Parameters:
      collectionType - Type of the collection to create
      Returns:
      Collection implementation instance
    • createDefaultQueryCollection

      public static <T> Collection<T> createDefaultQueryCollection(CollectionType collectionType)
      Creates a default collection for the specified collection type in the context of Queries. This differs from createDefaultCollection(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

      public static Map<Object,Object> createDefaultMap()
      Creates default instance of Map.
      Returns:
      Default Map implementation instance
    • resolveCollectionType

      public static CollectionType resolveCollectionType(Class<?> javaType)
      Resolves CollectionType 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