Class CollectionFactory

java.lang.Object
org.semanticweb.owlapi.util.CollectionFactory

public class CollectionFactory extends Object
Since:
2.0.0
Author:
Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group
  • Method Details

    • getExpectedThreads

      public static int getExpectedThreads()
      Returns:
      The current number of expected updating threads.
    • setExpectedThreads

      public static void setExpectedThreads(int value)
      Parameters:
      value - the number of expected threads that will update threadsafe collections; useful for increasing the concurrency in ConcurrentHashMap instances created by this factory
    • createSet

      public static <T> Set<T> createSet()
      Type Parameters:
      T - axiom type
      Returns:
      fresh non threadsafe set
    • createLinkedSet

      public static <T> Set<T> createLinkedSet()
      Type Parameters:
      T - axiom type
      Returns:
      fresh non threadsafe set
    • createList

      public static <T> List<T> createList()
      Type Parameters:
      T - axiom type
      Returns:
      fresh non threadsafe list
    • createList

      @SafeVarargs public static <T> List<T> createList(T... elements)
      Type Parameters:
      T - axiom type
      Parameters:
      elements - values to add to the list
      Returns:
      fresh non threadsafe list
    • createSyncList

      public static <T> List<T> createSyncList()
      Type Parameters:
      T - content type
      Returns:
      fresh threadsafe list
    • list

      public static <T> List<T> list(Iterable<T> i)
      Type Parameters:
      T - type
      Parameters:
      i - iterable
      Returns:
      list from iterable
    • list

      @SafeVarargs public static <T> List<T> list(T... i)
      Type Parameters:
      T - type
      Parameters:
      i - iterable
      Returns:
      list from iterable
    • list

      public static <T> List<T> list(T i)
      Type Parameters:
      T - type
      Parameters:
      i - iterable
      Returns:
      list from iterable
    • createSet

      public static <T> Set<T> createSet(Collection<T> c)
      Type Parameters:
      T - axiom type
      Parameters:
      c - values to add to the set
      Returns:
      fresh non threadsafe set
    • createSet

      public static <T> Set<T> createSet(int initialCapacity)
      Type Parameters:
      T - axiom type
      Parameters:
      initialCapacity - initial capacity for the new set
      Returns:
      fresh non threadsafe set
    • createMap

      public static <K, V> Map<K,V> createMap()
      Type Parameters:
      K - key type
      V - value type
      Returns:
      fresh map
    • createSyncWeakMap

      public static <K, V> Map<K,WeakReference<V>> createSyncWeakMap()
      Type Parameters:
      K - key type
      V - value type
      Returns:
      a new weak HashMap wrapped as a synchronized map
    • createSet

      @SafeVarargs public static <T> Set<T> createSet(T... elements)
      Type Parameters:
      T - axiom type
      Parameters:
      elements - values to add to the set
      Returns:
      fresh non threadsafe set
    • createSet

      public static <T> Set<T> createSet(T element)
      Type Parameters:
      T - axiom type
      Parameters:
      element - value to add to the set
      Returns:
      fresh non threadsafe set
    • createSyncSet

      public static <T> Set<T> createSyncSet()
      Type Parameters:
      T - set type
      Returns:
      fresh threadsafe set
    • createSyncMap

      public static <K, V> ConcurrentHashMap<K,V> createSyncMap()
      Type Parameters:
      K - key type
      V - value type
      Returns:
      fresh threadsafe HashMap
    • getCopyOnRequestSet

      public static <T> Set<T> getCopyOnRequestSet(Collection<T> source)
      Type Parameters:
      T - axiom type
      Parameters:
      source - the collection to lazily copy
      Returns:
      a lazy defensive copy for source; the source collection will not be copied until a method that modifies the collection gets called, e.g., add(), addAll()
    • getCopyOnRequestSetFromMutableCollection

      public static <T> Set<T> getCopyOnRequestSetFromMutableCollection(@Nullable Collection<T> source)
      Type Parameters:
      T - axiom type
      Parameters:
      source - source collection
      Returns:
      copy on request that builds a list from the input set
    • copy

      public static <T> Set<T> copy(@Nullable Collection<T> source)
      Type Parameters:
      T - axiom type
      Parameters:
      source - the source collection, expected to be immutable
      Returns:
      copy on request that does not build a list immediately
    • copyMutable

      public static <T> Set<T> copyMutable(@Nullable Collection<T> source)
      Type Parameters:
      T - axiom type
      Parameters:
      source - the source collection, expected to be mutable; the backing list is created immediately
      Returns:
      copy on request that builds a list immediately
    • getCopyOnRequestSetFromImmutableCollection

      public static <T> Set<T> getCopyOnRequestSetFromImmutableCollection(@Nullable Collection<T> source)
      Type Parameters:
      T - axiom type
      Parameters:
      source - the source collection, expected to be immutable
      Returns:
      copy on request that does not build a list immediately