com.tenduke.objectmodel
Class TendukeObject

java.lang.Object
  extended by com.tenduke.types.AbstractBindableObject
      extended by com.tenduke.objectmodel.TendukeObject
All Implemented Interfaces:
RelationObject, SerializableObject, java.lang.Cloneable
Direct Known Subclasses:
Account, AgeRange, Article, Category, Comment, Company, Contact, ContactDetails, CreditAccount, CreditAccountEntry, EntryEntrySet, Forum, ForumPost, License, LicensedItem, Media, MediaInfo, ObjectConsumption, ProfileStatus, Property, Relation, Report, ReportDefinition, TendukeSetObject, Vote

public abstract class TendukeObject
extends AbstractBindableObject
implements java.lang.Cloneable

Base class for 10duke object model objects.


Nested Class Summary
static class TendukeObject.CreatedDateComparator<T extends TendukeObject>
           
static class TendukeObject.ModifiedDateComparator<T extends TendukeObject>
           
 
Field Summary
static java.lang.String FIELD_NAME_CREATED
          Field name for created timestamp.
static java.lang.String FIELD_NAME_CREATED_BY_PROFILE
          Name that identifies TendukeObject._createdByProfile field, use case: bind.
static java.lang.String FIELD_NAME_MODIFIED
          Field name for modified timestamp.
static java.lang.String FIELD_NAME_MODIFIED_BY_PROFILE
          Name that identifies TendukeObject._modifiedByProfile field, use case: bind.
static java.lang.String FIELD_NAME_OBJECT_CATEGORY
          Name that identifies TendukeObject object category member, use case: bind.
static java.lang.String FIELD_NAME_OBJECT_CATEGORY_ID
          Name that identifies TendukeObject object category id member.
static java.lang.String FIELD_NAME_OBJECT_CONSUMPTION
          Name that identifies TendukeObject object properties member, use case: bind.
static java.lang.String FIELD_NAME_OBJECT_FEATURES
          Name that identifies TendukeObject object features member, use case: bind.
static java.lang.String FIELD_NAME_OBJECT_PROPERTIES
          Name that identifies TendukeObject object properties member, use case: bind.
static int RELATED_FIELD_COPY_STYLE_DEEP
          Value for determining how related fields are copied / cloned by clone operations: a deep copy of the related fields is set to the copied / cloned object, i.e.
static int RELATED_FIELD_COPY_STYLE_NONE
          Value for determining how related fields are copied / cloned by clone operations: related fields are not copied at all, i.e.
static int RELATED_FIELD_COPY_STYLE_SHALLOW
          Value for determining how related fields are copied / cloned by clone operations: a shallow copy of the related fields is set to the copied / cloned object.
 
Fields inherited from class com.tenduke.types.AbstractBindableObject
FIELD_LENGTH_SHORT_ID, FIELD_NAME_OBJECT_STATE_CHANGE, FIELD_NAME_REPLACES_OBJECT, FIELD_NAME_SHORT_ID, PERMISSION_ACTION_CREATE, PERMISSION_ACTION_DELETE, PERMISSION_ACTION_MODIFY, PERMISSION_ACTION_READ
 
Constructor Summary
TendukeObject()
          Initializes new instance of the TendukeObject class.
 
Method Summary
 void addFeature(FeatureBase feature)
           
 void addObjectConsumption(ObjectConsumption objectConsumption)
          Adds ObjectConsumption object related to object.
 void addObjectProperty(java.lang.String propertyKey, java.lang.String propertyValue)
          Add a Property to the object by Property key and value.
 void addProperty(Property property)
          Add a Property for the object.
 void addRelatedObjectDefault(AbstractBindableObject obj)
           Adds an object to the list of related objects by default relation type.
 void addRelatedObjectDefault(java.lang.String relationName, AbstractBindableObject obj)
           Adds an object to the list of related objects by default relation type and given relation name.
<U extends AbstractBindableObject>
void
addRelatedObjectsDefault(java.util.List<U> objects)
           Adds all objects in the given list to the list of related objects by default relation.
