Class Property<B,T>
- java.lang.Object
-
- org.perfectable.introspection.bean.Property<B,T>
-
- Type Parameters:
B
- Bean type that has this propertyT
- Type of property value
public final class Property<B,T> extends Object
Represents a property of a bean.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <X extends T>
Property<B,X>as(Class<X> newValueType)
Safely casts expected value to specific type.void
copy(Bean<B> other)
Copies value of this property to same property of another bean.boolean
equals(Object obj)
T
get()
Extracts value of this property from bound bean.int
hashCode()
boolean
isReadable()
Answers if the property is readable, i.e.boolean
isWritable()
Answers if the property is writeable, i.e.String
name()
Extracts name of the property.void
set(T value)
Sets provided value for this property of bound bean.Type
type()
Extracts type of the property.
-
-
-
Method Detail
-
as
public <X extends T> Property<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
-
-