Interface PropertyBean

All Known Subinterfaces:
StyleablePropertyBean
All Known Implementing Classes:
AbstractPropertyBean, AbstractStyleablePropertyBean, SimplePropertyBean

public interface PropertyBean
Interface for beans which support an open number of properties in a property map.

A property can be accessed using a Key. The type parameter of the key is used to ensure that property accesses are type safe.

To implement this interface, you need to implement method getProperties() as shown below.


 public class MyBean implements PropertyBean {
      protected final ObservableMap<Key<?>, Object> properties = FXCollections.observableMap(new LinkedHashMap<>());

     {@literal @}Override
     public ObservableMap{@literal <Key<?>, Object>} getProperties() {
        return properties;
      }
 }
 
Author:
Werner Randelshofer
  • Method Summary

    Modifier and Type
    Method
    Description
    default <T> @Nullable T
    get(MapAccessor<T> key)
    Gets a property value.
    default <T> T
    Gets a nonnull property value.
    javafx.collections.ObservableMap<Key<?>,Object>
    Returns an observable map of property keys and their values.
    default <T> javafx.beans.property.ObjectProperty<T>
    getProperty(Key<T> key)
     
    default <T> @Nullable T
    put(MapAccessor<T> key, @Nullable T newValue)
    Puts a property value.
    default <T> @Nullable T
    remove(Key<T> key)
    Removes a property value.
    default <T> void
    set(MapAccessor<T> key, @Nullable T newValue)
    Sets a property value.
    default <T> void
    setNonNull(NonNullMapAccessor<T> key, T newValue)
    Sets a non-null property value.
    default <T> javafx.beans.value.ObservableValue<T>
    valueAt(Key<T> key)
     
  • Method Details

    • getProperties

      javafx.collections.ObservableMap<Key<?>,Object> getProperties()
      Returns an observable map of property keys and their values.
      Returns:
      the map
    • getProperty

      default <T> javafx.beans.property.ObjectProperty<T> getProperty(Key<T> key)
    • set

      default <T> void set(MapAccessor<T> key, @Nullable T newValue)
      Sets a property value.
      Type Parameters:
      T - the value type
      Parameters:
      key - the key
      newValue - the value
    • setNonNull

      default <T> void setNonNull(NonNullMapAccessor<T> key, T newValue)
      Sets a non-null property value.
      Type Parameters:
      T - the value type
      Parameters:
      key - the key
      newValue - the value
    • put

      default <T> @Nullable T put(MapAccessor<T> key, @Nullable T newValue)
      Puts a property value.
      Type Parameters:
      T - the value type
      Parameters:
      key - the key
      newValue - the value
      Returns:
      the old value
    • get

      default <T> @Nullable T get(MapAccessor<T> key)
      Gets a property value.
      Type Parameters:
      T - the value type
      Parameters:
      key - the key
      Returns:
      the value
    • getNonNull

      default <T> T getNonNull(NonNullMapAccessor<T> key)
      Gets a nonnull property value.
      Type Parameters:
      T - the value type
      Parameters:
      key - the key
      Returns:
      the value
    • remove

      default <T> @Nullable T remove(Key<T> key)
      Removes a property value.
      Type Parameters:
      T - the value type
      Parameters:
      key - the key
      Returns:
      the removed value
    • valueAt

      default <T> javafx.beans.value.ObservableValue<T> valueAt(Key<T> key)