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>
,IClusterable
public abstract class LambdaModel<T> extends Object implements IModel<T>
LambdaModel
is a basic implementation of anIModel
that uses a serializableSupplier
to get the object andConsumer
to 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 aLambdaModel
for 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
.void
setObject(T t)
Sets the model object.
-
-
-
Method Detail
-
setObject
public void setObject(T t)
Description copied from interface:IModel
Sets the model object.
-
of
public static <R> IModel<R> of(org.danekja.java.util.function.serializable.SerializableSupplier<R> getter)
Create a read-onlyIModel
. Usage:LambdaModel.of(person::getName)
IModel
is aFunctionalInterface
and 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 aLambdaModel
for a given target. Usage: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)
-
-