<U extends AbstractBindableObject>
void
addRelatedObjectsDefault(java.lang.String relationName, java.util.List<U> objects)
           Adds all objects in the given list to the list of related objects by default relation type and given relation name.
 java.lang.Object clone()
          Clone this object.
 java.lang.Object clone(int relatedFieldCopyStyle)
          Clone this object.
protected  void copyThis(TendukeObject result)
          Util for use in Object.clone implementation.
protected  void copyThis(TendukeObject result, boolean includeRelated)
          Util for use in Object.clone implementation.
 boolean equals(java.lang.Object rhs)
           Two TendukeObject objects are the same object if they have same id.
protected  void fieldValueToString(java.lang.StringBuilder objectToString, java.lang.String fieldName, java.lang.Object fieldValue)
          Serializes value of object field as part of building String representation of object.
static Property findProperty(java.util.List<Property> properties, Property findProperty)
          Iterates all specified properties and checks if a contained property with key equal to key specified by input property's key exists (findProperty's key).
 Property findProperty(Property findProperty)
          Iterates all instance's properties and checks if a contained property with key equal to key specified by input property's key exists (findProperty's key).
 java.util.Map<java.lang.String,ValueChange> getChangedSerializableFieldValues(java.lang.Object changed)
          Searches through serializable fields (fields annotated with SerializableField annotation) in changed object and checks whether values of fields are different.
 java.util.Date getCreated()
           Gets timestamp when object was created.
 Profile getCreatedBy()
          Gets Profile that created this object.
 void getCreatedByRecursive(java.util.List<Profile> createdByProfiles)
          Recursively adds created by profiles of this object and all related objects to list of created by profiles.
 BindableObjectActor getCreatingActor()
          Gets actor that has created the object.
 java.util.Date getModified()
           Gets timestamp when object has been modified.
 Profile getModifiedBy()
          Gets modifying Profile of this object.
 void getModifiedByRecursive(java.util.List<Profile> modifyingProfiles)
          Recursively adds modifying profiles of this object and all related objects to list of modifying profiles.
 BindableObjectActor getModifyingActor()
          Gets actor that has modified the object.
 Category getObjectCategory()
          Gets the objects category.
 java.util.UUID getObjectCategoryId()
          Get object's category id.
 java.util.List<ObjectConsumption> getObjectConsumption()
          Getter for object consumption.
 java.lang.String getObjectContractName()
           Checks if this object is an instance of class that has SerializableClass annotation and if so read the object contract name.
static java.lang.String getObjectContractName(java.lang.Class<?> serializableClass)
           Checks if the specified class is annotated with SerializableClass and if so read the object contract name.
 FeatureBase getObjectFeature(java.lang.String key)
          Get an object feature by name.
 java.util.List<FeatureBase> getObjectFeatures()
           
 java.util.List<Property> getObjectProperties()
           
 Property getObjectProperty(java.lang.String key)
           
 java.lang.String getObjectPropertyValue(java.lang.String key)
           
<T extends AbstractBindableObject>
java.util.List<T>
getRelatedObjectsDefault(java.lang.Class<T> relatedObjectType)
           Gets objects related to this object with default relation type.
<T extends AbstractBindableObject>
java.util.List<T>
getRelatedObjectsDefault(java.lang.String relationName, java.lang.Class<T> relatedObjectType)
           Gets objects related to this object with default relation type.
 int hashCode()
          Since two TendukeObjects are same if they have same id, getId().hashCode() can be used also as the objects hashcode.
static java.util.UUID idFromString(java.lang.String id)
          Parse id from string.
 void merge(TendukeObject nullFieldValuesFromObject)
          Search SerializableField annotated fields of the object and check whether field value is null.
 java.util.Map<java.lang.String,FeatureBase> objectFeaturesToMap()
          Utility to convert objects feature list to Map.
 java.util.Map<java.lang.String,Property> objectPropertiesToMap()
          Utility to convert objects property list to Map.
static
<T extends TendukeObject>
java.util.List<T>
orderByCreatedDate(java.util.List<T> objects, boolean ascending)
          Order TendukeObject descendants by their created by date.
static
<T extends TendukeObject>
java.util.List<T>
orderByModifiedDate(java.util.List<T> objects, boolean ascending)
          Order TendukeObject descendants by their created by date.
 void setCreated(java.util.Date created)
           Sets timestamp when object was created.
 void setCreatedBy(Profile createdBy)
          Sets Profile that created this object.
static void setCreatedByRecursive(AbstractBindableObject object, BindableObjectActor createdBy)
          Recursively sets created by actor to an object model hierarchy (the given object and all objects that can be accessed via FieldName annotated fields).
 void setCreatedByRecursive(Profile createdBy)
          Recursively sets created by profile to an object model hierarchy (this object and all objects that can be accessed via FieldName annotated fields).
 void setCreatingActor(BindableObjectActor actor)
          Sets actor that has created the object.
 void setModified(java.util.Date modified)
           Sets timestamp when object has been modified.
static
<T extends AbstractBindableObject>
void
setModifiedBy(java.util.List<T> objects, Profile modifiedBy)
          Setting modified by profile for a list of objects.
 void setModifiedBy(Profile modifiedBy)
          Sets modifying Profile of this object.
static void setModifiedByRecursive(AbstractBindableObject object, BindableObjectActor modifiedBy)
          Recursively sets modified by actor to an object model hierarchy (the given object and all objects that can be accessed via FieldName annotated fields).
static
<T extends AbstractBindableObject>
void
setModifiedByRecursive(java.util.List<T> objects, Profile modifiedBy)
          Setting modified by profile recursively for a list of objects.
 void setModifiedByRecursive(Profile modifiedBy)
          Recursively sets modified by profile to an object model hierarchy (this object and all objects that can be accessed via FieldName annotated fields).
 void setModifyingActor(BindableObjectActor actor)
          Sets actor that has modified the object.
 void setObjectCategory(Category category)
          Sets object category and also sets category object's parent to this.
 void setObjectCategoryId(java.util.UUID categoryId)
          Set object's category id.
 void setObjectConsumption(java.util.List<ObjectConsumption> objectConsumption)
          Sets list of ObjectConsumption objects related to object.
 void setObjectFeatures(java.util.List<FeatureBase> objectFeatures)
           
 void setObjectProperties(java.util.List<Property> objectProperties)
           
 void setRelatedObjectsDefault(java.util.List<AbstractBindableObject> objects)
           Sets the list of related objects with default relation type, replacing earlier related objects for the relation.
 void setRelatedObjectsDefault(java.lang.String relationName, java.util.List<AbstractBindableObject> objects)
           Sets the list of related objects with default relation type and given relation name, replacing earlier related objects for the relation.
 java.lang.String toString()
          Returns a String representation of the object.
 
Methods inherited from class com.tenduke.types.AbstractBindableObject
addRelatedObject, addRelatedObject, addRelatedObject, addRelatedObject, addRelatedObjects, addRelatedObjects, addRelatedObjects, copyThis, getFirstObjectById, getGrantedObjectPermissionActions, getId, getParent, getParentBindableType, getParentBindableTypeChain, getParentId, getParentNode, getParentType, getRelatedObjectList, getRelatedObjectList, getRelatedObjectLists, getRelatedObjectLists, getRelatedObjects, getRelatedObjects, getRelatedObjects, getRelatedObjects, getRelatedObjects, getRelatedObjects, getRelationAttributeObject, getRelationField, getRelationHandler, getRelationType, getReplaces, getShortId, getStateChange, hasRelatedObjects, hasRelatedObjects, resolveParentBindableType, resolveParentBindableTypeByTreeParent, setGrantedObjectPermissionActions, setId, setParent, setParent, setParentBindableType, setParentNode, setRelatedObjectList, setRelatedObjects, setRelatedObjects, setRelatedObjects, setRelatedObjects, setRelatedObjects, setRelatedObjects, setRelationAttributeObject, setRelationHandler, setReplaces, setShortId, setStateChange
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

FIELD_NAME_CREATED

public static final java.lang.String FIELD_NAME_CREATED
Field name for created timestamp.

See Also:
Constant Field Values

FIELD_NAME_CREATED_BY_PROFILE

public static final java.lang.String FIELD_NAME_CREATED_BY_PROFILE
Name that identifies TendukeObject._createdByProfile field, use case: bind.

See Also:
Constant Field Values

FIELD_NAME_MODIFIED

public static final java.lang.String FIELD_NAME_MODIFIED
Field name for modified timestamp.

See Also:
Constant Field Values

FIELD_NAME_MODIFIED_BY_PROFILE

public static final java.lang.String FIELD_NAME_MODIFIED_BY_PROFILE
Name that identifies TendukeObject._modifiedByProfile field, use case: bind.

See Also:
Constant Field Values

FIELD_NAME_OBJECT_CATEGORY

public static final java.lang.String FIELD_NAME_OBJECT_CATEGORY
Name that identifies TendukeObject object category member, use case: bind.

See Also:
Constant Field Values

FIELD_NAME_OBJECT_CATEGORY_ID

public static final java.lang.String FIELD_NAME_OBJECT_CATEGORY_ID
Name that identifies TendukeObject object category id member.

See Also:
Constant Field Values

FIELD_NAME_OBJECT_CONSUMPTION

public static final java.lang.String FIELD_NAME_OBJECT_CONSUMPTION
Name that identifies TendukeObject object properties member, use case: bind.

See Also:
Constant Field Values

FIELD_NAME_OBJECT_FEATURES

public static final java.lang.String FIELD_NAME_OBJECT_FEATURES
Name that identifies TendukeObject object features member, use case: bind.

See Also:
Constant Field Values

FIELD_NAME_OBJECT_PROPERTIES

public static final java.lang.String FIELD_NAME_OBJECT_PROPERTIES
Name that identifies TendukeObject object properties member, use case: bind.

See Also:
Constant Field Values

RELATED_FIELD_COPY_STYLE_DEEP

public static final int RELATED_FIELD_COPY_STYLE_DEEP
Value for determining how related fields are copied / cloned by clone operations: a deep copy of the related fields is set to the copied / cloned object, i.e. each related object is also cloned.

See Also:
Constant Field Values

RELATED_FIELD_COPY_STYLE_NONE

public static final int RELATED_FIELD_COPY_STYLE_NONE
Value for determining how related fields are copied / cloned by clone operations: related fields are not copied at all, i.e. value of related field is not touched in the copied / cloned object.

See Also:
Constant Field Values

RELATED_FIELD_COPY_STYLE_SHALLOW

public static final int RELATED_FIELD_COPY_STYLE_SHALLOW
Value for determining how related fields are copied / cloned by clone operations: a shallow copy of the related fields is set to the copied / cloned object.

See Also:
Constant Field Values
Constructor Detail

TendukeObject

public TendukeObject()
Initializes new instance of the TendukeObject class.

Method Detail

addFeature

public void addFeature(FeatureBase feature)

addObjectConsumption

public void addObjectConsumption(ObjectConsumption objectConsumption)
Adds ObjectConsumption object related to object.

Parameters:
objectConsumption - ObjectConsumption object related to object to add.

addObjectProperty

public void addObjectProperty(java.lang.String propertyKey,
                              java.lang.String propertyValue)
Add a Property to the object by Property key and value.

Parameters:
propertyKey - Property key.
propertyValue - Property value.

addProperty

public void addProperty(Property property)
Add a Property for the object.

Parameters:
property - The Property to add.

addRelatedObjectDefault

public void addRelatedObjectDefault(AbstractBindableObject obj)

Adds an object to the list of related objects by default relation type.

This overload uses Relation as default relation type.

This overload creates relation description (instance of ObjectRelation) with given relation type and null (default) relation name.

Methods of this class that handle related objects can be used for dynamic relations between any objects that derive from AbstractBindableObject. Derived classes may also explicitly define relations.

Parameters:
obj - Object to be added to the relation.

addRelatedObjectDefault

public void addRelatedObjectDefault(java.lang.String relationName,
                                    AbstractBindableObject obj)

Adds an object to the list of related objects by default relation type and given relation name.

This overload uses Relation as default relation type.

Methods of this class that handle related objects can be used for dynamic relations between any objects that derive from AbstractBindableObject. Derived classes may also explicitly define relations.

Parameters:
relationName - Name of the relation.
obj - Object to be added to the relation.

addRelatedObjectsDefault

public <U extends AbstractBindableObject> void addRelatedObjectsDefault(java.util.List<U> objects)

Adds all objects in the given list to the list of related objects by default relation.

This overload uses Relation as default relation type.

This overload creates relation description (instance of ObjectRelation) with given relation type and null (default) relation name.

Methods of this class that handle related objects can be used for dynamic relations between any objects that derive from AbstractBindableObject. Derived classes may also explicitly define relations.

Parameters:
objects - List of objects to be added to the relation.

addRelatedObjectsDefault

public <U extends AbstractBindableObject> void addRelatedObjectsDefault(java.lang.String relationName,
                                                                        java.util.List<U> objects)

Adds all objects in the given list to the list of related objects by default relation type and given relation name.

This overload uses Relation as default relation type.

Methods of this class that handle related objects can be used for dynamic relations between any objects that derive from AbstractBindableObject. Derived classes may also explicitly define relations.

Parameters:
relationName - Name of the relation.
objects - List of objects to be added to the relation.

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Clone this object. This base class provides default implementation, derived classes may override this method e.g. to improve performance. The default implementation relies on SerializableField annotations, recursively traversing the object for SerializableField annotated fields of object's class and base classes. This overload creates shallow copies of relation fields, i.e. related objects are set without cloning to the cloned object.

Overrides:
clone in class java.lang.Object
Returns:
Cloned instance of this object.
Throws:
java.lang.CloneNotSupportedException - Exception not explicitly thrown, method is implemented.

clone

public java.lang.Object clone(int relatedFieldCopyStyle)
                       throws java.lang.CloneNotSupportedException
Clone this object. This base class provides default implementation, derived classes may override this method e.g. to improve performance. The default implementation relies on SerializableField annotations, recursively traversing the object for SerializableField annotated fields of object's class and base classes.

Parameters:
relatedFieldCopyStyle - Style how fields with SerializableField.relation != RELATION_NONE are copied. Use RELATED_FIELD_COPY_STYLE constants defined by this class for values of this parameter.
Returns:
Cloned instance of this object.
Throws:
java.lang.CloneNotSupportedException - Exception not explicitly thrown, method is implemented.

copyThis

protected void copyThis(TendukeObject result)
Util for use in Object.clone implementation.


copyThis

protected void copyThis(TendukeObject result,
                        boolean includeRelated)
Util for use in Object.clone implementation.


equals

public boolean equals(java.lang.Object rhs)

Two TendukeObject objects are the same object if they have same id.

DO NOT override this in sub classes. It is a system contract that equals between two objects is based on the object Id fields equality measure.

Overrides:
equals in class java.lang.Object
Parameters:
rhs - Object to compare for equality.
Returns:
true if the two TendukeObjects have same id

fieldValueToString

protected void fieldValueToString(java.lang.StringBuilder objectToString,
                                  java.lang.String fieldName,
                                  java.lang.Object fieldValue)
Serializes value of object field as part of building String representation of object.

Parameters:
objectToString - StringBuilder where String representation of the object is written.
fieldName - Name of field to serialize.
fieldValue - Value of the field to serialize.

findProperty

public static Property findProperty(java.util.List<Property> properties,
                                    Property findProperty)
Iterates all specified properties and checks if a contained property with key equal to key specified by input property's key exists (findProperty's key).

