Package org.apache.wicket.model
Class LambdaModel<T>
- java.lang.Object
-
- org.apache.wicket.model.LambdaModel<T>
-
- Type Parameters:
T- The type of the Model Object
- All Implemented Interfaces:
Serializable,IDetachable,IModel<T>,org.apache.wicket.util.io.IClusterable
public abstract class LambdaModel<T> extends Object implements IModel<T>
LambdaModelis a basic implementation of anIModelthat uses a serializableSupplierto get the object andConsumerto set it.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <X,R>
IModel<R>of(IModel<X> target, org.danekja.java.util.function.serializable.SerializableFunction<X,R> getter, org.danekja.java.util.function.serializable.SerializableBiConsumer<X,R> setter)Create aLambdaModelfor a given target.static <R> IModel<R>of(org.danekja.java.util.function.serializable.SerializableSupplier<R> getter)Create a read-onlyIModel.static <R> IModel<R>of(org.danekja.java.util.function.serializable.SerializableSupplier<R> getter, org.danekja.java.util.function.serializable.SerializableConsumer<R> setter)Create aLambdaModel.voidsetObject(T t)Sets the model object.
-
-
-
Method Detail
-
setObject
public void setObject(T t)
Description copied from interface:IModelSets the model object.
-
of
public static <R> IModel<R> of(org.danekja.java.util.function.serializable.SerializableSupplier<R> getter)
Create a read-onlyIModel. Usage:
Note thatLambdaModel.of(person::getName)IModelis aFunctionalInterfaceand you can also use a lambda directly as a model.- Type Parameters:
R- model object type- Parameters:
getter- used to get value- Returns:
- model
-
of
public static <R> IModel<R> of(org.danekja.java.util.function.serializable.SerializableSupplier<R> getter, org.danekja.java.util.function.serializable.SerializableConsumer<R> setter)
Create aLambdaModel. Usage:LambdaModel.of(person::getName, person::setName)- Type Parameters:
R- model object type- Parameters:
getter- used to get valuesetter- used to set value- Returns:
- model
-
of
public static <X,R> IModel<R> of(IModel<X> target, org.danekja.java.util.function.serializable.SerializableFunction<X,R> getter, org.danekja.java.util.function.serializable.SerializableBiConsumer<X,R> setter)
Create aLambdaModelfor a given target. Usage:
The target model will be detached automatically.LambdaModel.of(personModel, Person::getName, Person::setName)- Type Parameters:
X- target model object typeR- model object type- Parameters:
target- target for getter and settergetter- used to get a valuesetter- used to set a value- Returns:
- model
- See Also:
IModel.flatMap(SerializableFunction)
-
-