Class FunctionalPropertyStore
java.lang.Object
org.apache.juneau.commons.settings.FunctionalPropertyStore
- All Implemented Interfaces:
PropertySource,PropertyStore
A writable
PropertyStore implementation created from functional interfaces.-
Constructor Summary
ConstructorsConstructorDescriptionFunctionalPropertyStore(UnaryOperator<String> reader, BiConsumer<String, String> writer, Consumer<String> unsetter, Snippet clearer) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears all properties from this store.Returns a property in this property source.static FunctionalPropertyStoreof(UnaryOperator<String> reader, BiConsumer<String, String> writer, Consumer<String> unsetter, Snippet clearer) Creates a new store from the specified functions.voidSets a property in this store.voidRemoves a property from this store.
-
Constructor Details
-
FunctionalPropertyStore
public FunctionalPropertyStore(UnaryOperator<String> reader, BiConsumer<String, String> writer, Consumer<String> unsetter, Snippet clearer) Constructor.- Parameters:
reader- The function used to read property values by name. Must not benull .writer- The function used to write property values. Must not benull .unsetter- The function used to remove a property by name. Must not benull .clearer- The function used to clear all properties. Must not benull .
-
-
Method Details
-
get
Description copied from interface:PropertySourceReturns a property in this property source.- Specified by:
getin interfacePropertySource- Parameters:
name- The property name.- Returns:
- The property lookup result:
PropertyLookupResult.missing()if this source does not define the key.PropertyLookupResult.present(Optional)withOptional.empty()if the key exists with a null value.PropertyLookupResult.present(Optional)with a value if the key exists with a non-null value.
-
set
Description copied from interface:PropertyStoreSets a property in this store.- Specified by:
setin interfacePropertyStore- Parameters:
name- The property name.value- The property value, ornull to set an empty override.
-
unset
Description copied from interface:PropertyStoreRemoves a property from this store.- Specified by:
unsetin interfacePropertyStore- Parameters:
name- The property name to remove.
-
clear
Description copied from interface:PropertyStoreClears all properties from this store.- Specified by:
clearin interfacePropertyStore
-
of
public static FunctionalPropertyStore of(UnaryOperator<String> reader, BiConsumer<String, String> writer, Consumer<String> unsetter, Snippet clearer) Creates a new store from the specified functions.- Parameters:
reader- The function used to read property values by name. Must not benull .writer- The function used to write property values. Must not benull .unsetter- The function used to remove a property by name. Must not benull .clearer- The function used to clear all properties. Must not benull .- Returns:
- A new store.
-