public class CollectionFactory extends Object
Modifier and Type | Class and Description |
---|---|
static class |
CollectionFactory.ConditionalCopySet<T>
a set implementation that uses a delegate collection for all read-only operations and makes a
copy if changes are attempted.
|
Constructor and Description |
---|
CollectionFactory() |
Modifier and Type | Method and Description |
---|---|
static <T> Set<T> |
createLinkedSet() |
static <T> List<T> |
createList() |
static <K,V> Map<K,V> |
createMap() |
static <T> Set<T> |
createSet() |
static <T> Set<T> |
createSet(Collection<T> c) |
static <T> Set<T> |
createSet(int initialCapacity) |
static <T> Set<T> |
createSet(T... elements) |
static <T> Set<T> |
createSet(T element) |
static <T> List<T> |
createSyncList() |
static <K,V> ConcurrentHashMap<K,V> |
createSyncMap() |
static <T> Set<T> |
createSyncSet() |
static <K,V> Map<K,WeakReference<V>> |
createSyncWeakMap() |
static <T> List<T> |
emptyList() |
static <T> Set<T> |
emptySet()
Wrapper for Collections.emptySet() to allow nullity annotations.
|
static <T> Set<T> |
getCopyOnRequestSet(Collection<T> source) |
static <T> Set<T> |
getCopyOnRequestSetFromImmutableCollection(Collection<T> source) |
static <T> Set<T> |
getCopyOnRequestSetFromMutableCollection(Collection<T> source) |
static int |
getExpectedThreads() |
static <T> List<T> |
list(Iterable<T> i) |
static <T> List<T> |
list(T... i) |
static <T> List<T> |
list(T i) |
static void |
setExpectedThreads(int value) |
static <T extends OWLObject> |
sortOptionally(Collection<T> toReturn)
Sort a copy of the input collection; if the ordering is unstable and an error is thrown (due
to the use of TimSort in JDK 1.7 and newer), catch it and leave the collection unsorted.
|
static void |
sortOptionally(List<? extends OWLObject> toReturn)
Sort the input collection; if the ordering is unstable and an error is thrown (due to the use
of TimSort in JDK 1.7 and newer), catch it and leave the collection unsorted.
|
static <T extends Comparable<T>> |
sortOptionallyComparables(Collection<T> toReturn)
Sort a copy of the input collection; if the ordering is unstable and an error is thrown (due
to the use of TimSort in JDK 1.7 and newer), catch it and leave the collection unsorted.
|
static <T extends Comparable<T>> |
sortOptionallyComparables(List<T> toReturn)
Sort the input collection; if the ordering is unstable and an error is thrown (due to the use
of TimSort in JDK 1.7 and newer), catch it and leave the collection unsorted.
|
public static <T extends Comparable<T>> void sortOptionallyComparables(@Nonnull List<T> toReturn)
T
- list typetoReturn
- list to sortpublic static void sortOptionally(@Nonnull List<? extends OWLObject> toReturn)
toReturn
- list to sort@Nonnull public static <T extends Comparable<T>> List<T> sortOptionallyComparables(@Nonnull Collection<T> toReturn)
T
- list typetoReturn
- collection to sort@Nonnull public static <T extends OWLObject> List<T> sortOptionally(@Nonnull Collection<T> toReturn)
T
- list typetoReturn
- collection to sort@Nonnull public static <T> Set<T> emptySet()
T
- set typepublic static void setExpectedThreads(int value)
value
- the number of expected threads that will update threadsafe collections; useful
for increasing the concurrency in ConcurrentHashMap instances created by this factorypublic static int getExpectedThreads()
@Nonnull public static <T> Set<T> createSet()
T
- axiom type@Nonnull public static <T> Set<T> createLinkedSet()
T
- axiom type@Nonnull public static <T> List<T> createList()
T
- axiom type@Nonnull public static <T> List<T> createSyncList()
T
- content type@Nonnull public static <T> List<T> list(Iterable<T> i)
T
- typei
- iterable@Nonnull @SafeVarargs public static <T> List<T> list(T... i)
T
- typei
- iterable@Nonnull public static <T> List<T> list(T i)
T
- typei
- iterable@Nonnull public static <T> List<T> emptyList()
T
- type@Nonnull public static <T> Set<T> createSet(@Nonnull Collection<T> c)
T
- axiom typec
- values to add to the set@Nonnull public static <T> Set<T> createSet(int initialCapacity)
T
- axiom typeinitialCapacity
- initial capacity for the new set@Nonnull public static <K,V> Map<K,V> createMap()
K
- key typeV
- value typepublic static <K,V> Map<K,WeakReference<V>> createSyncWeakMap()
K
- key typeV
- value type@Nonnull @SafeVarargs public static <T> Set<T> createSet(@Nonnull T... elements)
T
- axiom typeelements
- values to add to the set@Nonnull public static <T> Set<T> createSet(@Nonnull T element)
T
- axiom typeelement
- value to add to the set@Nonnull public static <T> Set<T> createSyncSet()
T
- set type@Nonnull public static <K,V> ConcurrentHashMap<K,V> createSyncMap()
K
- key typeV
- value type@Nonnull public static <T> Set<T> getCopyOnRequestSet(Collection<T> source)
T
- axiom typesource
- the collection to lazily copy@Nonnull public static <T> Set<T> getCopyOnRequestSetFromMutableCollection(@Nullable Collection<T> source)
T
- axiom typesource
- source collection@Nonnull public static <T> Set<T> getCopyOnRequestSetFromImmutableCollection(@Nullable Collection<T> source)
T
- axiom typesource
- the source collectionCopyright © 2020 The University of Manchester. All rights reserved.