Package com.vaadin.data.util
Class ObjectProperty<T>
- java.lang.Object
-
- com.vaadin.data.util.AbstractProperty<T>
-
- com.vaadin.data.util.ObjectProperty<T>
-
- All Implemented Interfaces:
Property<T>
,Property.ReadOnlyStatusChangeNotifier
,Property.ValueChangeNotifier
,Serializable
public class ObjectProperty<T> extends AbstractProperty<T>
A simple data object containing one typed value. This class is a straightforward implementation of the theProperty
interface.- Since:
- 3.0
- Author:
- Vaadin Ltd.
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.vaadin.data.util.AbstractProperty
AbstractProperty.ReadOnlyStatusChangeEvent
-
Nested classes/interfaces inherited from interface com.vaadin.data.Property
Property.Editor, Property.ReadOnlyException, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.Transactional<T>, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer
-
-
Constructor Summary
Constructors Constructor Description ObjectProperty(T value)
Creates a new instance of ObjectProperty with the given value.ObjectProperty(T value, Class<T> type)
Creates a new instance of ObjectProperty with the given value and type.ObjectProperty(T value, Class<T> type, boolean readOnly)
Creates a new instance of ObjectProperty with the given value, type and read-only mode status.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Class<T>
getType()
Returns the type of the ObjectProperty.T
getValue()
Gets the value stored in the Property.void
setValue(T newValue)
Sets the value of the property.-
Methods inherited from class com.vaadin.data.util.AbstractProperty
addListener, addListener, addReadOnlyStatusChangeListener, addValueChangeListener, fireReadOnlyStatusChange, fireValueChange, getListeners, isReadOnly, removeListener, removeListener, removeReadOnlyStatusChangeListener, removeValueChangeListener, setReadOnly, toString
-
-
-
-
Constructor Detail
-
ObjectProperty
public ObjectProperty(T value)
Creates a new instance of ObjectProperty with the given value. The type of the property is automatically initialized to be the type of the given value.- Parameters:
value
- the Initial value of the Property.
-
ObjectProperty
public ObjectProperty(T value, Class<T> type)
Creates a new instance of ObjectProperty with the given value and type. Since Vaadin 7, only values of the correct type are accepted, and no automatic conversions are performed.- Parameters:
value
- the Initial value of the Property.type
- the type of the value. The value must be assignable to given type.
-
ObjectProperty
public ObjectProperty(T value, Class<T> type, boolean readOnly)
Creates a new instance of ObjectProperty with the given value, type and read-only mode status. Since Vaadin 7, only the correct type of values is accepted, seeObjectProperty(Object, Class)
.- Parameters:
value
- the Initial value of the property.type
- the type of the value.value
must be assignable to this type.readOnly
- Sets the read-only mode.
-
-
Method Detail
-
getType
public final Class<T> getType()
Returns the type of the ObjectProperty. The methodsgetValue
andsetValue
must be compatible with this type: one must be able to safely cast the value returned fromgetValue
to the given type and pass any variable assignable to this type as an argument tosetValue
.- Returns:
- type of the Property
-
getValue
public T getValue()
Gets the value stored in the Property.- Returns:
- the value stored in the Property
-
setValue
public void setValue(T newValue) throws Property.ReadOnlyException
Sets the value of the property. Note that since Vaadin 7, no conversions are performed and the value must be of the correct type.- Parameters:
newValue
- the New value of the property.- Throws:
Property.ReadOnlyException
- if the object is in read-only mode
-
-