Package com.kenshoo.pl.entity.spi
Interface FieldValueSupplier<T>
-
- Type Parameters:
T- type of the field whose value is being supplied
- All Superinterfaces:
FetchEntityFields
- All Known Implementing Classes:
FixedFieldValueSupplier
public interface FieldValueSupplier<T> extends FetchEntityFields
A "delayed" supplier of the new value for a field that decides on the value given the current state. For example, a logic to increment the current value by 10% can be implemented by implementing this interface. Thesupply(CurrentEntityState)method is going to be called after the current state has been fetched from the database.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static <OLD_VAL,NEW_VAL>
FieldValueSupplier<NEW_VAL>fromOldValue(EntityField<?,OLD_VAL> field, java.util.function.Function<OLD_VAL,NEW_VAL> func)static <T1,T2,RES>
FieldValueSupplier<RES>fromValues(EntityField<?,T1> field1, EntityField<?,T2> field2, java.util.function.BiFunction<T1,T2,RES> func)Tsupply(CurrentEntityState currentState)Returns the new value for a field given an existing entity-
Methods inherited from interface com.kenshoo.pl.entity.spi.FetchEntityFields
fetchFields
-
-
-
-
Method Detail
-
supply
T supply(CurrentEntityState currentState) throws ValidationException, NotSuppliedException
Returns the new value for a field given an existing entity- Parameters:
currentState- entity before the change- Returns:
- new field value
- Throws:
ValidationException- if the supposed change is invalidNotSuppliedException- if the supplier doesn't want to change the current value
-
fromOldValue
static <OLD_VAL,NEW_VAL> FieldValueSupplier<NEW_VAL> fromOldValue(EntityField<?,OLD_VAL> field, java.util.function.Function<OLD_VAL,NEW_VAL> func)
-
fromValues
static <T1,T2,RES> FieldValueSupplier<RES> fromValues(EntityField<?,T1> field1, EntityField<?,T2> field2, java.util.function.BiFunction<T1,T2,RES> func)
-
-