T
- element-typepublic class NamedProviderCombine<T> extends Object implements NamedProvider<T>
NamedProvider
s into a unitary NamedProvider
.
Queries are applied sequentially to each NamedProvider
until successful.
All keys from all underlying NamedProvider
s are valid, but maximally one entry will be
returned for a corresponding key, as first encountered during iteration.
Constructor and Description |
---|
NamedProviderCombine(java.util.stream.Stream<NamedProvider<T>> stream)
Create from a stream of
NamedProvider s. |
Modifier and Type | Method and Description |
---|---|
Optional<T> |
getOptional(String key)
Retrieves the item if it exists, or returns
Optional.empty() if it doesn't exist. |
Set<String> |
keys()
Returns a set of keys associated with the provider.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getArbitraryElement, getException, isEmpty
public NamedProviderCombine(java.util.stream.Stream<NamedProvider<T>> stream)
NamedProvider
s.
Note that the order of this stream, determines the order in which queries occur.
stream
- the streampublic Optional<T> getOptional(String key) throws NamedProviderGetException
NamedProvider
Optional.empty()
if it doesn't exist.
Note that a 'key' might still throw an exception for another reason (but never because a particular key is absent).
getOptional
in interface NamedProvider<T>
key
- a unique name for the item.Optional.empty()
.NamedProviderGetException
- if no item exists for identifier
.public Set<String> keys()
NamedProvider
There's no guarantee that it refers to all valid keys.
keys
in interface NamedProvider<T>
Copyright © 2010–2023 Owen Feehan, ETH Zurich, University of Zurich, Hoffmann-La Roche. All rights reserved.