Class ObjectProperty<S>

java.lang.Object
org.jdesktop.beansbinding.Property<S,S>
org.jdesktop.beansbinding.ObjectProperty<S>
Type Parameters:
S - the type of source object that this Property operates on and therefore the type of value that it represents

public final class ObjectProperty<S> extends Property<S,S>
An immutable, read-only, Property implementation whose getValue method returns the source object that it is given. This class is useful when you want to configure a Binding to use its source object directly, rather than some property of the source object. For example:

   new SomeBindingClass(sourceObject, ObjectProperty.create(), targetObject, targetProperty);

Explicitly using ObjectProperty isn't necessary when creating Bindings from this package or the SwingBindings package, as the set of static creation methods include versions that handle this for you.

  • Method Details

    • create

      public static <S> ObjectProperty<S> create()
      Creates an instance of ObjectProperty.
    • getWriteType

      public Class<? extends S> getWriteType(S source)
      Throws UnsupportedOperationException; ObjectProperty is never writeable.
      Specified by:
      getWriteType in class Property<S,S>
      Parameters:
      source - the source object on which to operate
      Returns:
      never returns; always throws UnsupportedOperationException; ObjectProperty is never writeable
      Throws:
      UnsupportedOperationException - always; ObjectProperty is never writeable
      See Also:
    • getValue

      public S getValue(S source)
      Returns the source object passed to the method.
      Specified by:
      getValue in class Property<S,S>
      Parameters:
      source - the source object on which to operate
      Returns:
      the value of the source argument
      See Also:
    • setValue

      public void setValue(S source, S value)
      Throws UnsupportedOperationException; ObjectProperty is never writeable.
      Specified by:
      setValue in class Property<S,S>
      Parameters:
      source - the source object on which to operate
      value - the new value for the Property
      Throws:
      UnsupportedOperationException - always; ObjectProperty is never writeable
      See Also:
    • isReadable

      public boolean isReadable(Object source)
      Returns true; ObjectProperty is always readable.
      Specified by:
      isReadable in class Property<S,S>
      Parameters:
      source - the source object on which to operate
      Returns:
      true; ObjectPropert is always readable
      See Also:
    • isWriteable

      public boolean isWriteable(Object source)
      Returns false; ObjectProperty is never writeable.
      Specified by:
      isWriteable in class Property<S,S>
      Parameters:
      source - the source object on which to operate
      Returns:
      false; ObjectPropert is never writeable
      See Also:
    • toString

      public String toString()
      Returns a string representation of the ObjectProperty. This method is intended to be used for debugging purposes only, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null.
      Overrides:
      toString in class Object
      Returns:
      a string representation of this ObjectProperty
    • addPropertyStateListener

      public void addPropertyStateListener(S source, PropertyStateListener listener)
      Does nothing; the state of an ObjectProperty never changes so listeners aren't useful.
      Specified by:
      addPropertyStateListener in class Property<S,S>
      Parameters:
      source - the source object on which to operate
      listener - the listener to be notified
    • removePropertyStateListener

      public void removePropertyStateListener(S source, PropertyStateListener listener)
      Does nothing; the state of an ObjectProperty never changes so listeners aren't useful.
      Specified by:
      removePropertyStateListener in class Property<S,S>
      Parameters:
      source - the source object on which to operate
      listener - the listener to be removed
      See Also:
    • getPropertyStateListeners

      public PropertyStateListener[] getPropertyStateListeners(S source)
      Returns an empty array; the state of an ObjectProperty never changes so listeners aren't useful.
      Specified by:
      getPropertyStateListeners in class Property<S,S>
      Parameters:
      source - the source object on which to operate
      Returns:
      an empty array
      See Also: