com.vaadin.signals.

Interface SignalFactory

Functional Interface:

This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface SignalFactory

Provides a signal instance based on a name. This encapsulates different strategies for creating instances that are e.g. synchronized across a cluster, shared within the same JVM, or isolated from any other instance.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final SignalFactory

    A signal factory that always returns a new instance that is not shared.

    static final SignalFactory

    A signal factory that always returns the same signal for the same name within the same JVM.

  • Method Summary

    Modifier and Type
    Method
    Description
    default void

    Removes all name associations.

    default <T> ListSignal<T>
    list(String name, Class<T> elementType)

    Gets a list signal with the given element type for the given name.

    default <T> MapSignal<T>
    map(String name, Class<T> elementType)

    Gets a map signal with the given element type for the given name.

    node(String name)

    Gets a node signal for the given name.

    default NumberSignal
    number(String name)

    Gets a number signal for the given name.

    default NumberSignal
    number(String name, double defaultValue)

    Gets a number signal for the given name and initializes it with the provided default value if the signal doesn't already have a value.

    default void
    remove(String name)

    Removes any previous association for the given name.

    default <T> ValueSignal<T>
    value(String name, Class<T> valueType)

    Gets a value signal of the given type for the given name.

    default <T> ValueSignal<T>
    value(String name, Class<T> valueType, T defaultValue)

    Gets a value signal of the given type for the given name and initializes it with the provided default value if the signal doesn't already have a value.

    default <T> ValueSignal<T>
    value(String name, T defaultValue)

    Gets a value signal for the given name and initializes it with the provided default value if the signal doesn't already have a value.

  • Field Details

    • IN_MEMORY_EXCLUSIVE

      static final SignalFactory IN_MEMORY_EXCLUSIVE

      A signal factory that always returns a new instance that is not shared. This factory does not support the optional removal methods.

    • IN_MEMORY_SHARED

      static final SignalFactory IN_MEMORY_SHARED

      A signal factory that always returns the same signal for the same name within the same JVM. This factory supports the optional removal methods.

  • Method Details

    • node

      NodeSignal node(String name)

      Gets a node signal for the given name.

      Parameters:

      name - the name to use, not null

      Returns:

      a node signal, not null

    • value

      default <T> ValueSignal<T> value(String name, Class<T> valueType)

      Gets a value signal of the given type for the given name.

      Type Parameters:

      T - the value type

      Parameters:

      name - the name to use, not null

      valueType - the value type to use, not null

      Returns:

      a value signal, not null

    • value

      default <T> ValueSignal<T> value(String name, Class<T> valueType, T defaultValue)

      Gets a value signal of the given type for the given name and initializes it with the provided default value if the signal doesn't already have a value. If the implementation returns an existing signal instance that already had a non-null value, then the provided default value is ignored.

      Type Parameters:

      T - the value type

      Parameters:

      name - the name to use, not null

      valueType - the value type to use, not null

      defaultValue - the default value to use, not null

      Returns:

      a value signal, not null

    • value

      default <T> ValueSignal<T> value(String name, T defaultValue)

      Gets a value signal for the given name and initializes it with the provided default value if the signal doesn't already have a value. If the implementation returns an existing signal instance that already had a non-null value, then the provided default value is ignored. The signal value type is based on the type (Object.getClass()) of the default value instance.

      Type Parameters:

      T - the value type

      Parameters:

      name - the name to use, not null

      defaultValue - the default value to use, not null

      Returns:

      a value signal, not null

    • number

      default NumberSignal number(String name)

      Gets a number signal for the given name.

      Parameters:

      name - the name to use, not null

      Returns:

      a number signal, not null

    • number

      default NumberSignal number(String name, double defaultValue)

      Gets a number signal for the given name and initializes it with the provided default value if the signal doesn't already have a value.

      Parameters:

      name - the name to use, not null

      defaultValue - the default value to use

      Returns:

      a number signal, not null

    • list

      default <T> ListSignal<T> list(String name, Class<T> elementType)

      Gets a list signal with the given element type for the given name.

      Type Parameters:

      T - the element type

      Parameters:

      name - the to use, not null

      elementType - the element type, not null

      Returns:

      a list signal, not null

    • map

      default <T> MapSignal<T> map(String name, Class<T> elementType)

      Gets a map signal with the given element type for the given name.

      Type Parameters:

      T - the element type

      Parameters:

      name - the to use, not null

      elementType - the element type, not null

      Returns:

      a map signal, not null

    • remove

      default void remove(String name) throws UnsupportedOperationException

      Removes any previous association for the given name. Removing an association typically means that memory previously associated with the name is freed and a subsequent invocation with the same name will create a new signal.

      This is an optional operation. Implementations that don't support removal throw UnsupportedOperationException.

      Parameters:

      name - the name to remove, not NullPointerException

      Throws:

      UnsupportedOperationException - if this implementation doesn't support removal

    • clear

      default void clear() throws UnsupportedOperationException

      Removes all name associations. Removing an association typically means that memory previously associated with the name is freed and a subsequent invocation with the same name will create a new signal.

      This is an optional operation. Implementations that don't support clearing may throw UnsupportedOperationException.

      Throws:

      UnsupportedOperationException - if this implementation doesn't support clearing