com.cumulocity.rest.representation
Class AbstractExtensibleRepresentation

java.lang.Object
  extended by com.cumulocity.rest.representation.BaseResourceRepresentation
      extended by com.cumulocity.rest.representation.AbstractExtensibleRepresentation
All Implemented Interfaces:
ResourceRepresentation, org.svenson.DynamicProperties
Direct Known Subclasses:
EventRepresentation, ManagedObjectRepresentation, MeasurementRepresentation, OperationRepresentation

public class AbstractExtensibleRepresentation
extends BaseResourceRepresentation
implements org.svenson.DynamicProperties


Constructor Summary
AbstractExtensibleRepresentation()
           
 
Method Summary
<T> T
get(Class<T> clazz)
          Returns the object whose parameter name is given by clazz, or null if no such property exists.
 Object get(String name)
          Returns the object associated with the given property name, or null if no such property exists.
 Map<String,Object> getAttrs()
           
 Object getProperty(String name)
           
 Set<String> propertyNames()
           
 void set(Object object)
          Sets a property referring to the given object.
<T> void
set(Object object, Class<T> clazz)
          Sets a property referring to the given object.
 void set(Object object, String propertyName)
          Sets a property referring to the given object, using an arbitrary property name.
 void setAttrs(Map<String,Object> attrs)
           
 void setProperty(String name, Object value)
           
 
Methods inherited from class com.cumulocity.rest.representation.BaseResourceRepresentation
getSelf, setSelf, toJSON, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractExtensibleRepresentation

public AbstractExtensibleRepresentation()
Method Detail

getAttrs

@JSONProperty(ignore=true)
public Map<String,Object> getAttrs()

setAttrs

public void setAttrs(Map<String,Object> attrs)

getProperty

public Object getProperty(String name)
Specified by:
getProperty in interface org.svenson.DynamicProperties

setProperty

public void setProperty(String name,
                        Object value)
Specified by:
setProperty in interface org.svenson.DynamicProperties

propertyNames

public Set<String> propertyNames()
Specified by:
propertyNames in interface org.svenson.DynamicProperties

set

@JSONProperty(ignore=true)
public void set(Object object)
Sets a property referring to the given object. The name of the property will be the fully qualified class name with dots replaced by underscores.
For example, if the object is of type:
then the property name will be:

Parameters:
object -

set

@JSONProperty(ignore=true)
public void set(Object object,
                             String propertyName)
Sets a property referring to the given object, using an arbitrary property name.

Parameters:
object -
propertyName -

set

@JSONProperty(ignore=true)
public <T> void set(Object object,
                                 Class<T> clazz)
Sets a property referring to the given object. The name of the property will be the fully qualified class name of the given class, with dots replaced by underscores.
This can be useful if you want to name the property after the base class rather than the actual class of object.
For example, if clazz is of type:
then the property name will be:

Parameters:
object -
clazz -

get

public <T> T get(Class<T> clazz)
Returns the object whose parameter name is given by clazz, or null if no such property exists.

Parameters:
clazz -
Returns:
See Also:
set(Object)

get

public Object get(String name)
Returns the object associated with the given property name, or null if no such property exists.

Parameters:
name -
Returns:


Copyright © 2013 (C) Cumulocity GmbH. All Rights Reserved.