Interface StateHelper

All Superinterfaces:
StateHolder

public interface StateHelper extends StateHolder

Define a Map-like contract that makes it easier for components to implement PartialStateHolder. Each UIComponent in the view will return an implementation of this interface from its UIComponent.getStateHelper() method.

Since:
2.0
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(Serializable key, Object value)
    Store the specified value in a List that is internal to the StateHelper.
    default <T> T
    computeIfAbsent(Serializable key, Supplier<T> defaultValueSupplier)
    Performs the same logic as get(java.io.Serializable) } but if no value is found, this will put and return the return-value of the defaultValueSupplier.
    <T> T
    Attempts to find a value associated with the specified key, using the value expression collection from the component if no such value is found.
    <T> T
    eval(Serializable key, Supplier<T> defaultValueSupplier)
    Performs the same logic as eval(java.io.Serializable) } but if no value is found, this will return the return-value of the defaultValueSupplier
    <T> T
    eval(Serializable key, T defaultValue)
    Performs the same logic as eval(java.io.Serializable) } but if no value is found, this will return the specified defaultValue
    <T> T
    Return the value currently associated with the specified key if any.
    <T> T
    put(Serializable key, String mapKey, T value)
    Store the specified mapKey/value in a Map that is internal to the helper, and return the previously stored value.
    <T> T
    put(Serializable key, T value)
    Return the previously stored value and store the specified key/value pair.
    <T> T
    Remove the key/value pair from the helper, returning the value previously stored under this key.
    <T> T
    remove(Serializable key, Object valueOrKey)
    Remove a value from the inner data structure.

    Methods inherited from interface StateHolder

    isTransient, restoreState, saveState, setTransient
    Modifier and Type
    Method
    Description
    boolean
    If true, the Object implementing this interface must not participate in state saving or restoring.
    void
    restoreState(FacesContext context, Object state)
    Perform any processing required to restore the state from the entries in the state Object.
    Gets the state of the instance as a Serializable Object.
    void
    setTransient(boolean newTransientValue)
    Denotes whether or not the Object implementing this interface must or must not participate in state saving or restoring.
  • Method Details

    • put

      <T> T put(Serializable key, T value)

      Return the previously stored value and store the specified key/value pair. This is intended to store data that would otherwise reside in an instance variable on the component.

      Type Parameters:
      T - The generic type of the value.
      Parameters:
      key - the key for the value
      value - the value
      Returns:
      the previously stored value
      Since:
      2.0
    • remove

      <T> T remove(Serializable key)

      Remove the key/value pair from the helper, returning the value previously stored under this key.

      Type Parameters:
      T - The generic type of the removed value.
      Parameters:
      key - the key to remove
      Returns:
      the removed value.
      Since:
      2.0
    • put

      <T> T put(Serializable key, String mapKey, T value)

      Store the specified mapKey/value in a Map that is internal to the helper, and return the previously stored value. The Map will then be associated with key.

      It's important to note for delta tracking that any modifications to the internal Map be made through this method or remove(java.io.Serializable, Object).

      Type Parameters:
      T - The generic type of the value.
      Parameters:
      key - the key of the map itself
      mapKey - the key within the internal map
      value - the value for the key in the internal map
      Returns:
      the value.
      Since:
      2.0
    • get

      <T> T get(Serializable key)

      Return the value currently associated with the specified key if any.

      Type Parameters:
      T - The generic type of the value.
      Parameters:
      key - the key for which the value should be returned.
      Returns:
      the value.
      Since:
      2.0
    • computeIfAbsent

      default <T> T computeIfAbsent(Serializable key, Supplier<T> defaultValueSupplier)

      Performs the same logic as get(java.io.Serializable) } but if no value is found, this will put and return the return-value of the defaultValueSupplier.

      Type Parameters:
      T - The generic type of the value.
      Parameters:
      key - the key for which the value should be returned.
      defaultValueSupplier - the supplier used to put and return the default value if no value is found in the call to get().
      Returns:
      the value.
      Throws:
      ClassCastException - When T is of wrong type.
      Since:
      5.0
    • eval

      <T> T eval(Serializable key)

      Attempts to find a value associated with the specified key, using the value expression collection from the component if no such value is found.

      Type Parameters:
      T - The generic type of the evaluated value.
      Parameters:
      key - the name of the value in the internal map, or the name of a value expression in the components value expression collection.
      Returns:
      the evaluated value.
      Since:
      2.0
    • eval

      <T> T eval(Serializable key, T defaultValue)

      Performs the same logic as eval(java.io.Serializable) } but if no value is found, this will return the specified defaultValue

      Type Parameters:
      T - The generic type of the evaluated value.
      Parameters:
      key - the key for which the value should be returned.
      defaultValue - the value to return if no value is found in the call to eval().
      Returns:
      the evaluated value.
      Since:
      2.0
    • eval

      <T> T eval(Serializable key, Supplier<T> defaultValueSupplier)

      Performs the same logic as eval(java.io.Serializable) } but if no value is found, this will return the return-value of the defaultValueSupplier

      Type Parameters:
      T - The generic type of the evaluated value.
      Parameters:
      key - the key for which the value should be returned.
      defaultValueSupplier - the supplier used to evaluate the default value if no value is found in the call to eval().
      Returns:
      the evaluated value.
      Since:
      4.0
    • add

      void add(Serializable key, Object value)

      Store the specified value in a List that is internal to the StateHelper.

      It's important to note for delta tracking that any modifications to the internal List be made through this method or remove(java.io.Serializable, Object).

      Parameters:
      key - the key for which the value should be returned.
      value - the value to add
      Since:
      2.0
    • remove

      <T> T remove(Serializable key, Object valueOrKey)

      Remove a value from the inner data structure. Look in the inner data structure for the value at the given key. If the value is a Map, remove and return the value under the key given by the valueOrKey argument. If the value is a Collection, simply remove the value given by the argument valueOrKey and return null.

      Type Parameters:
      T - The generic type of the removed value.
      Parameters:
      key - the key of in the inner data structure whose value is a Collection or Map
      valueOrKey - the value or key to be removed.
      Returns:
      the removed value.