Class Document<T extends ID>

  • 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
    • Constructor Detail

      • Document

        protected Document()
      • Document

        protected Document​(T id)
      • Document

        protected Document​(T id,
                           String internalId)
      • Document

        protected Document​(T id,
                           String internalId,
                           String revision)
    • 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.
      • 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 -
      • add

        @JSONProperty(ignore=true)
        public void add​(Map<String,​Object> fragments)
      • 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)
      • get

        public <C> C get​(String propertyName,
                         Class<C> asClass)
      • readObject

        protected <C> C readObject​(Object source,
                                   Class<C> asClass)
      • 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 to get(String name)
        Parameters:
        name -
        Returns:
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • asId

        public static <T extends ID> com.google.common.base.Function<? super Document<T>,​T> asId()