Class LambdaModel<T>

  • Type Parameters:
    T - The type of the IModel Object
    All Implemented Interfaces:
    Attachable, IDetachable, IModel<T>, java.io.Serializable

    public abstract class LambdaModel<T>
    extends java.lang.Object
    implements IModel<T>
    LambdaModel is a basic implementation of an IModel that uses a serializable Supplier to get the object and Consumer to set it.
    See Also:
    Serialized Form
    • Method Detail

      • of

        public static <X,​T> IModel<T> of​(IModel<X> target,
                                               SerializableFunction<X,​T> getter)
        Create a LambdaModel for a given target. Usage:
         
         	LambdaModel.of(personModel, Person::getName)
         
         
        The target model will be detached automatically.
        Type Parameters:
        X - target model object type
        T - model object type
        Parameters:
        target - target for getter and setter
        getter - used to get a value
        Returns:
        model
      • of

        public static <X,​T> IModel<T> of​(IModel<X> target,
                                               SerializableFunction<X,​T> getter,
                                               SerializableBiConsumer<X,​T> setter)
        Create a LambdaModel for a given target. Usage:
         
         	LambdaModel.of(personModel, Person::getName, Person::setName)
         
         
        The target model will be detached automatically.
        Type Parameters:
        X - target model object type
        T - model object type
        Parameters:
        target - target for getter and setter
        getter - used to get a value
        setter - used to set a value
        Returns:
        model
      • of

        public static <T> IModel<T> of​(SerializableSupplier<T> getter,
                                       SerializableConsumer<T> setter)
        Create a LambdaModel. Usage:
         
         	LambdaModel.of(person::getName, person::setName)
         
         
        Type Parameters:
        T - model object type
        Parameters:
        getter - used to get value
        setter - used to set value
        Returns:
        model
      • setObject

        public void setObject​(T t)
        Description copied from interface: IModel
        Sets the model object.
        Specified by:
        setObject in interface IModel<T>
        Parameters:
        t - The model object