com.holonplatform.vaadin.components

## Interface ValueHolder<V>

- Type Parameters:
    `V` - Value type
  All Superinterfaces:
    Serializable
  All Known Subinterfaces:
    Input<V>, MultiSelect<T>, PropertyInputForm, PropertyInputGroup, PropertyViewForm, PropertyViewGroup, SingleSelect<T>, ValidatableInput<V>, ViewComponent<V>

      public interface ValueHolder<V>
      extends Serializable

  Represents an object which holds a value and provide methods to handle such value.
  Since:
    5.0.0

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface and Description
    --- | ---
    `static interface` | `ValueHolder.ValueChangeEvent<V>` A `ValueHolder.ValueChangeListener` event.
    `static interface` | `ValueHolder.ValueChangeListener<V>` A listener for `ValueHolder` value change events.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `Registration` | `addValueChangeListener(ValueHolder.ValueChangeListener<V> listener)` Adds a value change listener, called when the value changes.
    `default void` | `clear()` Clears this value holder.
    `default V` | `getEmptyValue()` Returns the value that represents an empty value.
    `default Optional<V>` | `getOptionalValue()` Gets the current value of this value holder as an `Optional`, which will be empty if the value holder is considered to be empty.
    `V` | `getValue()` Gets the current value of this value holder.
    `default boolean` | `isEmpty()` Returns whether this value holder is considered to be empty, according to its current value.
    `void` | `setValue(V value)` Sets the `value` of this value holder.

- - ### Method Detail

    - #### setValue

          void setValue(V value)

      Sets the `value` of this value holder.
      Parameters:
        `value` - the value to set
      Throws:
        `IllegalArgumentException` - if the value is not valid

    - #### getValue

          V getValue()

      Gets the current value of this value holder.
      Returns:
        the current value

    - #### getEmptyValue

          default V getEmptyValue()

      Returns the value that represents an empty value.
      Returns:
        the value that represents an empty value (`null` by default)

    - #### isEmpty

          default boolean isEmpty()

      Returns whether this value holder is considered to be empty, according to its current value.

      By default this is an equality check between current value and empty value.

      Returns:
        `true` if considered empty, `false` if not

    - #### clear

          default void clear()

      Clears this value holder.

      By default, resets the value to the empty one.

    - #### getOptionalValue

          default Optional<V> getOptionalValue()

      Gets the current value of this value holder as an `Optional`, which will be empty if the value holder is considered to be empty.
      Returns:
        the current optional value

    - #### addValueChangeListener

          Registration addValueChangeListener(ValueHolder.ValueChangeListener<V> listener)

      Adds a value change listener, called when the value changes.
      Parameters:
        `listener` - the value change listener to add (not null)
      Returns:
        a registration for the listener, which provides the remove operation

Copyright © 2017 The Holon Platform. All rights reserved.