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 newNamedProviderBridgeinstance. -
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, waitMethods 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- theNamedProviderthat supplies elements, before conversion.bridge- a function that converts the elements inprovideras they are accessed.
-
NamedProviderBridge
public NamedProviderBridge(NamedProvider<S> provider, CheckedFunction<S, T, ? extends Exception> bridge, boolean bridgeNulls) Creates a newNamedProviderBridgeinstance.- Parameters:
provider- TheNamedProviderthat supplies elements, before conversion.bridge- A function that converts the elements inprovideras they are accessed.bridgeNulls- Whether to apply thebridgefunction to null values.Iff true, the
bridgefunction is applied to null values. If false, aOptional.empty()is returned instead.
-
-
Method Details
-
getOptional
Description copied from interface:NamedProviderRetrieves 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:
getOptionalin 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:NamedProviderReturns a set of keys associated with the provider.There's no guarantee that it refers to all valid keys.
- Specified by:
keysin interfaceNamedProvider<S>- Returns:
- a set of all keys associated with the provider.
-