Class ObjectCollectionFactory
Object
ObjectCollectionFactory
Creates
ObjectCollection using various utility and helper methods.- Author:
- Owen Feehan
-
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectCollectionempty()Creates a newly created object-collection that is empty.static <T,E extends Exception>
ObjectCollectionfilterAndMapFrom(Collection<T> collection, Predicate<T> predicate, Class<? extends E> throwableClass, CheckedFunction<T, ObjectMask, E> mapFunction) Creates a new collection by filtering an iterable and then mapping it toObjectMask.static <T> ObjectCollectionfilterAndMapFrom(Collection<T> collection, Predicate<T> predicate, Function<T, ObjectMask> mapFunction) Creates a new collection by filtering an iterable and then mapping it toObjectMask.static <T,E extends Exception>
ObjectCollectionfilterAndMapWithIndexFrom(List<T> list, Predicate<T> predicate, Class<? extends E> throwableClass, CheckedBiFunction<T, Integer, ObjectMask, E> mapFunctionWithIndex) Creates a new collection by filtering a list and then mapping from it toObjectMask.static <T> ObjectCollectionflatMapFrom(Collection<T> collection, Function<T, ObjectCollection> mapFunction) Creates a new collection by flat-mapping an incoming stream toObjectCollection.static <T,E extends Exception>
ObjectCollectionflatMapFrom(Stream<T> stream, Class<? extends Exception> throwableClass, CheckedFunction<T, ObjectCollection, E> mapFunction) Creates a new collection by flat-mapping an incoming stream toObjectCollectionand rethrowing any exception during mapping.static <T,E extends Exception>
ObjectCollectionflatMapFromCollection(Stream<T> stream, Class<? extends Exception> throwableClass, CheckedFunction<T, Stream<? extends ObjectMask>, E> mapFunction) Creates a newObjectCollectionby flatMapping an incoming stream toCollection<ObjectMask>and rethrowing any exception during mapping.static <E extends Exception>
ObjectCollectionflatMapFromRange(int startInclusive, int endExclusive, Class<? extends Exception> throwableClass, CheckedIntFunction<ObjectCollection, E> mapFunction) Creates a new collection by flat-mapping integers (from a range) each to aObjectCollection.static ObjectCollectionflatMapFromRange(int startInclusive, int endExclusive, IntFunction<ObjectCollection> mapFunction) Creates a new collection by flat-mapping integers (from a range) each to aObjectCollection.static <T,E extends Exception>
ObjectCollectionflatMapFromStream(Stream<T> stream, Class<? extends Exception> throwableClass, CheckedFunction<T, Stream<ObjectMask>, E> mapFunction) Creates a new collection by flat-mapping an incoming stream toObjectCollectionand rethrowing any exception during mapping.static ObjectCollectionfromRepeated(int repeats, Supplier<ObjectMask> createObjectMask) Creates a new collection by repeatedly calling a function to create a singleObjectMask.static ObjectCollectionfromSet(Set<ObjectMask> set) Creates a new collection from a set ofObjectMask.static <T,E extends Exception>
ObjectCollectionmapFrom(Iterable<T> iterable, Class<? extends E> throwableClass, CheckedFunction<T, ObjectMask, E> mapFunction) Creates a new collection by mapping anIterabletoObjectMask.static <T> ObjectCollectionmapFrom(Iterable<T> iterable, Function<T, ObjectMask> mapFunction) Creates a new collection by mapping anIterabletoObjectMask.static <T,E extends Exception>
ObjectCollectionmapFromOptional(Iterable<T> iterable, Class<? extends Exception> throwableClass, CheckedFunction<T, Optional<ObjectMask>, E> mapFunction) static <T> ObjectCollectionmapFromOptional(Iterable<T> iterable, Function<T, Optional<ObjectMask>> mapFunction) static <T,E extends Exception>
ObjectCollectionmapFromOptional(Iterator<T> iterator, Class<? extends Exception> throwableClass, CheckedFunction<T, Optional<ObjectMask>, E> mapFunction) static <T> ObjectCollectionmapFromOptional(Iterator<T> iterator, Function<T, Optional<ObjectMask>> mapFunction) static <E extends Exception>
ObjectCollectionmapFromRange(int startInclusive, int endExclusive, Class<? extends Exception> throwableClass, CheckedIntFunction<ObjectMask, E> mapFunction) Creates a new collection by mapping integers (from a range) each to aObjectMask.static ObjectCollectionmapFromRange(int startInclusive, int endExclusive, IntFunction<ObjectMask> mapFunction) Creates a new collection by mapping integers (from a range) each to aObjectMask.static ObjectCollectionof(Collection<ObjectMask>... collections) Creates a new collection with elements copied from existing collections.static ObjectCollectionof(Optional<ObjectCollection>... collections) Creates a new collection with elements copied from existing collections, if they exist.static ObjectCollectionof(BinaryVoxels<UnsignedByteBuffer>... masks) Creates a new collection with elements from the parameter-list ofBinaryVoxelsconverting the voxels in their entirety to an object-mask at the origin.static ObjectCollectionof(ObjectCollection... collection) Creates a new collection with elements copied from existing collections.static ObjectCollectionof(ObjectMask... object) Creates a new collection with elements from the parameter-list.
-
Method Details
-
empty
Creates a newly created object-collection that is empty.- Returns:
- a newly-created empty object collection.
-
of
Creates a new collection with elements from the parameter-list.- Parameters:
object- object-mask to add to collection.- Returns:
- the newly-created collection, reusing
object.
-
of
Creates a new collection with elements copied from existing collections.- Parameters:
collection- existing collections to copy from.- Returns:
- the newly-created collection, reusing the objects from
objects.
-
of
Creates a new collection with elements copied from existing collections, if they exist.- Parameters:
collections- existing collections to copy from.- Returns:
- the newly-created collection, reusing the objects from
objects.
-
of
Creates a new collection with elements copied from existing collections.- Parameters:
collections- one or more collections to add items from.- Returns:
- a newly created
ObjectCollection, reusing the objects incollections.
-
mapFrom
public static <T> ObjectCollection mapFrom(Iterable<T> iterable, Function<T, ObjectMask> mapFunction) Creates a new collection by mapping anIterabletoObjectMask.- Type Parameters:
T- type that will be mapped toObjectCollection.- Parameters:
iterable- source of entities to be mapped.mapFunction- function for mapping.- Returns:
- a newly created
ObjectCollection.
-
mapFrom
public static <T,E extends Exception> ObjectCollection mapFrom(Iterable<T> iterable, Class<? extends E> throwableClass, CheckedFunction<T, ObjectMask, throws EE> mapFunction) Creates a new collection by mapping anIterabletoObjectMask.- Type Parameters:
T- type that will be mapped toObjectCollection.E- exception-type that can be thrown during mapping.- Parameters:
iterable- source of entities to be mapped.throwableClass- the class of the exception that might be thrown during mapping.mapFunction- function for mapping.- Returns:
- a newly created
ObjectCollection. - Throws:
E- exception if it occurs during mapping.
-
mapFromOptional
public static <T> ObjectCollection mapFromOptional(Iterable<T> iterable, Function<T, Optional<ObjectMask>> mapFunction) Creates a new collection by mapping anIterabletoOptional.The object is only included in the outgoing collection if
Optional.isPresent().- Type Parameters:
T- type that will be mapped toObjectCollection.- Parameters:
iterable- iterable to be mapped.mapFunction- function for mapping.- Returns:
- a newly created ObjectCollection.
-
mapFromOptional
public static <T,E extends Exception> ObjectCollection mapFromOptional(Iterable<T> iterable, Class<? extends Exception> throwableClass, CheckedFunction<T, Optional<ObjectMask>, throws EE> mapFunction) Creates a new collection by mapping anIterabletoOptional.The object is only included in the outgoing collection if
Optional.isPresent().- Type Parameters:
T- type that will be mapped toObjectCollection.E- exception-type that can be thrown during mapping.- Parameters:
iterable- iterable to be mapped.throwableClass- the class of the exception that might be thrown during mapping.mapFunction- function for mapping.- Returns:
- a newly created ObjectCollection.
- Throws:
E- exception if it occurs during mapping.
-
mapFromOptional
public static <T> ObjectCollection mapFromOptional(Iterator<T> iterator, Function<T, Optional<ObjectMask>> mapFunction) Creates a new collection by mapping anIteratortoOptional.The object is only included in the outgoing collection if
Optional.isPresent().- Type Parameters:
T- type that will be mapped toObjectCollection.- Parameters:
iterator- to be mapped.mapFunction- function for mapping.- Returns:
- a newly created
ObjectCollection.
-
mapFromOptional
public static <T,E extends Exception> ObjectCollection mapFromOptional(Iterator<T> iterator, Class<? extends Exception> throwableClass, CheckedFunction<T, Optional<ObjectMask>, throws EE> mapFunction) Creates a new collection by mapping anIteratortoOptional.The object is only included in the outgoing collection if
Optional.isPresent().- Type Parameters:
T- type that will be mapped toObjectCollection.E- exception-type that can be thrown during mapping.- Parameters:
iterator- to be mapped.throwableClass- the class of the exception that might be thrown during mapping.mapFunction- function for mapping.- Returns:
- a newly created
ObjectCollection. - Throws:
E- exception if it occurs during mapping.
-
of
Creates a new collection with elements from the parameter-list ofBinaryVoxelsconverting the voxels in their entirety to an object-mask at the origin.- Parameters:
masks- object-mask to add to collection.- Returns:
- a newly created
ObjectCollection.
-
fromSet
Creates a new collection from a set ofObjectMask.- Parameters:
set- set.- Returns:
- the newly created collection.
-
fromRepeated
Creates a new collection by repeatedly calling a function to create a singleObjectMask.- Parameters:
repeats- the number of objects created.createObjectMask- creates a new object-mask.- Returns:
- a newly created
ObjectCollection.
-
mapFromRange
public static ObjectCollection mapFromRange(int startInclusive, int endExclusive, IntFunction<ObjectMask> mapFunction) Creates a new collection by mapping integers (from a range) each to aObjectMask.- Parameters:
startInclusive- start index for the integer range (inclusive).endExclusive- end index for the integer range (exclusive).mapFunction- function for mapping.- Returns:
- a newly created
ObjectCollection.
-
mapFromRange
public static <E extends Exception> ObjectCollection mapFromRange(int startInclusive, int endExclusive, Class<? extends Exception> throwableClass, CheckedIntFunction<ObjectMask, E> mapFunction) throws ECreates a new collection by mapping integers (from a range) each to aObjectMask.- Parameters:
startInclusive- start index for the integer range (inclusive).endExclusive- end index for the integer range (exclusive).throwableClass- the class of the exception that might be thrown during mapping.mapFunction- function for mapping.- Returns:
- a newly created
ObjectCollection. - Throws:
E- if the exception is thrown during mapping.
-
flatMapFromRange
public static ObjectCollection flatMapFromRange(int startInclusive, int endExclusive, IntFunction<ObjectCollection> mapFunction) Creates a new collection by flat-mapping integers (from a range) each to aObjectCollection.- Parameters:
startInclusive- start index for the integer range (inclusive).endExclusive- end index for the integer range (exclusive).mapFunction- function for flat-mapping.- Returns:
- a newly created
ObjectCollection.
-
flatMapFromRange
public static <E extends Exception> ObjectCollection flatMapFromRange(int startInclusive, int endExclusive, Class<? extends Exception> throwableClass, CheckedIntFunction<ObjectCollection, E> mapFunction) throws ECreates a new collection by flat-mapping integers (from a range) each to aObjectCollection.- Parameters:
startInclusive- start index for the integer range (inclusive).endExclusive- end index for the integer range (exclusive).throwableClass- the class of the exception that might be thrown during mapping.mapFunction- function for flat-mapping.- Returns:
- a newly created
ObjectCollection. - Throws:
E- exception if it occurs during mapping.
-
filterAndMapFrom
public static <T> ObjectCollection filterAndMapFrom(Collection<T> collection, Predicate<T> predicate, Function<T, ObjectMask> mapFunction) Creates a new collection by filtering an iterable and then mapping it toObjectMask.- Type Parameters:
T- type that will be mapped toObjectMask.- Parameters:
collection- incoming collection to be mapped.predicate- only elements from the iterable that satisfy this predicate are added.mapFunction- function for mapping.- Returns:
- a newly created
ObjectCollection.
-
filterAndMapFrom
public static <T,E extends Exception> ObjectCollection filterAndMapFrom(Collection<T> collection, Predicate<T> predicate, Class<? extends E> throwableClass, CheckedFunction<T, ObjectMask, throws EE> mapFunction) Creates a new collection by filtering an iterable and then mapping it toObjectMask.- Type Parameters:
T- type that will be mapped toObjectMask.E- exception-type that may be thrown during mapping.- Parameters:
collection- incoming collection to be mapped.predicate- only elements from the iterable that satisfy this predicate are added.throwableClass- the class ofE.mapFunction- function for mapping.- Returns:
- a newly created
ObjectCollection. - Throws:
E- if thrown bymapFunction
-
filterAndMapWithIndexFrom
public static <T,E extends Exception> ObjectCollection filterAndMapWithIndexFrom(List<T> list, Predicate<T> predicate, Class<? extends E> throwableClass, CheckedBiFunction<T, Integer, throws EObjectMask, E> mapFunctionWithIndex) Creates a new collection by filtering a list and then mapping from it toObjectMask.- Type Parameters:
T- type that will be mapped toObjectCollection.E- exception that be thrown during mapping.- Parameters:
list- incoming list to be mapped.predicate- only elements from the list that satisfy this predicate are added.throwableClass- the class of the exception that might be thrown during mapping.mapFunctionWithIndex- function for mapping, also including an index (the original position in the bounding-box).- Returns:
- a newly created
ObjectCollection. - Throws:
E- if an exception is thrown during mapping.
-
flatMapFrom
public static <T> ObjectCollection flatMapFrom(Collection<T> collection, Function<T, ObjectCollection> mapFunction) Creates a new collection by flat-mapping an incoming stream toObjectCollection.- Type Parameters:
T- type that will be flatMapped toObjectCollection.- Parameters:
collection- incoming collection to be flat-mapped.mapFunction- function for mapping.- Returns:
- a newly created
ObjectCollection.
-
flatMapFrom
public static <T,E extends Exception> ObjectCollection flatMapFrom(Stream<T> stream, Class<? extends Exception> throwableClass, CheckedFunction<T, ObjectCollection, throws EE> mapFunction) Creates a new collection by flat-mapping an incoming stream toObjectCollectionand rethrowing any exception during mapping.- Type Parameters:
T- type that will be flatMapped toObjectCollection.- Parameters:
stream- incoming stream to be flat-mapped.throwableClass- the class of the exception that might be thrown during mapping.mapFunction- function for flat-mapping.- Returns:
- a newly created
ObjectCollection. - Throws:
E- exception of it occurs during mapping.
-
flatMapFromStream
public static <T,E extends Exception> ObjectCollection flatMapFromStream(Stream<T> stream, Class<? extends Exception> throwableClass, CheckedFunction<T, Stream<ObjectMask>, throws EE> mapFunction) Creates a new collection by flat-mapping an incoming stream toObjectCollectionand rethrowing any exception during mapping.- Type Parameters:
T- type that will be flatMapped toObjectCollection.- Parameters:
stream- incoming stream to be flat-mapped.throwableClass- the class of the exception that might be thrown during mapping.mapFunction- function for flat-mapping.- Returns:
- a newly created
ObjectCollection. - Throws:
E- exception of it occurs during mapping.
-
flatMapFromCollection
public static <T,E extends Exception> ObjectCollection flatMapFromCollection(Stream<T> stream, Class<? extends Exception> throwableClass, CheckedFunction<T, Stream<? extends ObjectMask>, throws EE> mapFunction) Creates a newObjectCollectionby flatMapping an incoming stream toCollection<ObjectMask>and rethrowing any exception during mapping.- Type Parameters:
T- type that will be flatMapped toObjectCollection.- Parameters:
stream- incoming stream to be flat-mapped.throwableClass- the class of the exception that might be thrown during mapping.mapFunction- function for flat-mapping.- Returns:
- a newly created
ObjectCollection. - Throws:
E- exception of it occurs during mapping.
-