public class ObjectCollectionFactory extends Object
ObjectCollection
using various utility and helper methods.Modifier and Type | Method and Description |
---|---|
static ObjectCollection |
empty()
Creates a newly created object-collection that is empty.
|
static <T,E extends Exception> |
filterAndMapFrom(Collection<T> collection,
java.util.function.Predicate<T> predicate,
Class<? extends E> throwableClass,
CheckedFunction<T,ObjectMask,E> mapFunction)
Creates a new collection by filtering an iterable and then mapping it to
ObjectMask . |
static <T> ObjectCollection |
filterAndMapFrom(Collection<T> collection,
java.util.function.Predicate<T> predicate,
java.util.function.Function<T,ObjectMask> mapFunction)
Creates a new collection by filtering an iterable and then mapping it to
ObjectMask . |
static <T,E extends Exception> |
filterAndMapWithIndexFrom(List<T> list,
java.util.function.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 to
ObjectMask . |
static <T> ObjectCollection |
flatMapFrom(Collection<T> collection,
java.util.function.Function<T,ObjectCollection> mapFunction)
Creates a new collection by flat-mapping an incoming stream to
ObjectCollection . |
static <T,E extends Exception> |
flatMapFrom(java.util.stream.Stream<T> stream,
Class<? extends Exception> throwableClass,
CheckedFunction<T,ObjectCollection,E> mapFunction)
Creates a new collection by flat-mapping an incoming stream to
ObjectCollection and
rethrowing any exception during mapping. |
static <T,E extends Exception> |
flatMapFromCollection(java.util.stream.Stream<T> stream,
Class<? extends Exception> throwableClass,
CheckedFunction<T,java.util.stream.Stream<? extends ObjectMask>,E> mapFunction)
Creates a new
ObjectCollection by flatMapping an incoming stream to Collection<ObjectMask> and rethrowing any exception during mapping. |
static <E extends Exception> |
flatMapFromRange(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 a
ObjectCollection . |
static ObjectCollection |
flatMapFromRange(int startInclusive,
int endExclusive,
java.util.function.IntFunction<ObjectCollection> mapFunction)
Creates a new collection by flat-mapping integers (from a range) each to a
ObjectCollection . |
static <T,E extends Exception> |
flatMapFromStream(java.util.stream.Stream<T> stream,
Class<? extends Exception> throwableClass,
CheckedFunction<T,java.util.stream.Stream<ObjectMask>,E> mapFunction)
Creates a new collection by flat-mapping an incoming stream to
ObjectCollection and
rethrowing any exception during mapping. |
static ObjectCollection |
fromRepeated(int repeats,
java.util.function.Supplier<ObjectMask> createObjectMask)
Creates a new collection by repeatedly calling a function to create a single
ObjectMask . |
static ObjectCollection |
fromSet(Set<ObjectMask> set)
Creates a new collection from a set of
ObjectMask . |
static <T,E extends Exception> |
mapFrom(Iterable<T> iterable,
Class<? extends E> throwableClass,
CheckedFunction<T,ObjectMask,E> mapFunction)
Creates a new collection by mapping an
Iterable to ObjectMask . |
static <T> ObjectCollection |
mapFrom(Iterable<T> iterable,
java.util.function.Function<T,ObjectMask> mapFunction)
Creates a new collection by mapping an
Iterable to ObjectMask . |
static <T,E extends Exception> |
mapFromOptional(Iterable<T> iterable,
Class<? extends Exception> throwableClass,
CheckedFunction<T,Optional<ObjectMask>,E> mapFunction)
|
static <T> ObjectCollection |
mapFromOptional(Iterable<T> iterable,
java.util.function.Function<T,Optional<ObjectMask>> mapFunction)
|
static <T,E extends Exception> |
mapFromOptional(Iterator<T> iterator,
Class<? extends Exception> throwableClass,
CheckedFunction<T,Optional<ObjectMask>,E> mapFunction)
|
static <T> ObjectCollection |
mapFromOptional(Iterator<T> iterator,
java.util.function.Function<T,Optional<ObjectMask>> mapFunction)
|
static <E extends Exception> |
mapFromRange(int startInclusive,
int endExclusive,
Class<? extends Exception> throwableClass,
CheckedIntFunction<ObjectMask,E> mapFunction)
Creates a new collection by mapping integers (from a range) each to a
ObjectMask . |
static ObjectCollection |
mapFromRange(int startInclusive,
int endExclusive,
java.util.function.IntFunction<ObjectMask> mapFunction)
Creates a new collection by mapping integers (from a range) each to a
ObjectMask . |
static ObjectCollection |
of(BinaryVoxels<UnsignedByteBuffer>... masks)
Creates a new collection with elements from the parameter-list of
BinaryVoxels
converting the voxels in their entirety to an object-mask at the origin. |
static ObjectCollection |
of(Collection<ObjectMask>... collections)
Creates a new collection with elements copied from existing collections.
|
static ObjectCollection |
of(ObjectCollection... collection)
Creates a new collection with elements copied from existing collections.
|
static ObjectCollection |
of(ObjectMask... object)
Creates a new collection with elements from the parameter-list.
|
static ObjectCollection |
of(Optional<ObjectCollection>... collections)
Creates a new collection with elements copied from existing collections, if they exist.
|
public static ObjectCollection empty()
@SafeVarargs public static ObjectCollection of(ObjectMask... object)
object
- object-mask to add to collection.object
.@SafeVarargs public static ObjectCollection of(ObjectCollection... collection)
collection
- existing collections to copy from.objects
.@SafeVarargs public static ObjectCollection of(Optional<ObjectCollection>... collections)
collections
- existing collections to copy from.objects
.@SafeVarargs public static ObjectCollection of(Collection<ObjectMask>... collections)
collections
- one or more collections to add items from.ObjectCollection
, reusing the objects in collections
.public static <T> ObjectCollection mapFrom(Iterable<T> iterable, java.util.function.Function<T,ObjectMask> mapFunction)
Iterable
to ObjectMask
.T
- type that will be mapped to ObjectCollection
.iterable
- source of entities to be mapped.mapFunction
- function for mapping.ObjectCollection
.public static <T,E extends Exception> ObjectCollection mapFrom(Iterable<T> iterable, Class<? extends E> throwableClass, CheckedFunction<T,ObjectMask,E> mapFunction) throws E extends Exception
Iterable
to ObjectMask
.T
- type that will be mapped to ObjectCollection
.E
- exception-type that can be thrown during mapping.iterable
- source of entities to be mapped.throwableClass
- the class of the exception that might be thrown during mapping.mapFunction
- function for mapping.ObjectCollection
.E
- exception if it occurs during mapping.E extends Exception
public static <T> ObjectCollection mapFromOptional(Iterable<T> iterable, java.util.function.Function<T,Optional<ObjectMask>> mapFunction)
Iterable
to Optional
.
The object is only included in the outgoing collection if Optional.isPresent()
.
T
- type that will be mapped to ObjectCollection
.iterable
- iterable to be mapped.mapFunction
- function for mapping.public static <T,E extends Exception> ObjectCollection mapFromOptional(Iterable<T> iterable, Class<? extends Exception> throwableClass, CheckedFunction<T,Optional<ObjectMask>,E> mapFunction) throws E extends Exception
Iterable
to Optional
.
The object is only included in the outgoing collection if Optional.isPresent()
.
T
- type that will be mapped to ObjectCollection
.E
- exception-type that can be thrown during mapping.iterable
- iterable to be mapped.mapFunction
- function for mapping.throwableClass
- the class of the exception that might be thrown during mapping.E
- exception if it occurs during mapping.E extends Exception
public static <T> ObjectCollection mapFromOptional(Iterator<T> iterator, java.util.function.Function<T,Optional<ObjectMask>> mapFunction)
Iterator
to Optional
.
The object is only included in the outgoing collection if Optional.isPresent()
.
T
- type that will be mapped to ObjectCollection
.iterator
- to be mapped.mapFunction
- function for mapping.ObjectCollection
.public static <T,E extends Exception> ObjectCollection mapFromOptional(Iterator<T> iterator, Class<? extends Exception> throwableClass, CheckedFunction<T,Optional<ObjectMask>,E> mapFunction) throws E extends Exception
Iterator
to Optional
.
The object is only included in the outgoing collection if Optional.isPresent()
.
T
- type that will be mapped to ObjectCollection
.E
- exception-type that can be thrown during mapping.iterator
- to be mapped.mapFunction
- function for mapping.throwableClass
- the class of the exception that might be thrown during mapping.ObjectCollection
.E
- exception if it occurs during mapping.E extends Exception
@SafeVarargs public static ObjectCollection of(BinaryVoxels<UnsignedByteBuffer>... masks)
BinaryVoxels
converting the voxels in their entirety to an object-mask at the origin.masks
- object-mask to add to collection.ObjectCollection
.public static ObjectCollection fromSet(Set<ObjectMask> set)
ObjectMask
.set
- set.public static ObjectCollection fromRepeated(int repeats, java.util.function.Supplier<ObjectMask> createObjectMask)
ObjectMask
.repeats
- the number of objects created.createObjectMask
- creates a new object-mask.ObjectCollection
.public static ObjectCollection mapFromRange(int startInclusive, int endExclusive, java.util.function.IntFunction<ObjectMask> mapFunction)
ObjectMask
.startInclusive
- start index for the integer range (inclusive).endExclusive
- end index for the integer range (exclusive).mapFunction
- function for mapping.ObjectCollection
.public static <E extends Exception> ObjectCollection mapFromRange(int startInclusive, int endExclusive, Class<? extends Exception> throwableClass, CheckedIntFunction<ObjectMask,E> mapFunction) throws E extends Exception
ObjectMask
.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.ObjectCollection
.E
- if the exception is thrown during mapping.E extends Exception
public static ObjectCollection flatMapFromRange(int startInclusive, int endExclusive, java.util.function.IntFunction<ObjectCollection> mapFunction)
ObjectCollection
.startInclusive
- start index for the integer range (inclusive).endExclusive
- end index for the integer range (exclusive).mapFunction
- function for flat-mapping.ObjectCollection
.public static <E extends Exception> ObjectCollection flatMapFromRange(int startInclusive, int endExclusive, Class<? extends Exception> throwableClass, CheckedIntFunction<ObjectCollection,E> mapFunction) throws E extends Exception
ObjectCollection
.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.ObjectCollection
.E
- exception if it occurs during mapping.E extends Exception
public static <T> ObjectCollection filterAndMapFrom(Collection<T> collection, java.util.function.Predicate<T> predicate, java.util.function.Function<T,ObjectMask> mapFunction)
ObjectMask
.T
- type that will be mapped to ObjectMask
.collection
- incoming collection to be mapped.predicate
- only elements from the iterable that satisfy this predicate are added.mapFunction
- function for mapping.ObjectCollection
.public static <T,E extends Exception> ObjectCollection filterAndMapFrom(Collection<T> collection, java.util.function.Predicate<T> predicate, Class<? extends E> throwableClass, CheckedFunction<T,ObjectMask,E> mapFunction) throws E extends Exception
ObjectMask
.T
- type that will be mapped to ObjectMask
.E
- exception-type that may be thrown during mapping.collection
- incoming collection to be mapped.predicate
- only elements from the iterable that satisfy this predicate are added.throwableClass
- the class of E
.mapFunction
- function for mapping.ObjectCollection
.E
- if thrown by mapFunction
E extends Exception
public static <T,E extends Exception> ObjectCollection filterAndMapWithIndexFrom(List<T> list, java.util.function.Predicate<T> predicate, Class<? extends E> throwableClass, CheckedBiFunction<T,Integer,ObjectMask,E> mapFunctionWithIndex) throws E extends Exception
ObjectMask
.T
- type that will be mapped to ObjectCollection
.E
- exception that be thrown during mapping.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).ObjectCollection
.E
- if an exception is thrown during mapping.E extends Exception
public static <T> ObjectCollection flatMapFrom(Collection<T> collection, java.util.function.Function<T,ObjectCollection> mapFunction)
ObjectCollection
.T
- type that will be flatMapped to ObjectCollection
.collection
- incoming collection to be flat-mapped.mapFunction
- function for mapping.ObjectCollection
.public static <T,E extends Exception> ObjectCollection flatMapFrom(java.util.stream.Stream<T> stream, Class<? extends Exception> throwableClass, CheckedFunction<T,ObjectCollection,E> mapFunction) throws E extends Exception
ObjectCollection
and
rethrowing any exception during mapping.T
- type that will be flatMapped to ObjectCollection
.stream
- incoming stream to be flat-mapped.throwableClass
- the class of the exception that might be thrown during mapping.mapFunction
- function for flat-mapping.ObjectCollection
.E
- exception of it occurs during mapping.E extends Exception
public static <T,E extends Exception> ObjectCollection flatMapFromStream(java.util.stream.Stream<T> stream, Class<? extends Exception> throwableClass, CheckedFunction<T,java.util.stream.Stream<ObjectMask>,E> mapFunction) throws E extends Exception
ObjectCollection
and
rethrowing any exception during mapping.T
- type that will be flatMapped to ObjectCollection
.stream
- incoming stream to be flat-mapped.throwableClass
- the class of the exception that might be thrown during mapping.mapFunction
- function for flat-mapping.ObjectCollection
.E
- exception of it occurs during mapping.E extends Exception
public static <T,E extends Exception> ObjectCollection flatMapFromCollection(java.util.stream.Stream<T> stream, Class<? extends Exception> throwableClass, CheckedFunction<T,java.util.stream.Stream<? extends ObjectMask>,E> mapFunction) throws E extends Exception
ObjectCollection
by flatMapping an incoming stream to Collection<ObjectMask>
and rethrowing any exception during mapping.T
- type that will be flatMapped to ObjectCollection
.stream
- incoming stream to be flat-mapped.throwableClass
- the class of the exception that might be thrown during mapping.mapFunction
- function for flat-mapping.ObjectCollection
.E
- exception of it occurs during mapping.E extends Exception
Copyright © 2010–2023 Owen Feehan, ETH Zurich, University of Zurich, Hoffmann-La Roche. All rights reserved.