Class OptionalValue<V>
java.lang.Object
ch.nolix.system.property.value.AbstractValue<V>
ch.nolix.system.property.value.OptionalValue<V>
- Type Parameters:
V- is the type of the value of aOptionalValue.
- All Implemented Interfaces:
INameHolder, Clearable, EmptinessRequestable, MaterializationRequestable, IProperty, IBaseValue, IOptionalValue<V>
- Author:
- Silvan Wyss
-
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Removes the elements of the currentClearable.voidfillUpAttributesIntoList(ILinkedList<INode<?>> list) Fills up the attributes of the currentIPropertyinto the given list.static OptionalValue<Boolean> forBooleanWithNameAndSetter(String name, Consumer<Boolean> setter) static OptionalValue<Double> forDoubleWithNameAndSetter(String name, Consumer<Double> setter) static <E extends IElement>
OptionalValue<E> forElementWithNameAndSetterAndValueMapper(String name, Consumer<E> setter, Function<INode<?>, E> valueMapper) static OptionalValue<Integer> forIntWithNameAndSetter(String name, Consumer<Integer> setter) static OptionalValue<String> forStringWithNameAndSetter(String name, Consumer<String> setter) booleanisEmpty()voidSets the given value to the currentIOptionalValue.static <T> OptionalValue<T> withNameAndSetterAndValueMapperAndSpecificationMapper(String name, Consumer<T> setter, Function<INode<?>, T> valueMapper, Function<T, INode<?>> specificationMapper) Methods inherited from class AbstractValue
addedOrChangedAttribute, getName, isMaterializedMethods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface EmptinessRequestable
containsAnyMethods inherited from interface INameHolder
getName, getNameInQuotes, hasName, hasSameNameAsMethods inherited from interface IProperty
addedOrChangedAttributeMethods inherited from interface MaterializationRequestable
isMaterialized, isView
-
Method Details
-
forBooleanWithNameAndSetter
public static OptionalValue<Boolean> forBooleanWithNameAndSetter(String name, Consumer<Boolean> setter) - Parameters:
name-setter-- Returns:
- a new
OptionalValuewith the given name and setter and that can store aBoolean. - Throws:
RuntimeException- if the given name is null or blank.RuntimeException- if the given setter is null.
-
forDoubleWithNameAndSetter
public static OptionalValue<Double> forDoubleWithNameAndSetter(String name, Consumer<Double> setter) - Parameters:
name-setter-- Returns:
- a new
OptionalValuewith the given name and setter and that can store aDouble. - Throws:
RuntimeException- if the given name is null or blank.RuntimeException- if the given setter is null.
-
forElementWithNameAndSetterAndValueMapper
public static <E extends IElement> OptionalValue<E> forElementWithNameAndSetterAndValueMapper(String name, Consumer<E> setter, Function<INode<?>, E> valueMapper) - Type Parameters:
E- is the type of the value of aOptionalValue.- Parameters:
name-setter-valueMapper-- Returns:
- a new
OptionalValuewith the given name, setter and valueMapperand and that can store aIElement. - Throws:
RuntimeException- if the given name is null or blank.RuntimeException- if the given setter is null.RuntimeException- if the given valueMapper is null.
-
forIntWithNameAndSetter
- Parameters:
name-setter-- Returns:
- a new
OptionalValuewith the given name and setter and that can store aInteger. - Throws:
RuntimeException- if the given name is null or blank.RuntimeException- if the given setter is null.
-
forStringWithNameAndSetter
public static OptionalValue<String> forStringWithNameAndSetter(String name, Consumer<String> setter) - Parameters:
name-setter-- Returns:
- a new
OptionalValuewith the given name and setter and that can store aString. - Throws:
RuntimeException- if the given name is null or blank.RuntimeException- if the given setter is null.
-
withNameAndSetterAndValueMapperAndSpecificationMapper
public static <T> OptionalValue<T> withNameAndSetterAndValueMapperAndSpecificationMapper(String name, Consumer<T> setter, Function<INode<?>, T> valueMapper, Function<T, INode<?>> specificationMapper) - Type Parameters:
T- is the type of the value of aOptionalValue.- Parameters:
name-setter-valueMapper-specificationMapper-- Returns:
- a new
OptionalValuewith the given name, setter, valueMapper and specificationMapper. - Throws:
RuntimeException- if the given name is null or blank.RuntimeException- if the given valueMapper is null.RuntimeException- if the given specificationMapper is null.
-
clear
-
fillUpAttributesIntoList
Fills up the attributes of the currentIPropertyinto the given list.- Specified by:
fillUpAttributesIntoListin interfaceIProperty- Parameters:
list-
-
getStoredValue
- Specified by:
getStoredValuein interfaceIOptionalValue<V>- Returns:
- the value of the current
IOptionalValue.
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceEmptinessRequestable- Returns:
- true if
EmptinessRequestabledoes not contain an element, false otherwise.
-
setValue
Sets the given value to the currentIOptionalValue.- Specified by:
setValuein interfaceIOptionalValue<V>- Parameters:
value-
-