Package sprouts.impl
Class Sprouts
java.lang.Object
sprouts.impl.Sprouts
- All Implemented Interfaces:
SproutsFactory
Exposes an API for configuring the
So technically speaking, this is a configurable singleton, so be careful when using it as it effectively maintains global + mutable state!
SproutsFactory
,
which serves implementations of the various property types in the Sprouts library,
like Event
, Val
, Var
, Vals
and Vars
.
The methods implemented here are used by the various factory methods of the sprouts API like
Var.of(Object)
, Vals.of(Object, Object[])
...So technically speaking, this is a configurable singleton, so be careful when using it as it effectively maintains global + mutable state!
-
Method Summary
Modifier and TypeMethodDescription<K,
V> Association <K, V> associationOf
(Class<K> keyType, Class<V> valueType) Creates a new association between keys and values with the given key and value types.<K,
V> Association <K, V> associationOfLinked
(Class<K> keyType, Class<V> valueType) Creates a new linked association between keys and values with the given key and value types, where the order of key-value pairs in this type of association is based on the order in which the pairs are added to the association.<K extends Comparable<K>,
V>
Association<K, V> associationOfSorted
(Class<K> keyType, Class<V> valueType) Creates a new association between keys and values with the given key and value types, where the keys are sorted in natural order.<K,
V> Association <K, V> associationOfSorted
(Class<K> keyType, Class<V> valueType, Comparator<K> comparator) Creates a new association between keys and values with the given key and value types, where the key-value pairs are sorted using the supplied comparator.The default channel used for change events.The default id for properties which do not have an id explicitly specified.The default channel used forObservable
events, registered through theObservable.subscribe(Observer)
method.<T> ValDelegate
<T> delegateOf
(Val<T> source, Channel channel, SingleChange change, @Nullable T newValue, @Nullable T oldValue) <T> ValsDelegate
<T> delegateOf
(Vals<T> source, SequenceChange changeType, int index, Vals<T> newValues, Vals<T> oldValues) Creates a delegate for when aVals
/Vars
property list to be specifically designed as a context object passed toAction
s registered onViewable
s, like for example through theViewable.onChange(Channel, Action)
method.event()
A factory method to create a newEvent
instance.eventOf
(Event.Executor executor) A factory method to create a newEvent
instance with the given executor.static SproutsFactory
factory()
ASproutsFactory
is used by the various factory methods of this API likeVar.of(Object)
,Vals.of(Object, Object[])
...The regexPattern
used to validate property ids.<T,
B> Var <B> A factory method for creating aLens
basedVar
property, which is a zoomed in handle to a field variable of a non-nullClass
of a non-nullable typeB
that is a member part of the source property item typeT
.
The resultingVar
can be mutated, and the changes will be propagated to the source property value through the lens.
If the item in the source property valueT
isnull
, then the resultingVar
will use the providednullObject
as a default value.<T,
B> Var <B> A factory method for creating aLens
basedVar
property, which is a zoomed in handle to a field variable of a non-nullClass
of a non-nullable typeB
that is a member part of the source property item typeT
.
The resultingVar
can be mutated, and the changes will be propagated to the source property value through the lens.
BothT
andB
are expected to be data types with value semantics, meaning they should be immutable and have properequals
andhashCode
implementations.<T,
B> Var <B> lensOfNullable
(Class<B> type, Var<T> source, Lens<T, B> lens) A factory method for creating aLens
basedVar
property, which is a zoomed in handle to a field variable of a non-nullClass
of a nullable typeB
that is a member part of the source property item typeT
.
If you want to create a lens property which can never storenull
values, use theSproutsFactory.lensOf(Var, Object, Lens)
factory method instead.
The resultingVar
can be mutated, and the changes will be propagated to the source property value through the lens.static void
setFactory
(SproutsFactory factory) Sets the factory to be used by the various factory methods of this API likeVar.of(Object)
,Vals.of(Object, Object[])
...tupleOf
(byte... bytes) Creates an immutable tuple of non-nullable items from a primitive array of bytes.tupleOf
(double... doubles) Creates an immutable, non-nullableTuple<Double>
from a primitive array of doubles.tupleOf
(float... floats) Creates an immutable, non-nullableTuple<Float>
from a primitive array of floats.tupleOf
(int... ints) Creates an immutable tuple of non-nullable items from a primitive array of integers.tupleOf
(long... longs) Creates an immutable tuple of non-nullable items from a primitive array of longs.<T> Tuple
<T> Creates an empty tuple of non-nullable items from the supplied type.<T> Tuple
<T> Creates an immutable tuple of non-nullable items from the supplied type and iterable of values.<T> Tuple
<T> Creates an immutable tuple of non-nullable items from the supplied type and vararg values.<T> Tuple
<T> Creates an immutable tuple of non-nullable items from the supplied type and values.<T> Tuple
<T> tupleOf
(T first, T... rest) Creates an immutable tuple of non-nullable items from one or more non-null items.<T> Tuple
<@Nullable T> tupleOfNullable
(Class<T> type) Creates an empty tuple of nullable items from the supplied type.<T> Tuple
<@Nullable T> tupleOfNullable
(Class<T> type, @Nullable T... values) Creates an immutable tuple of nullable items from the supplied type and values.<T> Tuple
<@Nullable T> tupleOfNullable
(Class<T> type, Iterable<@Nullable T> iterable) Creates an immutable tuple of nullable items from the supplied type and iterable of values.<T> Val
<T> <T> Val
<T> valOf
(T item) Creates a non-nullVal
instance of the given non-null item.<T> Val
<@Nullable T> Creates an emptyVal
property from the given type class.<T> Val
<@Nullable T> valOfNullable
(Class<T> type, @Nullable T item) Creates a newVal
property from a type class and an item which may or may not be null.<T> Val
<@Nullable T> valOfNullable
(Val<@Nullable T> toBeCopied) <T> Vals
<T> A factory method which creates an emptyVals
instance dedicated to hold properties storing non-nullable items of the specified type.<T> Vals
<T> <T> Vals
<T> <T> Vals
<T> <T> Vals
<T> A factory method for creating aVals
property list from a type class and an array of items, which are all instances of the given type and may not benull
.<T> Vals
<T> <T> Vals
<T> valsOf
(T first, T... rest) A factory method for creating aVals
property list from one or more items, which are all instances of the same type and may not benull
.<T> Vals
<@Nullable T> valsOfNullable
(Class<T> type) This factory method instantiates an emptyVals
instance from a type class of a nullable typeT
.<T> Vals
<@Nullable T> valsOfNullable
(Class<T> type, @Nullable T... items) <T> Vals
<@Nullable T> valsOfNullable
(Class<T> type, Val<@Nullable T>... vals) <T> Vals
<@Nullable T> valsOfNullable
(Class<T> type, Vals<@Nullable T> vals) <T> Vals
<@Nullable T> valsOfNullable
(Val<@Nullable T> first, Val<@Nullable T>... rest) <E> ValueSet
<E> valueSetOf
(Class<E> type) Creates a new value set specifically for holding elements of the supplied type.<E> ValueSet
<E> valueSetOfLinked
(Class<E> type) Creates a new value set specifically for holding elements of the supplied type, and where the order of the elements is defined by the insertion order.<E extends Comparable<? super E>>
ValueSet<E> valueSetOfSorted
(Class<E> type) Creates a new value set specifically for holding elements of the supplied type, elements are sorted based on the natural ordering of the elements (which are expected to implementComparable
).<E> ValueSet
<E> valueSetOfSorted
(Class<E> type, Comparator<E> comparator) Creates a new value set specifically for holding elements of the supplied type, but with an explicit order defined by the supplied comparator.<T,
V extends T>
Var<T> Creates aVar
property instance of the given non-nullable type with the specified non-null item.<T> Var
<T> varOf
(T item) Creates aVar
property instance from a given non-nullable item, where theMaybe.type()
is inferred from the type of the item.<T> Var
<T> Creates an emptyVar
instance (storing anull
item) of the given type.<T> Var
<T> varOfNullable
(Class<T> type, @Nullable T item) <T> Vars
<T> Creates an empty list of non-nullable properties from the supplied type.<T> Vars
<T> Creates a list of non-nullable properties from the supplied type and iterable of values.<T> Vars
<T> Creates a list of non-nullable properties from the supplied type and vararg values.<T> Vars
<T> Creates a list of non-nullable properties from the supplied type and values.<T> Vars
<T> Creates a list of non-nullable properties from one or more non-nullable properties.<T> Vars
<T> varsOf
(T first, T... rest) Creates a list of non-nullable properties from one or more non-null values.<T> Vars
<@Nullable T> varsOfNullable
(Class<T> type) Creates an empty list of nullable properties from the supplied type.<T> Vars
<@Nullable T> varsOfNullable
(Class<T> type, @Nullable T... values) Creates a list of nullable properties from the supplied type and values.<T> Vars
<T> varsOfNullable
(Class<T> type, Iterable<Var<T>> vars) Creates a list of nullable properties from the supplied type and iterable of values.<T> Vars
<@Nullable T> varsOfNullable
(Class<T> type, Var<@Nullable T>... vars) Creates a list of nullable properties from the supplied type and varargs properties.<T> Vars
<@Nullable T> varsOfNullable
(Var<@Nullable T> first, Var<@Nullable T>... rest) Creates a list of nullable properties from the supplied properties.viewOf
(Class<R> type, Val<T> first, Val<U> second, BiFunction<T, U, R> combiner) <T,
U> Viewable <T> <T> Viewable
<T> viewOf
(Val<T> first, Val<U> second, BiFunction<T, U, @NonNull T> combiner) <T> Viewables
<T> <T,
U> Viewable <U> Creates aViewable
instance where he item of a supplied sourceVal
is mapped to a different (non-null) type using the provided mapper function as well as an error and null object in case the source value isnull
or an error occurs during mapping.
You can registerAction
s orObserver
s on the returnedViewable
to receive updates when the value of the source property changes.<T,
U> Viewables <U> viewOfNullable
(Class<R> type, Val<T> first, Val<U> second, BiFunction<T, U, @Nullable R> combiner) <T,
U> Viewable <@Nullable U> viewOfNullable
(Class<U> type, Val<T> source, Function<T, @Nullable U> mapper) Creates aViewable
instance of the given nullable type which is a view of the value of the specified sourceVal
mapped to a different (nullable) type using the provided mapper function.
You can register observers on the returnedViewable
to receive updates when the value of the source property changes.viewOfNullable
(Val<T> first, Val<U> second, BiFunction<T, U, @Nullable T> combiner) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface sprouts.impl.SproutsFactory
maybeOf, maybeOf, maybeOfNull, maybeOfNullable, maybeOfNullable, tupleOf, tupleOfNullable, tupleOfNullable
-
Method Details
-
factory
ASproutsFactory
is used by the various factory methods of this API likeVar.of(Object)
,Vals.of(Object, Object[])
... to create instances of these properties.
You can plug in your own factory implementation through thesetFactory(SproutsFactory)
method, where you can then serve your own implementations of the various property types in the Sprouts library.- Returns:
- The default factory for creating instances of the various property types in the Sprouts library.
-
setFactory
Sets the factory to be used by the various factory methods of this API likeVar.of(Object)
,Vals.of(Object, Object[])
... to create instances of these properties.
You can use a customSproutsFactory
to instantiate and serve your own implementations of the various property types in the Sprouts library.
WARNING: This is a global + mutable state, so be careful when using it
as it will have global side effects on the various factory methods of this API.- Parameters:
factory
- The factory to be used by the various factory methods of this API.- Throws:
NullPointerException
- if the factory is null.
-
delegateOf
public <T> ValDelegate<T> delegateOf(Val<T> source, Channel channel, SingleChange change, @Nullable T newValue, @Nullable T oldValue) Description copied from interface:SproutsFactory
Creates a delegate for when aVal
/Var
property changes its value or is explicitly triggered to propagate the event to all derivedViewable
instances and theirAction
s.- Specified by:
delegateOf
in interfaceSproutsFactory
- Type Parameters:
T
- The item type of the property for which the delegate is created.- Parameters:
source
- The source property for which the delegate is created.channel
- The channel on which the change event was triggered (seeVal.fireChange(Channel)
).change
- The type of change that occurred in the property, which may also beSingleChange.NONE
if the change was triggered explicitly without any actual change in the value.newValue
- The new value of the property after the change.oldValue
- The old value of the property before the change.- Returns:
- A delegate for the given
Val
property.
-
delegateOf
public <T> ValsDelegate<T> delegateOf(Vals<T> source, SequenceChange changeType, int index, Vals<T> newValues, Vals<T> oldValues) Description copied from interface:SproutsFactory
Creates a delegate for when aVals
/Vars
property list to be specifically designed as a context object passed toAction
s registered onViewable
s, like for example through theViewable.onChange(Channel, Action)
method.- Specified by:
delegateOf
in interfaceSproutsFactory
- Type Parameters:
T
- The type of the property for which the delegate is created.- Parameters:
source
- The source property for which the delegate is created.changeType
- The type of change that occurred in the property.index
- The (start) index at which the change occurred.newValues
- The new values of the property after the change.oldValues
- The old values of the property before the change.- Returns:
- A delegate for the given
Vals
property.
-
event
Description copied from interface:SproutsFactory
A factory method to create a newEvent
instance. AnEvent
can be triggered using theEvent.fire()
method, and it will notify allAction
s registered onObserver
s derived from theEvent
instance through theEvent.observable()
method.- Specified by:
event
in interfaceSproutsFactory
- Returns:
- A new
Event
instance with the default executor.
-
eventOf
Description copied from interface:SproutsFactory
A factory method to create a newEvent
instance with the given executor. AnEvent
can be triggered using theEvent.fire()
method, and it will notify allAction
s registered onObserver
s derived from theEvent
instance through theEvent.observable()
method.- Specified by:
eventOf
in interfaceSproutsFactory
- Parameters:
executor
- The executor to be used for the event. It must not benull
.- Returns:
- A new
Event
instance with the specified executor.
-
valOfNullable
Description copied from interface:SproutsFactory
Creates a newVal
property from a type class and an item which may or may not be null. The resulting property may or may not be empty (seeMaybe.isEmpty()
.- Specified by:
valOfNullable
in interfaceSproutsFactory
- Type Parameters:
T
- The type of the item to be wrapped in theVal
property.- Parameters:
type
- The type of the item to be wrapped in theVal
, which must not be null.item
- The item to be wrapped in theVal
. It can benull
.- Returns:
- A
Val
instance containing the item, or an emptyVal
if the item isnull
.
-
valOfNull
Description copied from interface:SproutsFactory
Creates an emptyVal
property from the given type class. TheMaybe.isEmpty()
method of the returned instance will always returntrue
, indicating that theVal
does not contain a value.- Specified by:
valOfNull
in interfaceSproutsFactory
- Type Parameters:
T
- The type of the item to be wrapped in theVal
.- Parameters:
type
- The type of the item to be wrapped in theVal
. It must not benull
.- Returns:
- An immutable and empty
Val
instance containing anull
item.
-
valOf
Description copied from interface:SproutsFactory
Creates a non-nullVal
instance of the given non-null item. TheMaybe.isPresent()
method of the returned instance will always returntrue
, indicating that theVal
does contain a value.- Specified by:
valOf
in interfaceSproutsFactory
- Type Parameters:
T
- The type of the item to be wrapped in theVal
.- Parameters:
item
- The item to be wrapped in theVal
. It must not benull
.- Returns:
- An immutable and non-empty
Val
instance containing the item.
-
valOf
Description copied from interface:SproutsFactory
Creates a non-emptyVal
copy from the suppliedVal
. The suppliedVal
must not contain a null item. So if the factory call was successful, then theMaybe.isPresent()
method of the returned instance will always returntrue
, indicating that theVal
contains a value. The returned instance is effectively an immutable copy of the suppliedVal
. -
valOfNullable
Description copied from interface:SproutsFactory
- Specified by:
valOfNullable
in interfaceSproutsFactory
- Type Parameters:
T
- The type of the item to be wrapped in theVal
.- Parameters:
toBeCopied
- TheVal
instance to be copied. It must not benull
, however, the value in theVal
can benull
.- Returns:
- A new
Val
instance containing the value from the givenVal
, or an emptyVal
if the value isnull
.
-
viewOf
Description copied from interface:SproutsFactory
-
viewOf
public <T extends @Nullable Object,U extends @Nullable Object> Viewable<@NonNull T> viewOf(Val<T> first, Val<U> second, BiFunction<T, U, @NonNull T> combiner) Description copied from interface:SproutsFactory
Creates a non-nullViewable
instance which is a composite of twoVal
instances whose values are combined using the specified combiner function. You may register observers on the resulting viewable to receive updates when the values of either of the twoVal
instances change.- Specified by:
viewOf
in interfaceSproutsFactory
- Type Parameters:
T
- The type of the firstVal
value.U
- The type of the secondVal
value.- Parameters:
first
- The firstVal
to be combined into aViewable
composite.second
- The secondVal
to be combined into aViewable
composite.combiner
- The function that combines the values of the twoVal
instances into a single value.- Returns:
- A
Viewable
instance that combines the values of the twoVal
instances using the specified combiner function.
-
viewOfNullable
public <T extends @Nullable Object,U extends @Nullable Object> Viewable<@Nullable T> viewOfNullable(Val<T> first, Val<U> second, BiFunction<T, U, @Nullable T> combiner) Description copied from interface:SproutsFactory
Creates a nullableViewable
instance which is a composite of twoVal
instances whose values are combined using the specified combiner function. You may register observers on the resulting viewable to receive updates when the values of either of the twoVal
instances change.- Specified by:
viewOfNullable
in interfaceSproutsFactory
- Type Parameters:
T
- The type of the firstVal
value.U
- The type of the secondVal
value.- Parameters:
first
- The firstVal
to be combined into aViewable
composite.second
- The secondVal
to be combined into aViewable
composite.combiner
- The function that combines the values of the twoVal
instances into a single value.- Returns:
- A
Viewable
instance that combines the values of the twoVal
instances using the specified combiner function.
-
viewOf
public <T extends @Nullable Object,U extends @Nullable Object, Viewable<R> viewOfR> (Class<R> type, Val<T> first, Val<U> second, BiFunction<T, U, R> combiner) Description copied from interface:SproutsFactory
Creates a non-nullableViewable
instance of the given type which is a composite of twoVal
instances whose values are combined using the specified combiner function. You may register observers on the resulting viewable to receive updates when the values of either of the twoVal
instances change.- Specified by:
viewOf
in interfaceSproutsFactory
- Type Parameters:
T
- The type of the firstVal
value.U
- The type of the secondVal
value.R
- The type of the resultingViewable
.- Parameters:
type
- The type of the resultingViewable
.first
- The firstVal
to be combined into aViewable
composite.second
- The secondVal
to be combined into aViewable
composite.combiner
- The function that combines the values of the twoVal
instances into a single value.- Returns:
- A
Viewable
instance that combines the values of the twoVal
instances using the specified combiner function.
-
viewOfNullable
public <T extends @Nullable Object,U extends @Nullable Object, Viewable<@Nullable R> viewOfNullableR> (Class<R> type, Val<T> first, Val<U> second, BiFunction<T, U, @Nullable R> combiner) Description copied from interface:SproutsFactory
Creates a nullableViewable
instance of the given type which is a composite of twoVal
instances whose values are combined using the specified combiner function. You may register observers on the resulting viewable to receive updates when the values of either of the twoVal
instances change.- Specified by:
viewOfNullable
in interfaceSproutsFactory
- Type Parameters:
T
- The type of the firstVal
value.U
- The type of the secondVal
value.R
- The type of the resultingViewable
.- Parameters:
type
- The type of the resultingViewable
.first
- The firstVal
to be combined into aViewable
composite.second
- The secondVal
to be combined into aViewable
composite.combiner
- The function that combines the values of the twoVal
instances into a single value.- Returns:
- A
Viewable
instance that combines the values of the twoVal
instances using the specified combiner function.
-
viewOf
Description copied from interface:SproutsFactory
-
viewOf
Description copied from interface:SproutsFactory
Creates a mappedViewable
instance of the given type which is a view of the value of the specified sourceVal
mapped to a different type using the provided mapper function.
You can register observers on the returnedViewable
to receive updates when the value of the source property changes.- Specified by:
viewOf
in interfaceSproutsFactory
- Type Parameters:
T
- The type parameter to which the source value will be mapped in the resultingViewable
.U
- The type of the value in the sourceVal
.- Parameters:
type
- The type class to which the source value will be mapped into the resultingViewable
.source
- The sourceVal
for which the view is created.mapper
- The function that maps the source value to the resulting value in theViewable
.- Returns:
- A
Viewable
instance which is a view of the specified sourceVal
mapped to the given type.
-
viewOf
public <T,U> Viewables<U> viewOf(U nullObject, U errorObject, Vals<T> source, Function<T, @Nullable U> mapper) Description copied from interface:SproutsFactory
Creates a mappedViewables
instance of the givenVals
with specified null and error objects. This is useful when you want to provide default values for theViewables
when the source property contains anull
value or an error occurs during mapping.- Specified by:
viewOf
in interfaceSproutsFactory
- Type Parameters:
T
- The type of the items in theVals
.U
- The type of the items in the resultingViewables
.- Parameters:
nullObject
- The default value to be used when the source value is null.errorObject
- The default value to be used when an error occurs during mapping.source
- The sourceVals
for which the view is created.mapper
- The function that maps the source value to the resulting value.- Returns:
- A
Viewables
instance that wraps the givenVals
with specified null and error objects.
-
viewOf
public <T,U> Viewable<U> viewOf(U nullObject, U errorObject, Val<T> source, Function<T, @Nullable U> mapper) Description copied from interface:SproutsFactory
Creates aViewable
instance where he item of a supplied sourceVal
is mapped to a different (non-null) type using the provided mapper function as well as an error and null object in case the source value isnull
or an error occurs during mapping.
You can registerAction
s orObserver
s on the returnedViewable
to receive updates when the value of the source property changes. This method is useful when you want a mappedViewable
with a default/fallback values in case the source property contains anull
value or an error occurs during mapping.- Specified by:
viewOf
in interfaceSproutsFactory
- Type Parameters:
T
- The type of the item in the sourceVal
to be mapped. It can be nullable.U
- The type of the item to map to in the resultingViewable
. It may never benull
in the resultingViewable
.- Parameters:
nullObject
- The default value to be used when the source value is null.errorObject
- The default value to be used when an error occurs during mapping.source
- The sourceVal
for which the view is created.mapper
- The function that maps the source value to the resulting value in theViewable
returned by this method.- Returns:
- A
Viewable
instance that dynamically maps the source value or alternatively uses the specified null and error objects.
-
viewOfNullable
public <T,U> Viewable<@Nullable U> viewOfNullable(Class<U> type, Val<T> source, Function<T, @Nullable U> mapper) Description copied from interface:SproutsFactory
Creates aViewable
instance of the given nullable type which is a view of the value of the specified sourceVal
mapped to a different (nullable) type using the provided mapper function.
You can register observers on the returnedViewable
to receive updates when the value of the source property changes.- Specified by:
viewOfNullable
in interfaceSproutsFactory
- Type Parameters:
T
- The type parameter to which the source value will be mapped in the resultingViewable
. It can be nullable.U
- The type of the value in the sourceVal
. It can also be nullable.- Parameters:
type
- The type class to which the source value will be mapped into the resultingViewable
. This argument may not benull
(Although the resultingViewable
can containnull
values).source
- The sourceVal
for which the view is created.mapper
- The function that maps the source value to the resulting value in theViewable
.- Returns:
- A
Viewable
instance which is a view of the specified sourceVal
mapped to the given (nullable) type.
-
lensOf
Description copied from interface:SproutsFactory
A factory method for creating aLens
basedVar
property, which is a zoomed in handle to a field variable of a non-nullClass
of a non-nullable typeB
that is a member part of the source property item typeT
.
The resultingVar
can be mutated, and the changes will be propagated to the source property value through the lens.
BothT
andB
are expected to be data types with value semantics, meaning they should be immutable and have properequals
andhashCode
implementations. We recommend using record types forT
andB
to reliably ensure value semantics.- Specified by:
lensOf
in interfaceSproutsFactory
- Type Parameters:
T
- The type of the source property value, which is expected to be non-nullable.B
- The type of the field in the source property valueT
, which can be nullable.- Parameters:
source
- The sourceVar
from which the lens is created.lens
- The lens that defines how to access the field of typeB
in the source property valueT
.- Returns:
- A
Var
instance that represents the field of typeB
in the source property valueT
.
-
lensOf
Description copied from interface:SproutsFactory
A factory method for creating aLens
basedVar
property, which is a zoomed in handle to a field variable of a non-nullClass
of a non-nullable typeB
that is a member part of the source property item typeT
.
The resultingVar
can be mutated, and the changes will be propagated to the source property value through the lens.
If the item in the source property valueT
isnull
, then the resultingVar
will use the providednullObject
as a default value. If you want to create a lens property which can storenull
values, use theSproutsFactory.lensOfNullable(Class, Var, Lens)
method instead.
BothT
andB
are expected to be data types with value semantics, meaning they should be immutable and have properequals
andhashCode
implementations. We recommend using record types forT
andB
to reliably ensure value semantics.- Specified by:
lensOf
in interfaceSproutsFactory
- Type Parameters:
T
- The type of the source property value, which is expected to be non-nullable.B
- The type of the field in the source property valueT
, which can be nullable.- Parameters:
source
- The sourceVar
from which the lens is created.nullObject
- The default value to be used when the source value is null.lens
- The lens that defines how to access the field of typeB
in the source property valueT
. This lens property may never storenull
values.- Returns:
- A
Var
instance that represents the field of typeB
in the source property valueT
.
-
lensOfNullable
Description copied from interface:SproutsFactory
A factory method for creating aLens
basedVar
property, which is a zoomed in handle to a field variable of a non-nullClass
of a nullable typeB
that is a member part of the source property item typeT
.
If you want to create a lens property which can never storenull
values, use theSproutsFactory.lensOf(Var, Object, Lens)
factory method instead.
The resultingVar
can be mutated, and the changes will be propagated to the source property value through the lens.
Both
T
andB
are expected to be data types with value semantics, so they should be immutable and have properequals
andhashCode
implementations. We recommend using record types forT
andB
to reliably ensure value semantics.- Specified by:
lensOfNullable
in interfaceSproutsFactory
- Type Parameters:
T
- The type of the source property value, which is expected to be non-nullable.B
- The type of the field in the source property valueT
, which can be nullable.- Parameters:
type
- The type of the resultingVar
.source
- The sourceVar
from which the lens is created.lens
- The lens that defines how to access the field of typeB
in the source property valueT
.- Returns:
- A
Var
instance that represents the field of typeB
in the source property valueT
.
-
varOfNullable
Description copied from interface:SproutsFactory
Creates aVar
property instance from a given non-nullClass
of a nullable type and as well as an item of that type, which therefore may benull
. The resulting property is nullable, meaning it can hold a value of the given type or benull
. If you want to create a property which can never holdnull
values, useSproutsFactory.varOf(Class, Object)
instead of this method.- Specified by:
varOfNullable
in interfaceSproutsFactory
- Type Parameters:
T
- The type of the item to be wrapped in theVar
.- Parameters:
type
- The type of the item to be wrapped in theVar
, which must not benull
.item
- The item to be wrapped in theVar
. It can benull
.- Returns:
- A
Var
instance containing the item, or an emptyVar
if the item isnull
.
-
varOfNull
Description copied from interface:SproutsFactory
Creates an emptyVar
instance (storing anull
item) of the given type. If you want to create a property which can never holdnull
values, useSproutsFactory.varOf(Class, Object)
instead of this method.- Specified by:
varOfNull
in interfaceSproutsFactory
- Type Parameters:
T
- The type of the item to be wrapped in theVar
.- Parameters:
type
- The type of the item to be wrapped in theVar
, which must not benull
.- Returns:
- A
Var
instance containing anull
item.
-
varOf
Description copied from interface:SproutsFactory
Creates aVar
property instance from a given non-nullable item, where theMaybe.type()
is inferred from the type of the item.- Specified by:
varOf
in interfaceSproutsFactory
- Type Parameters:
T
- The type of the item to be wrapped in theVar
.- Parameters:
item
- The item to be wrapped in theVar
. It must not benull
.- Returns:
- A
Var
instance containing the item.
-
varOf
Description copied from interface:SproutsFactory
Creates aVar
property instance of the given non-nullable type with the specified non-null item. The resulting property is non-nullable, meaning it can only hold a value of the given type and cannot benull
. The supplied item must be a subtype of the specifiedtype
.- Specified by:
varOf
in interfaceSproutsFactory
- Type Parameters:
T
- The type of the item to be wrapped in theVar
.V
- The type of the item to be wrapped in theVar
, which must be a subtype ofT
.- Parameters:
type
- The type of the item to be wrapped in theVar
.item
- The item to be wrapped in theVar
. It must not benull
and it must be a subtype of the specifiedtype
.- Returns:
- A non-nullable
Var
instance containing the item.
-
valsOf
Description copied from interface:SproutsFactory
A factory method which creates an emptyVals
instance dedicated to hold properties storing non-nullable items of the specified type.- Specified by:
valsOf
in interfaceSproutsFactory
- Type Parameters:
T
- The type of the items to be wrapped in theVals
.- Parameters:
type
- The type of the items to be wrapped in theVals
. It must not benull
.- Returns:
- A
Vals
instance that can hold items of the specified type.
-
valsOf
Description copied from interface:SproutsFactory
This factory method creates aVals
instance from a type class and an array ofVal
properties, each wrapping a non-nullable item of the specified type. A property list can store multipleVal
properties wrapping non-nullable items of the specified type.- Specified by:
valsOf
in interfaceSproutsFactory
- Type Parameters:
T
- The non-nullable type of the items to be wrapped in theVals
.- Parameters:
type
- The type of the items to be wrapped in theVals
. It must not benull
.vars
- An array ofVal
properties to be wrapped in theVals
. Properties in the array cannot benull
, and their items also cannot benull
.- Returns:
- A
Vals
instance that can hold the specified items of the given type.
-
valsOf
Description copied from interface:SproutsFactory
A factory method for creating aVals
property list from one or moreVal
properties, which are all instances of the same type and may not benull
. TheVals.type()
is inferred from the type of the first propertiesMaybe.type()
. If you want to create a property list which can holdnull
s, useSproutsFactory.valsOfNullable(Class, Val...)
instead of this method.- Specified by:
valsOf
in interfaceSproutsFactory
- Type Parameters:
T
- The type of the items to be wrapped in theVals
.- Parameters:
first
- The firstVal
to be wrapped in theVals
. It must not benull
and it must not contain anull
item (Val.allowsNull()
must returnfalse
).rest
- AdditionalVal
items to be wrapped in theVals
. They are not permitted to benull
, and they also may not containnull
items (Val.allowsNull()
must returnfalse
).- Returns:
- A
Vals
instance that can hold the specified items of the inferred type.
-
valsOf
Description copied from interface:SproutsFactory
A factory method for creating aVals
property list from one or more items, which are all instances of the same type and may not benull
. TheVals.type()
is inferred from the type of the first item. If you want to create a property list which can holdnull
s, useSproutsFactory.valsOfNullable(Class, Object...)
instead of this method.- Specified by:
valsOf
in interfaceSproutsFactory
- Type Parameters:
T
- The type of the items to be wrapped in theVals
.- Parameters:
first
- The first item to be wrapped in theVals
. It must not benull
.rest
- Additional items to be wrapped in theVals
. They can benull
.- Returns:
- A
Vals
instance that can hold the specified items of the inferred type.
-
valsOf
Description copied from interface:SproutsFactory
A factory method for creating aVals
property list from a type class and an array of items, which are all instances of the given type and may not benull
. The resultingVals
can hold multiple values of the specified type. If you want to create a property list which can holdnull
references, useSproutsFactory.valsOfNullable(Class, Object...)
instead of this method.- Specified by:
valsOf
in interfaceSproutsFactory
- Type Parameters:
T
- The type of the items to be wrapped in theVals
.- Parameters:
type
- The type class of the items to be wrapped in theVals
. It must not benull
.items
- An array of items to be wrapped in theVals
. The items themselves cannot benull
.- Returns:
- A
Vals
instance that can hold the specified items of the given type.
-
valsOf
Description copied from interface:SproutsFactory
Creates aVals
property list from a type class and an iterable ofVal
properties, each wrapping a non-nullable item of the specified type. A property list can store multipleVal
properties wrapping non-nullable items of the specified type.- Specified by:
valsOf
in interfaceSproutsFactory
- Type Parameters:
T
- The non-nullable type of the items to be wrapped in theVals
.- Parameters:
type
- The type of the items to be wrapped in theVals
. It must not benull
.properties
- An iterable ofVal
properties to be wrapped in theVals
. Properties in the iterable cannot benull
, and their items cannot benull
.- Returns:
- A
Vals
instance that can hold the specified items of the given type.
-
valsOf
Description copied from interface:SproutsFactory
Creates aVals
property list of the given type with the specified items from anotherVals
instance. A property list can store multipleVal
properties wrapping non-nullable items of the specified type.- Specified by:
valsOf
in interfaceSproutsFactory
- Type Parameters:
T
- The non-nullable type of the items to be wrapped in theVals
.- Parameters:
type
- The type of the items to be wrapped in theVals
. It must not benull
.vals
- The items to be wrapped in theVals
. Items in properties of theVals
are not permitted to benull
.- Returns:
- A
Vals
instance that can hold the specified items of the given (non-nullable) type.
-
valsOfNullable
Description copied from interface:SproutsFactory
Creates aVals
property list ofVal
properties from a type class and an array of properties, holding nullable items which are all instances of the given type ornull
. So everyVal
property in the resultingVals
is permitted to hold anull
reference and may therefore reportMaybe.isEmpty()
astrue
.- Specified by:
valsOfNullable
in interfaceSproutsFactory
- Type Parameters:
T
- The type of the items to be wrapped in theVals
.- Parameters:
type
- The type class of the nullable items to be wrapped in theVals
. It must not benull
.vals
- An array ofVal
s to be wrapped in theVals
. The properties themselves cannot benull
, but the items they hold can benull
.- Returns:
- A
Vals
instance that can hold the specified items of the given type, includingnull
values.
-
valsOfNullable
Description copied from interface:SproutsFactory
This factory method instantiates an emptyVals
instance from a type class of a nullable typeT
. The resultingVals
can hold multiple properties wrapping either instances of the specified typeT
ornull
references. If you want to create a property list which can never holdnull
s, useSproutsFactory.valsOf(Class)
instead of this method.- Specified by:
valsOfNullable
in interfaceSproutsFactory
- Type Parameters:
T
- The nullable type of the items to be wrapped in theVals
.- Parameters:
type
- The type class of the nullable items to be wrapped in theVals
. It must not benull
.- Returns:
- A
Vals
instance that can hold items of the specified nullable type.
-
valsOfNullable
Description copied from interface:SproutsFactory
Creates aVals
property list ofVal
properties from a type class and an array of items, which are all instances of the given type ornull
. EveryVal
property in the resultingVals
is permitted to hold anull
reference, in which case it will reportMaybe.isEmpty()
astrue
. If you want to create a property list which can never holdnull
s, useSproutsFactory.valsOf(Class, Object...)
instead of this method.- Specified by:
valsOfNullable
in interfaceSproutsFactory
- Type Parameters:
T
- The type of the items to be wrapped in theVals
.- Parameters:
type
- The type class of the nullable items to be wrapped in theVals
. It must not benull
.items
- An array of items to be wrapped in theVals
. The items themselves can benull
, but the array is not permitted to benull
itself.- Returns:
- A
Vals
instance that can hold the specified items of the given type, includingnull
values.
-
valsOfNullable
Description copied from interface:SproutsFactory
Creates aVals
property list ofVal
properties from one or moreVal
properties, which are all instances of the same type and may holdnull
values. TheVals.type()
is inferred from the type of the first propertiesMaybe.type()
. If you want to create a property list which can never holdnull
s, useSproutsFactory.valsOf(Class, Val...)
instead of this method.- Specified by:
valsOfNullable
in interfaceSproutsFactory
- Type Parameters:
T
- The type of the items to be wrapped in theVals
.- Parameters:
first
- The firstVal
to be wrapped in theVals
. It must not benull
and it may contain anull
item (Val.allowsNull()
may returntrue
).rest
- AdditionalVal
items to be wrapped in theVals
. They are not permitted to benull
, but they may containnull
items (Val.allowsNull()
may returntrue
).- Returns:
- A
Vals
instance that can hold the specified items of the inferred type, including nullable values.
-
valsOfNullable
Description copied from interface:SproutsFactory
This factory method creates aVals
property list from a type class representing a nullable typeT
and anotherVals
instance, which contains nullable items being compatible with the specified typeT
. A property list can store multipleVal
properties wrapping nullable items of the specified type.- Specified by:
valsOfNullable
in interfaceSproutsFactory
- Type Parameters:
T
- The nullable type of the items to be wrapped in theVals
.- Parameters:
type
- The type of the items to be wrapped in theVals
. It must not benull
.vals
- The items to be wrapped in theVals
. Items in properties of theVals
are permitted to benull
.- Returns:
- A
Vals
instance that can hold the specified items of the given (nullable) type.
-
varsOfNullable
Description copied from interface:SproutsFactory
Creates a list of nullable properties from the supplied type and iterable of values. This factory method requires that the type be specified because the compiler cannot infer the type from a potentially empty iterable.- Specified by:
varsOfNullable
in interfaceSproutsFactory
- Type Parameters:
T
- the type of the properties.- Parameters:
type
- the type of the properties.vars
- the iterable of values.- Returns:
- a new
Vars
instance.
-
tupleOf
Description copied from interface:SproutsFactory
Creates an immutable tuple of non-nullable items from the supplied type and vararg values. This factory method requires the type to be specified, because the compiler cannot infer the type from a potentially empty vararg array.- Specified by:
tupleOf
in interfaceSproutsFactory
- Type Parameters:
T
- the type of the items in the tuple.- Parameters:
type
- the type of the items in the tuple.maybes
- the items to add to the newTuple
instance.- Returns:
- a new
Tuple
instance.
-
tupleOf
Description copied from interface:SproutsFactory
Creates an empty tuple of non-nullable items from the supplied type. This factory method requires the type to be specified, because the compiler cannot infer the type from a potentially empty vararg array.- Specified by:
tupleOf
in interfaceSproutsFactory
- Type Parameters:
T
- the type of the items in the tuple.- Parameters:
type
- the type of the items in the tuple. This is used to check if the item is of the correct type.- Returns:
- a new
Tuple
instance.
-
tupleOf
Description copied from interface:SproutsFactory
Creates an immutable tuple of non-nullable items from one or more non-null items. At least one non-null item must be provided to this factory method.- Specified by:
tupleOf
in interfaceSproutsFactory
- Type Parameters:
T
- the type of the values.- Parameters:
first
- the first value to add to the newTuple
instance.rest
- the remaining values to add to the newTuple
instance.- Returns:
- a new
Tuple
instance.
-
tupleOf
Description copied from interface:SproutsFactory
Creates an immutable, non-nullableTuple<Float>
from a primitive array of floats. The returned tuple will contain the floats as a single dense array of primitives.
Note that in order to guarantee immutability, the array of floats is copied.- Specified by:
tupleOf
in interfaceSproutsFactory
- Parameters:
floats
- The floats to use as a basis for the new tuple.- Returns:
- a new
Tuple
instance backed by a single primitive array of floats.
-
tupleOf
Description copied from interface:SproutsFactory
Creates an immutable, non-nullableTuple<Double>
from a primitive array of doubles. The returned tuple will contain the doubles as a single dense array of primitives.
Note that in order to guarantee immutability, the array of doubles is copied.- Specified by:
tupleOf
in interfaceSproutsFactory
- Parameters:
doubles
- The doubles to use as a basis for the new tuple.- Returns:
- a new
Tuple
instance backed by a single primitive array of doubles.
-
tupleOf
Description copied from interface:SproutsFactory
Creates an immutable tuple of non-nullable items from a primitive array of integers. The returned tuple will contain the integers as a single dense array of primitives.
Note that in order to guarantee immutability, the array of integers is copied.- Specified by:
tupleOf
in interfaceSproutsFactory
- Parameters:
ints
- The integers to use as a basis for the new tuple.- Returns:
- a new
Tuple
instance backed by a single primitive array of integers.
-
tupleOf
Description copied from interface:SproutsFactory
Creates an immutable tuple of non-nullable items from a primitive array of bytes. The returned tuple will contain the bytes as a single dense array of primitives.
Note that in order to guarantee immutability, the array of bytes is copied.- Specified by:
tupleOf
in interfaceSproutsFactory
- Parameters:
bytes
- The bytes to use as a basis for the new tuple.- Returns:
- a new
Tuple
instance backed by a single primitive array of bytes.
-
tupleOf
Description copied from interface:SproutsFactory
Creates an immutable tuple of non-nullable items from a primitive array of longs. The returned tuple will contain the longs as a single dense array of primitives.
Note that in order to guarantee immutability, the array of longs is copied.- Specified by:
tupleOf
in interfaceSproutsFactory
- Parameters:
longs
- The longs to use as a basis for the new tuple.- Returns:
- a new
Tuple
instance backed by a single primitive array of longs.
-
tupleOf
Description copied from interface:SproutsFactory
Creates an immutable tuple of non-nullable items from the supplied type and values. This factory method requires the type to be specified, because the compiler cannot infer the type from the values.- Specified by:
tupleOf
in interfaceSproutsFactory
- Type Parameters:
T
- the type of the values.- Parameters:
type
- the type of the items in the tuple.items
- the values to be wrapped by items and then added to the newTuple
instance. The values may not be null.- Returns:
- a new
Tuple
instance.
-
tupleOf
Description copied from interface:SproutsFactory
Creates an immutable tuple of non-nullable items from the supplied type and iterable of values. This factory method requires the type to be specified, because the compiler cannot infer the type from a potentially empty iterable.- Specified by:
tupleOf
in interfaceSproutsFactory
- Type Parameters:
T
- the type of the items in the tuple.- Parameters:
type
- the type of the items in the tuple.iterable
- the iterable of values.- Returns:
- a new
Tuple
instance.
-
tupleOfNullable
Description copied from interface:SproutsFactory
Creates an empty tuple of nullable items from the supplied type. This factory method requires the type to be specified, because the compiler cannot infer the type from a potentially empty vararg array.- Specified by:
tupleOfNullable
in interfaceSproutsFactory
- Type Parameters:
T
- the type of the items in the tuple.- Parameters:
type
- the type of the items in the tuple. This is used to check if the item is of the correct type.- Returns:
- a new
Tuple
instance.
-
tupleOfNullable
Description copied from interface:SproutsFactory
Creates an immutable tuple of nullable items from the supplied type and values. This factory method requires the type to be specified, because the compiler cannot infer the type from the null values.- Specified by:
tupleOfNullable
in interfaceSproutsFactory
- Type Parameters:
T
- the type of the values.- Parameters:
type
- the type of the items in the tuple.values
- The items to be stored by the newTuple
instance. The values may be null.- Returns:
- a new
Tuple
instance.
-
tupleOfNullable
Description copied from interface:SproutsFactory
Creates an immutable tuple of nullable items from the supplied type and iterable of values. This factory method requires the type to be specified, because the compiler cannot infer the type from a potentially empty iterable.- Specified by:
tupleOfNullable
in interfaceSproutsFactory
- Type Parameters:
T
- the type of the items in the tuple.- Parameters:
type
- the type of the items in the tuple.iterable
- the iterable of values.- Returns:
- a new
Tuple
instance.
-
associationOf
Description copied from interface:SproutsFactory
Creates a new association between keys and values with the given key and value types. An association knows the types of its keys and values, and so you can only put keys and values of the defined types into the association. This creates an empty association primed without any order of their key-value pairs.- Specified by:
associationOf
in interfaceSproutsFactory
- Type Parameters:
K
- The type of the keys in the association, which must be immutable.V
- The type of the values in the association, which should be immutable.- Parameters:
keyType
- The type of the keys in the association.valueType
- The type of the values in the association.- Returns:
- A new association between keys and values.
-
associationOfLinked
Description copied from interface:SproutsFactory
Creates a new linked association between keys and values with the given key and value types, where the order of key-value pairs in this type of association is based on the order in which the pairs are added to the association. An association always knows the types of its keys and values, and so you can only put keys and values of the defined types into the association.- Specified by:
associationOfLinked
in interfaceSproutsFactory
- Type Parameters:
K
- The type of the keys in the association, which must be immutable.V
- The type of the values in the association, which should be immutable.- Parameters:
keyType
- The type of the keys in the association.valueType
- The type of the values in the association.- Returns:
- A new linked association between keys and values, where the order of key-value pairs is preserved in the order they are added.
-
associationOfSorted
public <K,V> Association<K,V> associationOfSorted(Class<K> keyType, Class<V> valueType, Comparator<K> comparator) Description copied from interface:SproutsFactory
Creates a new association between keys and values with the given key and value types, where the key-value pairs are sorted using the supplied comparator. An association knows the types of its keys and values, and so you can only put keys and values of the defined types into the association.- Specified by:
associationOfSorted
in interfaceSproutsFactory
- Type Parameters:
K
- The type of the keys in the association, which must be immutable.V
- The type of the values in the association, which should be immutable.- Parameters:
keyType
- The type of the keys in the association.valueType
- The type of the values in the association.comparator
- The comparator to use for sorting the keys in the association.- Returns:
- A new sorted association between keys and values.
-
associationOfSorted
public <K extends Comparable<K>,V> Association<K,V> associationOfSorted(Class<K> keyType, Class<V> valueType) Description copied from interface:SproutsFactory
Creates a new association between keys and values with the given key and value types, where the keys are sorted in natural order. An association knows the types of its keys and values, and so you can only put keys and values of the defined types into the association.- Specified by:
associationOfSorted
in interfaceSproutsFactory
- Type Parameters:
K
- The type of the keys in the association, which must be immutable.V
- The type of the values in the association, which should be immutable.- Parameters:
keyType
- The type of the keys in the association.valueType
- The type of the values in the association.- Returns:
- A new sorted association between keys and values.
-
valueSetOf
Description copied from interface:SproutsFactory
Creates a new value set specifically for holding elements of the supplied type. A value set knows the types of its elements, and so you can only add elements which are of the same type or a subtype of the type of the value set.- Specified by:
valueSetOf
in interfaceSproutsFactory
- Type Parameters:
E
- The type of the elements in the value set, which must be an immutable value type.- Parameters:
type
- The type of the elements in the value set.- Returns:
- A new value set specific to the given element type.
-
valueSetOfLinked
Description copied from interface:SproutsFactory
Creates a new value set specifically for holding elements of the supplied type, and where the order of the elements is defined by the insertion order. Which means that during iteration over the value set, the elements will be returned in the order they were added. A value set knows the types of its elements, and so you can only add elements which are of the same type or a subtype of the type of the value set.- Specified by:
valueSetOfLinked
in interfaceSproutsFactory
- Type Parameters:
E
- The type of the elements in the value set, which must be an immutable value type.- Parameters:
type
- The type of the elements in the value set.- Returns:
- A new linked value set specific to the given element type.
-
valueSetOfSorted
Description copied from interface:SproutsFactory
Creates a new value set specifically for holding elements of the supplied type, but with an explicit order defined by the supplied comparator. A value set knows the types of its elements and values, and so you can only add elements which are of the same type or a subtype of the type of the value set.
Here is an example demonstrating how this method may be used to create a set with string elements sorted by their length:
ValueSet.ofSorted( String.class, Comparator.comparing(String::length) );
- Specified by:
valueSetOfSorted
in interfaceSproutsFactory
- Type Parameters:
E
- The type of the elements in the value set, which must be an immutable value type.- Parameters:
type
- The type of the elements in the value set.comparator
- The comparator to use for sorting the elements in the value set.- Returns:
- A new sorted value set specific to the given element type.
-
valueSetOfSorted
Description copied from interface:SproutsFactory
Creates a new value set specifically for holding elements of the supplied type, elements are sorted based on the natural ordering of the elements (which are expected to implementComparable
). A value set knows the types of its elements and values, and so you can only add elements which are of the same type or a subtype of the specified element type of the value set.- Specified by:
valueSetOfSorted
in interfaceSproutsFactory
- Type Parameters:
E
- The type of the elements in the value set, which must be an immutable value type.- Parameters:
type
- The type of the elements in the value set.- Returns:
- A new sorted value set specific to the given element type.
-
varsOf
Description copied from interface:SproutsFactory
Creates a list of non-nullable properties from the supplied type and vararg values. This factory method requires that the type be specified because the compiler cannot infer the type from a potentially empty vararg array.- Specified by:
varsOf
in interfaceSproutsFactory
- Type Parameters:
T
- the type of the properties.- Parameters:
type
- the type of the properties.vars
- the properties to add to the new Vars instance.- Returns:
- a new
Vars
instance.
-
varsOf
Description copied from interface:SproutsFactory
Creates an empty list of non-nullable properties from the supplied type. This factory method requires that the type be specified because the compiler cannot infer the type from a potentially empty vararg array.- Specified by:
varsOf
in interfaceSproutsFactory
- Type Parameters:
T
- the type of the properties.- Parameters:
type
- the type of the properties. This is used to check if the item is of the correct type.- Returns:
- a new
Vars
instance.
-
varsOf
Description copied from interface:SproutsFactory
Creates a list of non-nullable properties from one or more non-nullable properties.- Specified by:
varsOf
in interfaceSproutsFactory
- Type Parameters:
T
- the type of the properties.- Parameters:
first
- the first property to add to the new Vars instance.rest
- the remaining properties to add to the new Vars instance.- Returns:
- a new
Vars
instance.
-
varsOf
Description copied from interface:SproutsFactory
Creates a list of non-nullable properties from one or more non-null values.- Specified by:
varsOf
in interfaceSproutsFactory
- Type Parameters:
T
- the type of the values.- Parameters:
first
- the first value to add to the new Vars instance.rest
- the remaining values to add to the new Vars instance.- Returns:
- a new
Vars
instance.
-
varsOf
Description copied from interface:SproutsFactory
Creates a list of non-nullable properties from the supplied type and values. This factory method requires that the type be specified because the compiler cannot infer the type from the values.- Specified by:
varsOf
in interfaceSproutsFactory
- Type Parameters:
T
- the type of the values.- Parameters:
type
- the type of the properties.items
- the values to be wrapped by properties and then added to the new Vars instance. The values may not be null.- Returns:
- a new
Vars
instance.
-
varsOf
Description copied from interface:SproutsFactory
Creates a list of non-nullable properties from the supplied type and iterable of values. This factory method requires that the type be specified because the compiler cannot infer the type from a potentially empty iterable.- Specified by:
varsOf
in interfaceSproutsFactory
- Type Parameters:
T
- the type of the properties.- Parameters:
type
- the type of the properties.vars
- the iterable of values.- Returns:
- a new
Vars
instance.
-
varsOfNullable
Description copied from interface:SproutsFactory
Creates a list of nullable properties from the supplied type and varargs properties. This factory method requires that the type be specified because the compiler cannot infer the type from the null values.- Specified by:
varsOfNullable
in interfaceSproutsFactory
- Type Parameters:
T
- the type of the properties.- Parameters:
type
- the type of the properties.vars
- the properties to add to the new Vars instance. The properties may be nullable properties, but they may not be null themselves.- Returns:
- a new
Vars
instance.
-
varsOfNullable
Description copied from interface:SproutsFactory
Creates an empty list of nullable properties from the supplied type. This factory method requires that the type be specified because the compiler cannot infer the type from a potentially empty vararg array.- Specified by:
varsOfNullable
in interfaceSproutsFactory
- Type Parameters:
T
- the type of the properties.- Parameters:
type
- the type of the properties. This is used to check if the item is of the correct type.- Returns:
- a new
Vars
instance.
-
varsOfNullable
Description copied from interface:SproutsFactory
Creates a list of nullable properties from the supplied type and values. This factory method requires that the type be specified because the compiler cannot infer the type from the null values.- Specified by:
varsOfNullable
in interfaceSproutsFactory
- Type Parameters:
T
- the type of the values.- Parameters:
type
- the type of the properties.values
- the values to be wrapped by properties and then added to the new Vars instance. The values may be null.- Returns:
- a new
Vars
instance.
-
varsOfNullable
Description copied from interface:SproutsFactory
Creates a list of nullable properties from the supplied properties.- Specified by:
varsOfNullable
in interfaceSproutsFactory
- Type Parameters:
T
- the type of the properties.- Parameters:
first
- the first property to add to the new Vars instance.rest
- the remaining properties to add to the new Vars instance.- Returns:
- a new
Vars
instance.
-
defaultId
Description copied from interface:SproutsFactory
The default id for properties which do not have an id explicitly specified. The id of a property is used to identify it in the system or as part of a view model and convert it into other data formats like key/value based data stores.- Specified by:
defaultId
in interfaceSproutsFactory
- Returns:
- The default id for properties which do not have an id explicitly specified.
This must never return
null
and it is recommended to be a constant or cached object due to this method being called frequently.
-
idPattern
Description copied from interface:SproutsFactory
The regexPattern
used to validate property ids. All ids must match this pattern.- Specified by:
idPattern
in interfaceSproutsFactory
- Returns:
- The regex
Pattern
used to validate property ids. This must never returnnull
and it is recommended to be a constant or cached object due to this method being called frequently.
-
defaultChannel
Description copied from interface:SproutsFactory
The default channel used for change events. This channel is used to give events a chanel when no channel is explicitly specified.- Specified by:
defaultChannel
in interfaceSproutsFactory
- Returns:
- The default channel used for change events.
This must never return
null
and it is recommended to be a constant or cached object due to this method being called frequently.
-
defaultObservableChannel
Description copied from interface:SproutsFactory
The default channel used forObservable
events, registered through theObservable.subscribe(Observer)
method.- Specified by:
defaultObservableChannel
in interfaceSproutsFactory
- Returns:
- The default channel used for change events.
This must never return
null
and it is recommended to be a constant or cached object due to this method being called frequently.
-