@ParametersAreNonnullByDefault public interface ManyValueWithIndices extends ManyValueMapper
ManyValueMapper
that provides a default behavior to represent the "multi-valued" directly with their
position.
Indices are persisted with dedicated SingleFeatureBean
s containing the index of the element to store. Using
this approach avoid to deserialize entire Collection
s to retrieve a single element, which can be an
important bottleneck in terms of execution time and memory consumption if the underlying model contains very large
Collection
s.
Modifier and Type | Method and Description |
---|---|
default <V> void |
addAllValues(ManyFeatureBean feature,
List<? extends V> collection)
Adds all the
collection to the specified feature from the position of the feature . |
default <V> void |
addValue(ManyFeatureBean feature,
V value)
Adds the
value to the specified feature at a defined position. |
default <V> Stream<V> |
allValuesOf(SingleFeatureBean feature)
Retrieves all values of the specified
feature . |
default void |
removeAllValues(SingleFeatureBean feature)
Removes all values of the specified
feature . |
default <V> Optional<V> |
removeValue(ManyFeatureBean feature)
Removes the value of the specified
feature at a defined position. |
default void |
sizeForValue(SingleFeatureBean feature,
int size)
Defines the number of values of the specified
feature . |
default Optional<Integer> |
sizeOfValue(SingleFeatureBean feature)
Returns the number of value of the specified
feature . |
default <V> Optional<V> |
valueFor(ManyFeatureBean feature,
V value)
Defines the
value of the specified feature at a defined position. |
<V> void |
valueForNullable(ManyFeatureBean feature,
V value)
Defines the
value of the specified feature at a defined position. |
appendAllValues, appendValue, valueOf
removeValue, valueFor, valueOf
@Nonnull default <V> Stream<V> allValuesOf(SingleFeatureBean feature)
ManyValueMapper
feature
.allValuesOf
in interface ManyValueMapper
feature
- the bean identifying the multi-valued attributeStream
over all values@Nonnull default <V> Optional<V> valueFor(ManyFeatureBean feature, V value)
ManyValueMapper
value
of the specified feature
at a defined position.valueFor
in interface ManyValueMapper
V
- the type of valuefeature
- the bean identifying the multi-valued attributevalue
- the value to setOptional
containing the previous value of the feature
, or Optional.empty()
if
the feature has no value beforeManyValueMapper.addValue(ManyFeatureBean, Object)
,
ManyValueMapper.appendValue(SingleFeatureBean, Object)
default <V> void addValue(ManyFeatureBean feature, V value)
ManyValueMapper
value
to the specified feature
at a defined position.addValue
in interface ManyValueMapper
V
- the type of valuefeature
- the bean identifying the multi-valued attributevalue
- the value to adddefault <V> void addAllValues(ManyFeatureBean feature, List<? extends V> collection)
ManyValueMapper
collection
to the specified feature
from the position of the feature
.addAllValues
in interface ManyValueMapper
V
- the type of valuefeature
- the bean identifying the multi-valued attributecollection
- the values to add@Nonnull default <V> Optional<V> removeValue(ManyFeatureBean feature)
ManyValueMapper
feature
at a defined position.removeValue
in interface ManyValueMapper
V
- the type of valuefeature
- the bean identifying the multi-valued attributeOptional
containing the removed value, or Optional.empty()
if the feature has no value
beforedefault void removeAllValues(SingleFeatureBean feature)
ManyValueMapper
feature
.removeAllValues
in interface ManyValueMapper
feature
- the bean identifying the multi-valued attribute@Nonnull @Nonnegative default Optional<Integer> sizeOfValue(SingleFeatureBean feature)
ManyValueMapper
feature
.sizeOfValue
in interface ManyValueMapper
feature
- the bean identifying the multi-valued attributeOptional
containing the number of value of the feature
, or Optional.empty()
if
the feature
hasn't any value, or if size == 0
.default void sizeForValue(SingleFeatureBean feature, @Nonnegative int size)
feature
.feature
- the bean identifying the multi-valued attributesize
- the number of valuesNullPointerException
- if the feature
is null
IllegalArgumentException
- if size < 0
<V> void valueForNullable(ManyFeatureBean feature, @Nullable V value)
value
of the specified feature
at a defined position.
This method behaves like valueFor(ManyFeatureBean, Object)
, without checking whether the multi-valued
feature already exists, in order to replace it. If value == null
, the feature is removed.
V
- the type of valuefeature
- the bean identifying the multi-valued attributevalue
- the value to setNullPointerException
- if the feature
is null
Copyright © 2013–2019 Atlanmod. All rights reserved.