Class Property<B,​T>

  • Type Parameters:
    B - Bean type that has this property
    T - Type of property value

    public final class Property<B,​T>
    extends Object
    Represents a property of a bean.
    • Method Detail

      • as

        public <X extends TProperty<B,​X> as​(Class<X> newValueType)
        Safely casts expected value to specific type.
        Type Parameters:
        X - new value type
        Parameters:
        newValueType - new value type representation
        Returns:
        property with new value type
        Throws:
        IllegalArgumentException - if property value aren't of this type.
      • get

        @Nullable
        public T get()
        Extracts value of this property from bound bean.
        Returns:
        Property value
        Throws:
        IllegalStateException - when this property is not readable
      • set

        public void set​(@Nullable
                        T value)
        Sets provided value for this property of bound bean.
        Parameters:
        value - new value for this property
        Throws:
        IllegalStateException - when this property is not writeable
      • type

        public Type type()
        Extracts type of the property.
        Returns:
        property type
      • name

        public String name()
        Extracts name of the property.
        Returns:
        property name
      • isReadable

        public boolean isReadable()
        Answers if the property is readable, i.e. get() will succeed.
        Returns:
        if the property can have value read
      • isWritable

        public boolean isWritable()
        Answers if the property is writeable, i.e. set(T) will succeed.
        Returns:
        if the property can have value written
      • copy

        public void copy​(Bean<B> other)
        Copies value of this property to same property of another bean.
        Parameters:
        other - bean to set value on
        Throws:
        IllegalStateException - when this property is either not readable or not writeable
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object