Interface Property<P>

  • Type Parameters:
    P - the type of the property content
    All Known Implementing Classes:
    BasicProperty

    public interface Property<P>
    A property that is linked to a specific bean.

    For a JavaBean, this will ultimately wrap a get/set method pair. Alternate implementations may perform any logic to obtain the value.

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      <B extends Bean>
      B
      bean()
      Gets the bean which owns this property.
      boolean equals​(java.lang.Object obj)
      Checks if this property equals another.
      default P get()
      Gets the value of the property for the associated bean.
      int hashCode()
      Returns a suitable hash code.
      MetaProperty<P> metaProperty()
      Gets the meta-property representing the parts of the property that are common across all instances, such as the name.
      default java.lang.String name()
      Gets the property name.
      default P put​(java.lang.Object value)
      Sets the value of the property on the associated bean and returns the previous value.
      default void set​(java.lang.Object value)
      Sets the value of the property on the associated bean.
    • Method Detail

      • bean

        <B extends Bean> B bean()
        Gets the bean which owns this property.

        Each property is fully owned by a single bean.

        Type Parameters:
        B - the bean type
        Returns:
        the bean, not null
      • metaProperty

        MetaProperty<P> metaProperty()
        Gets the meta-property representing the parts of the property that are common across all instances, such as the name.
        Returns:
        the meta-property, not null
      • name

        default java.lang.String name()
        Gets the property name.

        The JavaBean style methods getFoo() and setFoo() will lead to a property name of 'foo' and so on.

        Returns:
        the name of the property, not empty
      • get

        default P get()
        Gets the value of the property for the associated bean.

        For a JavaBean, this is the equivalent to calling getFoo() on the bean itself. Alternate implementations may perform any logic to obtain the value.

        Returns:
        the value of the property on the bound bean, may be null
        Throws:
        java.lang.UnsupportedOperationException - if the property is write-only
      • set

        default void set​(java.lang.Object value)
        Sets the value of the property on the associated bean.

        The value must be of the correct type for the property. See the meta-property for string conversion. For a standard JavaBean, this is equivalent to calling setFoo() on the bean. Alternate implementations may perform any logic to change the value.

        Parameters:
        value - the value to set into the property on the bean
        Throws:
        java.lang.ClassCastException - if the value is of an invalid type for the property
        java.lang.UnsupportedOperationException - if the property is read-only
        java.lang.RuntimeException - if the value is rejected by the property (use appropriate subclasses)
      • put

        default P put​(java.lang.Object value)
        Sets the value of the property on the associated bean and returns the previous value.

        This is a combination of the get and set methods that matches the definition of put in a Map.

        Parameters:
        value - the value to set into the property on the bean
        Returns:
        the old value of the property, may be null
        Throws:
        java.lang.ClassCastException - if the value is of an invalid type for the property
        java.lang.UnsupportedOperationException - if the property is read-only
        java.lang.RuntimeException - if the value is rejected by the property (use appropriate subclasses)
      • equals

        boolean equals​(java.lang.Object obj)
        Checks if this property equals another.

        This compares the meta-property and value. It does not consider the property or bean types.

        Overrides:
        equals in class java.lang.Object
        Parameters:
        obj - the other property, null returns false
        Returns:
        true if equal
      • hashCode

        int hashCode()
        Returns a suitable hash code.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        the hash code