Parameters:
properties - List of properties in which to search for a specific key.
findProperty - Input property that defines key, which is used to find property in list.
Returns:
Handle to Property in list if found by findProperty's key.

findProperty

public Property findProperty(Property findProperty)
Iterates all instance's properties and checks if a contained property with key equal to key specified by input property's key exists (findProperty's key).

Parameters:
findProperty - Input property, which is used to access reference key value
Returns:
Handle to property in instance's properties if found by key specified by input findProperty's key.

getChangedSerializableFieldValues

public java.util.Map<java.lang.String,ValueChange> getChangedSerializableFieldValues(java.lang.Object changed)
Searches through serializable fields (fields annotated with SerializableField annotation) in changed object and checks whether values of fields are different.

Parameters:
changed - The changed object to compare against baseline.
Returns:
HashMap where keys are names of changed SerializableField annotated fields, and values are ValueChange objects that contain baseline (from this object) and changed values of the changed fields.

getCreated

public java.util.Date getCreated()

Gets timestamp when object was created.

An object's created field is intended to mark a technical timestamp when the object has been created. Users of the object model may decide if the field has relevance from business logical point of view.

Specified by:
getCreated in class AbstractBindableObject
Returns:
timestamp when object was created.

getCreatedBy

public Profile getCreatedBy()
Gets Profile that created this object.

Returns:
Profile that created this object.

getCreatedByRecursive

public void getCreatedByRecursive(java.util.List<Profile> createdByProfiles)
Recursively adds created by profiles of this object and all related objects to list of created by profiles.

Parameters:
createdByProfiles - List where created by profiles are added.

getCreatingActor

public BindableObjectActor getCreatingActor()
Gets actor that has created the object.

Specified by:
getCreatingActor in class AbstractBindableObject
Returns:
actor that has created the object.

getModified

public java.util.Date getModified()

Gets timestamp when object has been modified.

An object's modified field is intended to mark a technical timestamp when the object has been last changed. The change / update may be of no relevance from business logical point of view (Users of the object model may decide if the field has relevance from business logical point of view).

Specified by:
getModified in class AbstractBindableObject
Returns:
timestamp when object has been modified.

getModifiedBy

public Profile getModifiedBy()
Gets modifying Profile of this object.

Returns:
Modifying Profile of this object.

getModifiedByRecursive

public void getModifiedByRecursive(java.util.List<Profile> modifyingProfiles)
Recursively adds modifying profiles of this object and all related objects to list of modifying profiles.

Parameters:
modifyingProfiles - List where modifying profiles are added.

getModifyingActor

public BindableObjectActor getModifyingActor()
Gets actor that has modified the object.

Specified by:
getModifyingActor in class AbstractBindableObject
Returns:
actor that has modified the object.

getObjectCategory

public Category getObjectCategory()
Gets the objects category.

Returns:
Object category

getObjectCategoryId

public java.util.UUID getObjectCategoryId()
Description copied from class: AbstractBindableObject
Get object's category id. Override this method to actually implement support for category id's (this is an empty method).

Overrides:
getObjectCategoryId in class AbstractBindableObject
Returns:
This default implementation always returns null.

getObjectConsumption

public java.util.List<ObjectConsumption> getObjectConsumption()
Getter for object consumption.

Returns:
List of ObjectConsumption objects related to object.

getObjectContractName

public java.lang.String getObjectContractName()

Checks if this object is an instance of class that has SerializableClass annotation and if so read the object contract name.

Calls getObjectContractName(java.lang.Class) with this.getClass() argument. See the getObjectContractName(...) method documentation for further details.

Returns:
Object contract name

getObjectContractName

public static java.lang.String getObjectContractName(java.lang.Class<?> serializableClass)

Checks if the specified class is annotated with SerializableClass and if so read the object contract name.

The object contract name of an object is the name attribute of a SerializableClass annotation of the class the object is instance of. If the name attribute is not set, then the object contract name is a simple name of the class.

Examples:

  1. Objects of this class have MyObjectContractname as the object contract name.
        @SerializableClass(name = "MyObjectContractname")
        public class SomeClass {...}
  2. Objects of this class have SomeClass as the object contract name.
        @SerializableClass
        public class SomeClass {...}
  3. Objects of this class have don't have object contract name defined, i.e., null is returned if an object contract name is asked for.
        public class SomeClass {...}

Parameters:
serializableClass - The class to be checked and analyzed
Returns:
Object contract name defined by SerializableClass annotation or null if the class is not annotated with SerializableClass.

getObjectFeature

public FeatureBase getObjectFeature(java.lang.String key)
Get an object feature by name.

Parameters:
key - The name for the feature to look up
Returns:
Instance of object feature by given name or null if not found

getObjectFeatures

public java.util.List<FeatureBase> getObjectFeatures()

getObjectProperties

public java.util.List<Property> getObjectProperties()

getObjectProperty

public Property getObjectProperty(java.lang.String key)

getObjectPropertyValue

public java.lang.String getObjectPropertyValue(java.lang.String key)

getRelatedObjectsDefault

public <T extends AbstractBindableObject> java.util.List<T> getRelatedObjectsDefault(java.lang.Class<T> relatedObjectType)

Gets objects related to this object with default relation type.

This overload uses Relation as default relation type.

This overload creates relation description (instance of ObjectRelation) with given relation type and null (default) relation name.

Methods of this class that handle related objects can be used for dynamic relations between any objects that derive from AbstractBindableObject. Derived classes may also explicitly define relations.

Type Parameters:
T - Type of related objects.
Parameters:
relatedObjectType - Type of related objects.
Returns:
List of related objects by default relation.

getRelatedObjectsDefault

public <T extends AbstractBindableObject> java.util.List<T> getRelatedObjectsDefault(java.lang.String relationName,
                                                                                     java.lang.Class<T> relatedObjectType)

Gets objects related to this object with default relation type.

This overload uses Relation as default relation type.

Methods of this class that handle related objects can be used for dynamic relations between any objects that derive from AbstractBindableObject. Derived classes may also explicitly define relations.

Type Parameters:
T - Type of related objects.
Parameters:
relationName - Name of the relation.
relatedObjectType - Type of related objects.
Returns:
List of related objects by given relation name.

hashCode

public int hashCode()
Since two TendukeObjects are same if they have same id, getId().hashCode() can be used also as the objects hashcode.

Overrides:
hashCode in class java.lang.Object
Returns:
Object hash code

idFromString

public static java.util.UUID idFromString(java.lang.String id)
Parse id from string. The implementation traps IllegalArgumentException for using UUIDUtils.parseUUID(java.lang.String) and logs errors as very verbose warning level log entries using Logger.

Parameters:
id - UUID in string format. Argument is checked to not be null.
Returns:
UUID for successful parsing or null in other cases.

merge

public void merge(TendukeObject nullFieldValuesFromObject)
Search SerializableField annotated fields of the object and check whether field value is null. For null field values, set value from the other object.

Parameters:
nullFieldValuesFromObject - Object whose field values are used to set values to SerializableField annotated fields of this object.

objectFeaturesToMap

public java.util.Map<java.lang.String,FeatureBase> objectFeaturesToMap()
Utility to convert objects feature list to Map.

Returns:
Instance of Map that holds all features mapped by feature key to feature instance (returns null for null or empty property list).

objectPropertiesToMap

public java.util.Map<java.lang.String,Property> objectPropertiesToMap()
Utility to convert objects property list to Map.

Returns:
Instance of Map that holds all properties mapped by property key to property instance (returns null for null or empty property list).

orderByCreatedDate

public static <T extends TendukeObject> java.util.List<T> orderByCreatedDate(java.util.List<T> objects,
                                                                             boolean ascending)
Order TendukeObject descendants by their created by date.

Type Parameters:
T - TendukeObject derived class
Parameters:
objects - List to be ordered
ascending - If true, ordered in ascending order, otherwise in descending order
Returns:
Returns the ordered list

orderByModifiedDate

public static <T extends TendukeObject> java.util.List<T> orderByModifiedDate(java.util.List<T> objects,
                                                                              boolean ascending)
Order TendukeObject descendants by their created by date.

Type Parameters:
T - TendukeObject derived class
Parameters:
objects - List to be ordered
ascending - If true, ordered in ascending order, otherwise in descending order
Returns:
Returns the ordered list

setCreated

public void setCreated(java.util.Date created)

Sets timestamp when object was created.

An object's created field is intended to mark a technical timestamp when the object has been created. Users of the object model may decide if the field has relevance from business logical point of view.

Specified by:
setCreated in class AbstractBindableObject
Parameters:
created - timestamp when object was created.

setCreatedBy

public void setCreatedBy(Profile createdBy)
Sets Profile that created this object.

Parameters:
createdBy - Profile that created this object.

setCreatedByRecursive

public static void setCreatedByRecursive(AbstractBindableObject object,
                                         BindableObjectActor createdBy)
Recursively sets created by actor to an object model hierarchy (the given object and all objects that can be accessed via FieldName annotated fields).

Parameters:
object - Object for which creating actor is set recursively.
createdBy - Creating actor for the object.

setCreatedByRecursive

public void setCreatedByRecursive(Profile createdBy)
Recursively sets created by profile to an object model hierarchy (this object and all objects that can be accessed via FieldName annotated fields).

Parameters:
createdBy - Creating Profile of this object.

setCreatingActor

public void setCreatingActor(BindableObjectActor actor)
Sets actor that has created the object.

Specified by:
setCreatingActor in class AbstractBindableObject
Parameters:
actor - that has created the object

setModified

public void setModified(java.util.Date modified)

Sets timestamp when object has been modified.

An object's modified field is intended to mark a technical timestamp when the object has been last changed. The change / update may be of no relevance from business logical point of view (Users of the object model may decide if the field has relevance from business logical point of view).

Specified by:
setModified in class AbstractBindableObject
Parameters:
modified - timestamp when object has been modified.

setModifiedBy

public static <T extends AbstractBindableObject> void setModifiedBy(java.util.List<T> objects,
                                                                    Profile modifiedBy)
Setting modified by profile for a list of objects.

Parameters:
objects - The objects for which to set the modifiedBy profile
modifiedBy - The modifier profile

setModifiedBy

public void setModifiedBy(Profile modifiedBy)
Sets modifying Profile of this object.

Parameters:
modifiedBy - Modifying Profile of this object.

setModifiedByRecursive

public static void setModifiedByRecursive(AbstractBindableObject object,
                                          BindableObjectActor modifiedBy)
Recursively sets modified by actor to an object model hierarchy (the given object and all objects that can be accessed via FieldName annotated fields).

Parameters:
object - Object for which modifying actor is set recursively.
modifiedBy - Modifying actor for the object.

setModifiedByRecursive

public static <T extends AbstractBindableObject> void setModifiedByRecursive(java.util.List<T> objects,
                                                                             Profile modifiedBy)
Setting modified by profile recursively for a list of objects.

Parameters:
objects - The objects for which to set the modifiedBy profile
modifiedBy - The modifier profile

setModifiedByRecursive

public void setModifiedByRecursive(Profile modifiedBy)
Recursively sets modified by profile to an object model hierarchy (this object and all objects that can be accessed via FieldName annotated fields).

Parameters:
modifiedBy - Modifying Profile of this object.

setModifyingActor

public void setModifyingActor(BindableObjectActor actor)
Sets actor that has modified the object.

Specified by:
setModifyingActor in class AbstractBindableObject
Parameters:
actor - actor that has modified the object.

setObjectCategory

public void setObjectCategory(Category category)
Sets object category and also sets category object's parent to this.

Parameters:
category - Category

setObjectCategoryId

public void setObjectCategoryId(java.util.UUID categoryId)
Description copied from class: AbstractBindableObject
Set object's category id. This default implementation does nothing (empty method), override this method to actually implement support for category id's.

Overrides:
setObjectCategoryId in class AbstractBindableObject
Parameters:
categoryId - The category id to set.

setObjectConsumption

public void setObjectConsumption(java.util.List<ObjectConsumption> objectConsumption)
Sets list of ObjectConsumption objects related to object.

Parameters:
objectConsumption - list of ObjectConsumption objects related to object.

setObjectFeatures

public void setObjectFeatures(java.util.List<FeatureBase> objectFeatures)

setObjectProperties

public void setObjectProperties(java.util.List<Property> objectProperties)

setRelatedObjectsDefault

public void setRelatedObjectsDefault(java.util.List<AbstractBindableObject> objects)

Sets the list of related objects with default relation type, replacing earlier related objects for the relation.

This overload uses Relation as default relation type.

This overload creates relation description (instance of ObjectRelation) with given relation type and null (default) relation name.

Methods of this class that handle related objects can be used for dynamic relations between any objects that derive from AbstractBindableObject. Derived classes may also explicitly define relations.

Parameters:
objects - List of objects to be set as related objects with default relation.

setRelatedObjectsDefault

public void setRelatedObjectsDefault(java.lang.String relationName,
                                     java.util.List<AbstractBindableObject> objects)

Sets the list of related objects with default relation type and given relation name, replacing earlier related objects for the relation.

This overload uses Relation as default relation type.

Methods of this class that handle related objects can be used for dynamic relations between any objects that derive from AbstractBindableObject. Derived classes may also explicitly define relations.

Parameters:
relationName - Name of the relation.
objects - List of objects to be set as related objects with default relation.

toString

public java.lang.String toString()
Returns a String representation of the object.

Overrides:
toString in class java.lang.Object
Returns:
String representation of the object.