Package com.cumulocity.model
Class Document<T extends ID>
- java.lang.Object
-
- org.svenson.AbstractDynamicProperties
-
- com.cumulocity.model.JSONBase
-
- com.cumulocity.model.Document<T>
-
- All Implemented Interfaces:
Serializable
,org.svenson.DynamicProperties
public abstract class Document<T extends ID> extends JSONBase
Represents the common elements of any modeled entity. Can serialize into and be deserialized from JSON.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.cumulocity.model.JSONBase
JSONBase.JSONGeneratorBuilder, JSONBase.JSONParserBuilder, JSONBase.ReaderJSONCharacterSource
-
-
Field Summary
Fields Modifier and Type Field Description static DynamicPropertiesFilter
acceptAll
-
Fields inherited from class com.cumulocity.model.JSONBase
ID_TYPE_CONVERTER_NAME
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Document()
protected
Document(T id)
protected
Document(T id, String internalId)
protected
Document(T id, String internalId, String revision)
protected
Document(T id, String internalId, String revision, Map<String,Object> fragments)
protected
Document(T id, Map<String,Object> fragments)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
add(Map<String,Object> fragments)
static <T extends ID>
com.google.common.base.Function<? super Document<T>,T>asId()
static <E extends org.svenson.AbstractDynamicProperties>
EcopyDynamicProperties(org.svenson.AbstractDynamicProperties source, E target)
static <E extends org.svenson.AbstractDynamicProperties>
EcopyDynamicProperties(org.svenson.AbstractDynamicProperties source, E target, DynamicPropertiesFilter filter)
static <E extends org.svenson.AbstractDynamicProperties>
EdeepCopyDynamicProperties(org.svenson.AbstractDynamicProperties source, E target)
boolean
equals(Object o)
<C> C
get(Class<C> clazz)
Returns the object whose parameter name is given by clazz, or null if no such property exists, or property cannot be cased to clazz.Object
get(String name)
Returns the object associated with the given property name, or null if no such property exists.<C> C
get(String propertyName, Class<C> asClass)
Object
getFragment(String name)
Returns the object associated with the given property name, or null if no such property exists.T
getId()
String
getInternalId()
Deprecated.String
getRevision()
Deprecated.int
hashCode()
protected <C> C
readObject(Object source, Class<C> asClass)
void
remove(Class<?> clazz)
Remove the fragment whose name is given by clazz if existsvoid
set(Object object)
Sets a property referring to the given object.<C> void
set(Object object, Class<C> 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
setId(T id)
void
setInternalId(String internalId)
Deprecated.void
setRevision(String revision)
Deprecated.String
toString()
-
Methods inherited from class com.cumulocity.model.JSONBase
fromJSON, fromJSON, getJSONGenerator, getJSONGeneratorWithUTF8Encoding, getJSONParser, toJSON
-
-
-
-
Field Detail
-
acceptAll
public static DynamicPropertiesFilter acceptAll
-
-
Constructor Detail
-
Document
protected Document()
-
Document
protected Document(T id)
-
-
Method Detail
-
copyDynamicProperties
public static <E extends org.svenson.AbstractDynamicProperties> E copyDynamicProperties(org.svenson.AbstractDynamicProperties source, E target, DynamicPropertiesFilter filter)
-
copyDynamicProperties
public static <E extends org.svenson.AbstractDynamicProperties> E copyDynamicProperties(org.svenson.AbstractDynamicProperties source, E target)
-
deepCopyDynamicProperties
public static <E extends org.svenson.AbstractDynamicProperties> E deepCopyDynamicProperties(org.svenson.AbstractDynamicProperties source, E target)
-
getId
@JSONProperty(value="id", ignoreIfNull=true) @JSONConverter(type=IDTypeConverter.class) public T getId()
-
setId
public void setId(T id)
-
getInternalId
@Deprecated @JSONProperty(value="_id", ignoreIfNull=true) public String getInternalId()
Deprecated.
-
setInternalId
@Deprecated public void setInternalId(String internalId)
Deprecated.
-
getRevision
@Deprecated @JSONProperty(value="_rev", ignoreIfNull=true) public String getRevision()
Deprecated.
-
setRevision
@Deprecated public void setRevision(String revision)
Deprecated.
-
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:
com.cumulocity.model.Coordinate
then the property name will be:
"com_cumulocity_model_Coordinate"
- 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 <C> void set(Object object, Class<C> 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:
com.cumulocity.model.Coordinate
then the property name will be:
"com_cumulocity_model_Coordinate"
- Parameters:
object
-clazz
-
-
get
public <C> C get(Class<C> clazz)
Returns the object whose parameter name is given by clazz, or null if no such property exists, or property cannot be cased to clazz.- Parameters:
clazz
-- Returns:
- See Also:
set(Object)
-
remove
public void remove(Class<?> clazz)
Remove the fragment whose name is given by clazz if exists- Parameters:
clazz
-
-
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:
-
getFragment
public Object getFragment(String name)
Returns the object associated with the given property name, or null if no such property exists. Such an accessor is required when bean naming conventions are used to discover available properties. Same as a call toget(String name)
- Parameters:
name
-- Returns:
-
-