com.vaadin.data.util
Class ObjectProperty<T>

java.lang.Object
  extended by com.vaadin.data.util.AbstractProperty<T>
      extended by 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 the Property interface.

Since:
3.0
Version:
7.0.0.alpha3
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
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
 Class<T> getType()
          Returns the type of the ObjectProperty.
 T getValue()
          Gets the value stored in the Property.
 void setValue(Object newValue)
          Sets the value of the property.
 
Methods inherited from class com.vaadin.data.util.AbstractProperty
addListener, addListener, fireReadOnlyStatusChange, fireValueChange, getListeners, isReadOnly, removeListener, removeListener, setReadOnly, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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, see ObjectProperty(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 methods getValue and setValue must be compatible with this type: one must be able to safely cast the value returned from getValue to the given type and pass any variable assignable to this type as an argument to setValue.

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(Object 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
Property.ReadOnlyException - if the object is in read-only mode


Copyright © 2000-2011 Vaadin Ltd. All Rights Reserved.