Class ValueHolder

java.lang.Object
groovy.swing.model.ValueHolder
All Implemented Interfaces:
ValueModel

public class ValueHolder extends Object implements ValueModel
A mutable ValueModel implementation that stores a local value and optionally emits change events.
  • Constructor Details

    • ValueHolder

      public ValueHolder()
      Creates a holder with Object as its declared type.
    • ValueHolder

      public ValueHolder(Class type)
      Creates a holder with the supplied declared type.
      Parameters:
      type - the declared value type
    • ValueHolder

      public ValueHolder(Object value)
      Creates a holder initialized with the supplied value.
      Parameters:
      value - the initial value
  • Method Details

    • addPropertyChangeListener

      public void addPropertyChangeListener(PropertyChangeListener listener)
      Add a PropertyChangeListener to the listener list.
      Parameters:
      listener - The listener to add.
    • removePropertyChangeListener

      public void removePropertyChangeListener(PropertyChangeListener listener)
      Removes a PropertyChangeListener from the listener list.
      Parameters:
      listener - The listener to remove.
    • getValue

      public Object getValue()
      Returns the current stored value.
      Specified by:
      getValue in interface ValueModel
      Returns:
      the current value
    • setValue

      public void setValue(Object value)
      Updates the current value and notifies registered listeners of the change.
      Specified by:
      setValue in interface ValueModel
      Parameters:
      value - the new value
    • getType

      public Class getType()
      Returns the declared value type for this holder.
      Specified by:
      getType in interface ValueModel
      Returns:
      the holder type
    • isEditable

      public boolean isEditable()
      Indicates whether callers should treat this holder as writable.
      Specified by:
      isEditable in interface ValueModel
      Returns:
      true when the holder is editable
    • setEditable

      public void setEditable(boolean editable)
      Controls whether callers should treat this holder as writable.
      Parameters:
      editable - true to mark the holder as editable