Class NamedProviderBridge<S,T>
Object
NamedProviderBridge<S,T>
- Type Parameters:
S
- source-type that is converted from.T
- destination-type that is converted to.
- All Implemented Interfaces:
NamedProvider<T>
Exposes elements in a
NamedProvider
as a different type.- Author:
- Owen Feehan
-
Constructor Summary
ConstructorsConstructorDescriptionNamedProviderBridge
(NamedProvider<S> provider, CheckedFunction<S, T, ? extends Exception> bridge) Creates with a particular provider and bridge.NamedProviderBridge
(NamedProvider<S> provider, CheckedFunction<S, T, ? extends Exception> bridge, boolean bridgeNulls) Creates a newNamedProviderBridge
instance. -
Method Summary
Modifier and TypeMethodDescriptiongetOptional
(String key) Retrieves the item if it exists, or returnsOptional.empty()
if it doesn't exist.keys()
Returns a set of keys associated with the provider.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.anchoranalysis.core.identifier.provider.NamedProvider
getArbitraryElement, getException, isEmpty
-
Constructor Details
-
NamedProviderBridge
public NamedProviderBridge(NamedProvider<S> provider, CheckedFunction<S, T, ? extends Exception> bridge) Creates with a particular provider and bridge.- Parameters:
provider
- theNamedProvider
that supplies elements, before conversion.bridge
- a function that converts the elements inprovider
as they are accessed.
-
NamedProviderBridge
public NamedProviderBridge(NamedProvider<S> provider, CheckedFunction<S, T, ? extends Exception> bridge, boolean bridgeNulls) Creates a newNamedProviderBridge
instance.- Parameters:
provider
- TheNamedProvider
that supplies elements, before conversion.bridge
- A function that converts the elements inprovider
as they are accessed.bridgeNulls
- Whether to apply thebridge
function to null values.Iff true, the
bridge
function is applied to null values. If false, aOptional.empty()
is returned instead.
-
-
Method Details
-
getOptional
Description copied from interface:NamedProvider
Retrieves the item if it exists, or returnsOptional.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).
- Specified by:
getOptional
in interfaceNamedProvider<S>
- Parameters:
key
- a unique name for the item.- Returns:
- the item, if it exists, otherwise
Optional.empty()
. - Throws:
NamedProviderGetException
- if no item exists foridentifier
.
-
keys
Description copied from interface:NamedProvider
Returns a set of keys associated with the provider.There's no guarantee that it refers to all valid keys.
- Specified by:
keys
in interfaceNamedProvider<S>
- Returns:
- a set of all keys associated with the provider.
-