Class OptionalValueProperty<V>
java.lang.Object
ch.nolix.system.element.valueproperty.AbstractValueProperty<V>
ch.nolix.system.element.valueproperty.OptionalValueProperty<V>
- Type Parameters:
V- the type of the value of aOptionalValueProperty.
- All Implemented Interfaces:
NameHolder, Clearable, EmptinessRequestable, MaterializationRequestable, Property, BaseValueProperty, IOptionalValueProperty<V>
public final class OptionalValueProperty<V>
extends AbstractValueProperty<V>
implements IOptionalValueProperty<V>
- Author:
- Silvan Wyss
-
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Removes the elements of the currentClearable.voidfillUpAttributesIntoList(ILinkedList<Node<?>> list) Fills up the attributes of the currentPropertyinto the given list.static OptionalValueProperty<Boolean> forBooleanWithNameAndSetter(String name, Consumer<Boolean> setter) static OptionalValueProperty<Double> forDoubleWithNameAndSetter(String name, Consumer<Double> setter) static <E extends Element>
OptionalValueProperty<E> forElementWithNameAndSetterAndValueMapper(String name, Consumer<E> setter, Function<Node<?>, E> valueMapper) static <E extends Enum<E>>
OptionalValueProperty<E> forEnumWithNameAndSetter(Class<E> enumClass, String name, Consumer<E> setter) static OptionalValueProperty<Integer> forIntWithNameAndSetter(String name, Consumer<Integer> setter) static OptionalValueProperty<String> forStringWithNameAndSetter(String name, Consumer<String> setter) booleanisEmpty()voidSets the given value to the currentIOptionalValueProperty.static <T> OptionalValueProperty<T> withNameAndSetterAndValueMapperAndSpecificationMapper(String name, Consumer<T> setter, Function<Node<?>, T> valueMapper, Function<T, Node<?>> specificationMapper) Methods inherited from class AbstractValueProperty
addedOrChangedAttribute, getName, isMaterializedMethods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface EmptinessRequestable
containsAnyMethods inherited from interface MaterializationRequestable
isMaterialized, isViewMethods inherited from interface NameHolder
getName, getNameInSingleQuotes, hasName, hasSameNameAsMethods inherited from interface Property
addedOrChangedAttribute
-
Method Details
-
forBooleanWithNameAndSetter
public static OptionalValueProperty<Boolean> forBooleanWithNameAndSetter(String name, Consumer<Boolean> setter) - Parameters:
name-setter-- Returns:
- a new
OptionalValuePropertywith the given name and setter and that can store aBoolean - Throws:
RuntimeException- if the given name is null or blankRuntimeException- if the given setter is null
-
forDoubleWithNameAndSetter
public static OptionalValueProperty<Double> forDoubleWithNameAndSetter(String name, Consumer<Double> setter) - Parameters:
name-setter-- Returns:
- a new
OptionalValuePropertywith the given name and setter and that can store aDouble - Throws:
RuntimeException- if the given name is null or blankRuntimeException- if the given setter is null
-
forElementWithNameAndSetterAndValueMapper
public static <E extends Element> OptionalValueProperty<E> forElementWithNameAndSetterAndValueMapper(String name, Consumer<E> setter, Function<Node<?>, E> valueMapper) - Type Parameters:
E- the type of the value of aOptionalValueProperty- Parameters:
name-setter-valueMapper-- Returns:
- a new
OptionalValuePropertywith the given name, setter and valueMapperand and that can store aElement - Throws:
RuntimeException- if the given name is null or blankRuntimeException- if the given setter is nullRuntimeException- if the given valueMapper is null
-
forEnumWithNameAndSetter
public static <E extends Enum<E>> OptionalValueProperty<E> forEnumWithNameAndSetter(Class<E> enumClass, String name, Consumer<E> setter) - Type Parameters:
E- the type of theEnumthe createdOptionalValuePropertycan store- Parameters:
enumClass-name-setter-- Returns:
- a new
OptionalValuePropertywith the given name and setter and that can store anEnumof the given enumClass - Throws:
RuntimeException- if the given enumClass is nullRuntimeException- if the given name is null or blankRuntimeException- if the given setter is null
-
forIntWithNameAndSetter
public static OptionalValueProperty<Integer> forIntWithNameAndSetter(String name, Consumer<Integer> setter) - Parameters:
name-setter-- Returns:
- a new
OptionalValuePropertywith the given name and setter and that can store aInteger - Throws:
RuntimeException- if the given name is null or blankRuntimeException- if the given setter is null
-
forStringWithNameAndSetter
public static OptionalValueProperty<String> forStringWithNameAndSetter(String name, Consumer<String> setter) - Parameters:
name-setter-- Returns:
- a new
OptionalValuePropertywith the given name and setter and that can store aString - Throws:
RuntimeException- if the given name is null or blankRuntimeException- if the given setter is null
-
withNameAndSetterAndValueMapperAndSpecificationMapper
public static <T> OptionalValueProperty<T> withNameAndSetterAndValueMapperAndSpecificationMapper(String name, Consumer<T> setter, Function<Node<?>, T> valueMapper, Function<T, Node<?>> specificationMapper) - Type Parameters:
T- the type of the value of aOptionalValueProperty- Parameters:
name-setter-valueMapper-specificationMapper-- Returns:
- a new
OptionalValuePropertywith the given name, setter, valueMapper and specificationMapper - Throws:
RuntimeException- if the given name is null or blankRuntimeException- if the given valueMapper is nullRuntimeException- if the given specificationMapper is null
-
clear
-
fillUpAttributesIntoList
Fills up the attributes of the currentPropertyinto the given list.- Specified by:
fillUpAttributesIntoListin interfaceProperty- Parameters:
list-
-
getStoredValue
- Specified by:
getStoredValuein interfaceIOptionalValueProperty<V>- Returns:
- the value of the current
IOptionalValueProperty
-
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 currentIOptionalValueProperty.- Specified by:
setValuein interfaceIOptionalValueProperty<V>- Parameters:
value-
-