Package org.n52.shetland.ogc.om
Interface ObservationStream
-
- All Superinterfaces:
AutoCloseable,ThrowingIterator<OmObservation,OwsExceptionReport>
- All Known Implementing Classes:
AbstractObservationStream,AbstractStreaming,StreamingValue
public interface ObservationStream extends ThrowingIterator<OmObservation,OwsExceptionReport>, AutoCloseable
TODO JavaDoc
-
-
Method Summary
All Methods Static Methods Instance Methods Default Methods Modifier and Type Method Description default voidclose()default <T extends Collection<OmObservation>>
Tcollect(Supplier<T> supplier)static ObservationStreamempty()Creates an empty observation stream.default ObservationStreamfilter(Predicate<OmObservation> predicate)Creates a new observation stream that filters the observatons from the original stream using the supplied predicate.default Optional<OmObservation>findAny()As this stream is always serial this is the same asfindFirst().default Optional<OmObservation>findFirst()Gets the next value that is in the stream.default ObservationStreamflatMap(ThrowingFunction<OmObservation,ObservationStream,OwsExceptionReport> mapper)Creates a new observation stream from a mapping function that produces a stream for every observation in this stream.default ObservationStreammap(ThrowingUnaryOperator<OmObservation,OwsExceptionReport> operator)Produces a observation new stream from a mapping function that produces a new observation for every observation in this stream.default ObservationStreammerge()Creates a new stream out of this stream in which observations with the same observation constellation are merged.default ObservationStreammerge(ObservationMergeIndicator indicator)Creates a new stream out of this stream in which observations with the same observation constellation are merged.default ObservationStreammodify(ThrowingConsumer<OmObservation,OwsExceptionReport> consumer)Creates a new observation stream from an consumer that consumes every observation before it is emitted by the stream.static ObservationStreamof(Iterable<OmObservation> observations)Creates a new observation stream from the supplied iterable.static ObservationStreamof(Iterator<OmObservation> observations)Creates a new observation stream from the supplied iterator.static ObservationStreamof(OmObservation observation)Creates a new observation stream from the supplied observation.default Stream<OmObservation>toStream()Creates a new stream of this observation stream.-
Methods inherited from interface org.n52.janmayen.ThrowingIterator
forEachRemaining, hasNext, next, remove
-
-
-
-
Method Detail
-
close
default void close()
- Specified by:
closein interfaceAutoCloseable
-
collect
default <T extends Collection<OmObservation>> T collect(Supplier<T> supplier) throws OwsExceptionReport
- Throws:
OwsExceptionReport
-
findFirst
default Optional<OmObservation> findFirst() throws OwsExceptionReport
Gets the next value that is in the stream.- Returns:
- the first observation of the stream
- Throws:
OwsExceptionReport- if an error occurs during observation retrieval
-
toStream
default Stream<OmObservation> toStream()
Creates a new stream of this observation stream. Note that consuming the stream will drain the iterator and all thrown exceptions will be wrapped inRuntimeExceptions.- Returns:
- the stream
-
findAny
default Optional<OmObservation> findAny() throws OwsExceptionReport
As this stream is always serial this is the same asfindFirst().- Returns:
- the first observation of the stream
- Throws:
OwsExceptionReport- if an error occurs during observation retrieval
-
modify
@CheckReturnValue default ObservationStream modify(ThrowingConsumer<OmObservation,OwsExceptionReport> consumer)
Creates a new observation stream from an consumer that consumes every observation before it is emitted by the stream.- Parameters:
consumer- the consumer- Returns:
- the new stream
-
flatMap
@CheckReturnValue default ObservationStream flatMap(ThrowingFunction<OmObservation,ObservationStream,OwsExceptionReport> mapper)
Creates a new observation stream from a mapping function that produces a stream for every observation in this stream.- Parameters:
mapper- the mapping function- Returns:
- the new stream
-
map
@CheckReturnValue default ObservationStream map(ThrowingUnaryOperator<OmObservation,OwsExceptionReport> operator)
Produces a observation new stream from a mapping function that produces a new observation for every observation in this stream.- Parameters:
operator- the mapping function- Returns:
- the new stream
-
filter
@CheckReturnValue default ObservationStream filter(Predicate<OmObservation> predicate)
Creates a new observation stream that filters the observatons from the original stream using the supplied predicate.- Parameters:
predicate- the filter- Returns:
- the new stream
-
merge
@CheckReturnValue default ObservationStream merge() throws OwsExceptionReport
Creates a new stream out of this stream in which observations with the same observation constellation are merged. Be aware that this method will consume this stream completely.- Returns:
- the new observation stream
- Throws:
OwsExceptionReport- if an error occurs during observation retrieval- See Also:
OmObservation.checkForMerge(org.n52.shetland.ogc.om.OmObservation),OmObservation.mergeWithObservation(org.n52.shetland.ogc.om.OmObservation)
-
merge
@CheckReturnValue default ObservationStream merge(ObservationMergeIndicator indicator) throws OwsExceptionReport
Creates a new stream out of this stream in which observations with the same observation constellation are merged. Be aware that this method will consume this stream completely.- Parameters:
indicator-- Returns:
- the new observation stream
- Throws:
OwsExceptionReport- if an error occurs during observation retrieval- See Also:
OmObservation.checkForMerge(org.n52.shetland.ogc.om.OmObservation),OmObservation.mergeWithObservation(org.n52.shetland.ogc.om.OmObservation)
-
empty
static ObservationStream empty()
Creates an empty observation stream.- Returns:
- the stream
-
of
static ObservationStream of(Iterator<OmObservation> observations)
Creates a new observation stream from the supplied iterator.- Parameters:
observations- the observations- Returns:
- the stream
-
of
static ObservationStream of(Iterable<OmObservation> observations)
Creates a new observation stream from the supplied iterable.- Parameters:
observations- the observations- Returns:
- the stream
-
of
static ObservationStream of(OmObservation observation)
Creates a new observation stream from the supplied observation.- Parameters:
observation- the observation- Returns:
- the stream
-
-