com.tenduke.types
Class AbstractBindableObject

java.lang.Object
  extended by com.tenduke.types.AbstractBindableObject
All Implemented Interfaces:
RelationObject, SerializableObject
Direct Known Subclasses:
AbstractReportEntry, ObjectCount, ShortId, TendukeObject, WebLogEntry

public abstract class AbstractBindableObject
extends java.lang.Object
implements SerializableObject, RelationObject

Base class for classes that support binding / persistent storage: e.g. storing in relation database using Jdbc, java persistence or similar.

Bindable objects features:

See Also:
ObjectStateChange, SerializableObject

Field Summary
static int FIELD_LENGTH_SHORT_ID
          Field length for the short, human-friendly id.
static java.lang.String FIELD_NAME_OBJECT_STATE_CHANGE
          Constant that names field for defining object state change.
static java.lang.String FIELD_NAME_REPLACES_OBJECT
           Constant that names field that holds object that is replaced in a model state change.
static java.lang.String FIELD_NAME_SHORT_ID
          Field name for the short, human-friendly id.
static long PERMISSION_ACTION_CREATE
          Permission action required for creating new objects.
static long PERMISSION_ACTION_DELETE
          Permission action required for deleting objects.
static long PERMISSION_ACTION_MODIFY
          Permission action required for modifying existing objects.
static long PERMISSION_ACTION_READ
          Permission action required for reading / querying objects.
 
Constructor Summary
AbstractBindableObject()
           
 
Method Summary
<T extends AbstractBindableObject,U extends AbstractBindableObject>
void
addRelatedObject(java.lang.Class<U> relationType, java.lang.String relationName, T obj)
           Adds an object to the list of related objects by given relation type and relation name.
<T extends AbstractBindableObject,U extends AbstractBindableObject>
void
addRelatedObject(java.lang.Class<U> relationType, T obj)
           Adds an object to the list of related objects by given relation type.
<T extends AbstractBindableObject,U extends AbstractBindableObject>
void
addRelatedObject(ObjectRelation<T,U> relation, T obj)
           Adds an object to the list of related objects by given relation.
<T extends RelationObject,U extends AbstractBindableObject>
void
addRelatedObject(U relationAttributeObject, java.lang.String relationName, T obj)
           Adds an object to the list of related objects by given relation type and relation name.
<T extends AbstractBindableObject,U extends AbstractBindableObject>
void
addRelatedObjects(java.lang.Class<U> relationType, java.util.List<T> objects)
           Adds all objects in the given list to the list of related objects by given relation type.
<T extends AbstractBindableObject,U extends AbstractBindableObject>
void
addRelatedObjects(java.lang.Class<U> relationType, java.lang.String relationName, java.util.List<T> objects)
           Adds all objects in the given list to the list of related objects by given relation type and relation name.
<T extends AbstractBindableObject,U extends AbstractBindableObject>
void
addRelatedObjects(ObjectRelation<T,U> relation, java.util.List<T> objects)
           Adds all objects in the given list to the list of related objects by given relation.
protected  void copyThis(AbstractBindableObject result)
          Utility for use in Object.clone implementation.
abstract  java.util.Date getCreated()
          Get created timestamp.
abstract  BindableObjectActor getCreatingActor()
          Get actor that has created the object.
static
<U extends AbstractBindableObject>
U
getFirstObjectById(java.util.List<U> objects, java.util.UUID id)
          Gets an object from the given list of objects by id.
 java.lang.Long getGrantedObjectPermissionActions()
          Gets permission actions granted for handling the object in current context.
abstract  java.util.UUID getId()
          Gets object's unique id.
abstract  java.util.Date getModified()
          Gets the timestamp when object was modified.
abstract  BindableObjectActor getModifyingActor()
          Get actor that has modified the object.
 java.util.UUID getObjectCategoryId()
          Get object's category id.
 AbstractBindableObject getParent()
          Gets this objects parent.
 java.lang.String getParentBindableType()
          Gets type to be used as parent bindable object.
 java.util.List<java.lang.String> getParentBindableTypeChain()
          Follows parent chain of this object and for each parent found, adds its getParentBindableType() to the list, starting from this object.
 java.util.UUID getParentId()
          Gets id of parent object.
 SerializableObject getParentNode()
          Gets this objects parent object.
 java.lang.String getParentType()
          Gets type of parent object as fully qualified class name.
 java.util.List<AbstractBindableObject> getRelatedObjectList()
          Gets flat list of all objects related to this object via old-style static named relations.
 java.util.List<AbstractBindableObject> getRelatedObjectList(java.lang.String relationName)
          Gets list of related objects with given old-style static relation name.
 java.util.Map<java.lang.String,java.util.List<AbstractBindableObject>> getRelatedObjectLists()
          Gets old-style static relations for this object.
static java.util.Map<java.lang.String,java.util.List<AbstractBindableObject>> getRelatedObjectLists(AbstractBindableObject object)
          Gets old-style static relations for the given object.
 java.util.Map<ObjectRelation<? extends AbstractBindableObject,? extends AbstractBindableObject>,java.util.List<? extends AbstractBindableObject>> getRelatedObjects()
           Gets objects related to this object.
<T extends AbstractBindableObject,U extends AbstractBindableObject>
java.util.List<T>
getRelatedObjects(java.lang.Class<U> relationType, java.lang.Class<T> relatedObjectType)
           Gets objects related to this object with given relation type.
<T extends AbstractBindableObject,U extends AbstractBindableObject>
java.util.List<T>
getRelatedObjects(java.lang.Class<U> relationType, java.lang.String relationName, java.lang.Class<T> relatedObjectType)
           Gets objects related to this object with given relation type and relation name.
<T extends AbstractBindableObject,U extends AbstractBindableObject>
java.util.List<T>
getRelatedObjects(ObjectRelation<T,U> relation)
           Gets objects related to this object with given relation.
 java.util.List<? extends AbstractBindableObject> getRelatedObjects(java.lang.String relationName)
           Gets objects related to this object with given relation relation name and any relation type.
<T extends AbstractBindableObject>
java.util.List<T>
getRelatedObjects(java.lang.String relationName, java.lang.Class<T> relatedObjectType)
           Gets objects related to this object with given relation relation name and any relation type.
<U> U
getRelationAttributeObject(java.lang.Class<U> relationAttributeObjectType)
          Gets object that is an attribute of a relation from another object to this object.
<T> T
getRelationField(java.lang.Class<T> fieldValueClass, java.lang.String fieldName)
          Gets value of a field in relation attribute object.
 ObjectRelationHandler getRelationHandler()
          Gets handler that encapsulates object dynamic relations.
 java.lang.Class<? extends AbstractBindableObject> getRelationType(java.lang.String relationName)
           Gets type of relation with given relation name.
 AbstractBindableObject getReplaces()
           Handle to object that is replaced in a model state change.
 java.lang.String getShortId()
          Gets short id of the object.
 java.lang.Integer getStateChange()
          Gets instance member for state change flag (default value for an object instance is ObjectStateChange.UNDEFINED).
<T extends AbstractBindableObject,U extends AbstractBindableObject>
boolean
hasRelatedObjects(ObjectRelation<T,U> relation)
          Does this object have related objects with given relation.
 boolean hasRelatedObjects(java.lang.String relationName)
          Does this object have related objects with given relation name.
protected  void resolveParentBindableType()
          Resolves and sets getParentBindableType() based on currently set parent object.
protected  java.lang.String resolveParentBindableTypeByTreeParent()
           Gets parent bindable object type for the object by iterating parents in the current object tree.
abstract  void setCreated(java.util.Date created)
          Set created timestamp.
abstract  void setCreatingActor(BindableObjectActor actor)
          Set actor that has created the object.
 void setGrantedObjectPermissionActions(java.lang.Long grantedObjectPermissionActions)
          Sets permission actions granted for handling the object in current context.
abstract  void setId(java.util.UUID identifier)
          Sets object's unique id.
abstract  void setModified(java.util.Date modified)
          Set modified timestamp.
abstract  void setModifyingActor(BindableObjectActor actor)
          Set actor that has modified the object.
 void setObjectCategoryId(java.util.UUID categoryId)
          Set object's category id.
 void setParent(AbstractBindableObject parent)
          Set parent object, i.e.
static void setParent(java.util.List<? extends AbstractBindableObject> objects, AbstractBindableObject parent)
          Set parent object for each object in list, i.e.
 void setParentBindableType(java.lang.String parentBindableType)
          Sets type to be used as parent bindable object.
 void setParentNode(SerializableObject parent)
          Set parent object, i.e.
 void setRelatedObjectList(java.lang.String relationName, java.util.List<AbstractBindableObject> relationList)
          Sets value of old-style static @FieldName(relationName) annotated field in this object to relationList.
<T extends AbstractBindableObject>
void
setRelatedObjects(java.lang.Class<? extends AbstractBindableObject> relationType, java.util.List<T> objects)
           Sets the list of related objects with given relation type, replacing earlier related objects for the relation.
<T extends AbstractBindableObject>
void
setRelatedObjects(java.lang.Class<? extends AbstractBindableObject> relationType, java.lang.String relationName, T object)
           Sets the list of related objects with given relation type and relation name, replacing earlier related objects for the relation, to the single object.
<T extends AbstractBindableObject>
void
setRelatedObjects(java.lang.Class<? extends AbstractBindableObject> relationType, T object)
           Sets the list of related objects with given relation type, replacing earlier related objects for the relation, to the single object.
<T extends AbstractBindableObject,U extends AbstractBindableObject>
void
setRelatedObjects(java.lang.Class<U> relationType, java.lang.String relationName, java.util.List<T> objects)
           Sets the list of related objects with given relation type and relation name, replacing earlier related objects for the relation.
<T extends AbstractBindableObject,U extends AbstractBindableObject>
void
setRelatedObjects(ObjectRelation<T,U> relation, java.util.List<T> objects)
           Sets the list of related objects with given relation, replacing earlier related objects for the relation.
<T extends AbstractBindableObject,U extends AbstractBindableObject>
void
setRelatedObjects(ObjectRelation<T,U> relation, T object)
           Sets the list of related objects with given relation, replacing earlier related objects for the relation, to the single object.
<U> void
setRelationAttributeObject(U relationAttributeObject)
          Gets object that is an attribute of a relation from another object to this object.
 void setRelationHandler(ObjectRelationHandler relationHandler)
          Sets handler that encapsulates object dynamic relations.
 void setReplaces(AbstractBindableObject replaces)
           Handle to object that is replaced in a model state change.
 void setShortId(java.lang.String shortId)
          Sets short id of the object.
 void setStateChange(java.lang.Integer stateChange)
          Sets instance member for state change flag (default value for an object instance is ObjectStateChange.UNDEFINED).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FIELD_LENGTH_SHORT_ID

public static final int FIELD_LENGTH_SHORT_ID
Field length for the short, human-friendly id.

See Also:
Constant Field Values

FIELD_NAME_OBJECT_STATE_CHANGE

public static final java.lang.String FIELD_NAME_OBJECT_STATE_CHANGE
Constant that names field for defining object state change. State change most commonly applies to relations. State change constants are declared and defined in: ObjectStateChange:

See Also:
Constant Field Values

FIELD_NAME_REPLACES_OBJECT

public static final java.lang.String FIELD_NAME_REPLACES_OBJECT

Constant that names field that holds object that is replaced in a model state change.

Requirements:

See Also:
Constant Field Values

FIELD_NAME_SHORT_ID

public static final java.lang.String FIELD_NAME_SHORT_ID
Field name for the short, human-friendly id.

See Also:
Constant Field Values

PERMISSION_ACTION_CREATE

public static final long PERMISSION_ACTION_CREATE
Permission action required for creating new objects.

See Also:
Constant Field Values

PERMISSION_ACTION_DELETE

public static final long PERMISSION_ACTION_DELETE
Permission action required for deleting objects.

See Also:
Constant Field Values

PERMISSION_ACTION_MODIFY

public static final long PERMISSION_ACTION_MODIFY
Permission action required for modifying existing objects.

See Also:
Constant Field Values

PERMISSION_ACTION_READ

public static final long PERMISSION_ACTION_READ
Permission action required for reading / querying objects.

See Also:
Constant Field Values
Constructor Detail

AbstractBindableObject

public AbstractBindableObject()
Method Detail

addRelatedObject

public <T extends AbstractBindableObject,U extends AbstractBindableObject> void addRelatedObject(java.lang.Class<U> relationType,
                                                                                                 java.lang.String relationName,
                                                                                                 T obj)

Adds an object to the list of related objects by given relation type and 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 object.
Parameters:
relationType - Type of relation.
relationName - Name of relation. May be null. For null relation name default relation naming may be used e.g. for binding.
obj - Object to be added to the relation.

addRelatedObject

public <T extends AbstractBindableObject,U extends AbstractBindableObject> void addRelatedObject(java.lang.Class<U> relationType,
                                                                                                 T obj)

Adds an object to the list of related objects by given 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 object.
Parameters:
relationType - Type of relation.
obj - Object to be added to the relation.

addRelatedObject

public <T extends AbstractBindableObject,U extends AbstractBindableObject> void addRelatedObject(ObjectRelation<T,U> relation,
                                                                                                 T obj)

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

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 object.
Parameters:
relation - Description of relation. Relation description may be defined dynamically in the context where relations are associated and used.
obj - Object to be added to the relation.

addRelatedObject

public <T extends RelationObject,U extends AbstractBindableObject> void addRelatedObject(U relationAttributeObject,
                                                                                         java.lang.String relationName,
                                                                                         T obj)

Adds an object to the list of related objects by given relation type and 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 object.
U - Type of relation attribute object.
Parameters:
relationAttributeObject - Relation attribute object.
relationName - Name of relation. May be null. For null relation name default relation naming may be used e.g. for binding.
obj - Object to be added to the relation.

addRelatedObjects

public <T extends AbstractBindableObject,U extends AbstractBindableObject> void addRelatedObjects(java.lang.Class<U> relationType,
                                                                                                  java.util.List<T> objects)

Adds all objects in the given list to the list of related objects by given 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:
relationType - Type of relation.
objects - List of objects to be added to the relation.

addRelatedObjects

public <T extends AbstractBindableObject,U extends AbstractBindableObject> void addRelatedObjects(java.lang.Class<U> relationType,
                                                                                                  java.lang.String relationName,
                                                                                                  java.util.List<T> objects)

Adds all objects in the given list to the list of related objects by given relation type and 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:
relationType - Type of relation.
relationName - Name of relation. May be null. For null relation name default relation naming may be used e.g. for binding.
objects - List of objects to be added to the relation.

addRelatedObjects

public <T extends AbstractBindableObject,U extends AbstractBindableObject> void addRelatedObjects(ObjectRelation<T,U> relation,
                                                                                                  java.util.List<T> objects)

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

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:
relation - Description of relation. Relation description may be defined dynamically in the context where relations are associated and used.
objects - List of objects to be added to the relation.

copyThis

protected void copyThis(AbstractBindableObject result)
Utility for use in Object.clone implementation.

Parameters:
result - The object who's fields will be set by values from this instance.

getCreated

public abstract java.util.Date getCreated()
Get created timestamp.

Returns:
The date (timestamp) when object was created.

getCreatingActor

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

Returns:
Handle to creating actor.

getFirstObjectById

public static <U extends AbstractBindableObject> U getFirstObjectById(java.util.List<U> objects,
                                                                      java.util.UUID id)
Gets an object from the given list of objects by id.

Type Parameters:
U - Object type.
Parameters:
objects - List of objects.
id - Object id.
Returns:
Object with given id or null if not found.

getGrantedObjectPermissionActions

public java.lang.Long getGrantedObjectPermissionActions()
Gets permission actions granted for handling the object in current context. This is transient information that may be used for authorization purposes.

Returns:
Permission actions granted, bitmask of PERMISSION_ACTION values defined by AbstractBindableObject.

getId

public abstract java.util.UUID getId()
Gets object's unique id.

Specified by:
getId in interface SerializableObject
Returns:
unique id of the object.

getModified

public abstract java.util.Date getModified()
Gets the timestamp when object was modified.

Returns:
Date (timestamp) when object was modified.

getModifyingActor

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

Returns:
Handle to modifying actor.

getObjectCategoryId

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

Returns:
This default implementation always returns null.

getParent

public AbstractBindableObject getParent()
Gets this objects parent.

Returns:
parent object, i.e. object that aggregates this object in the current object hierarchy.

getParentBindableType

public java.lang.String getParentBindableType()
Gets type to be used as parent bindable object. This information can be used by bind implementations that do parent-based bind naming.

Returns:
Fully qualified name of class to be used as parent bindable type.

getParentBindableTypeChain

public java.util.List<java.lang.String> getParentBindableTypeChain()
Follows parent chain of this object and for each parent found, adds its getParentBindableType() to the list, starting from this object. Breaks on first object that doesn't have parent bindable object type defined, i.e. there will be no nulls in the returned list.

Returns:
List of parent bindable object types.

getParentId

public java.util.UUID getParentId()
Gets id of parent object.

Returns:
Parent object id, or null if no parent object.

getParentNode

public SerializableObject getParentNode()
Gets this objects parent object.

Specified by:
getParentNode in interface SerializableObject
Returns:
parent object, i.e. object that aggregates this object in the current object hierarchy.

getParentType

public java.lang.String getParentType()
Gets type of parent object as fully qualified class name.

Returns:
Fully qualified class name of parent object, or null if no parent object.

getRelatedObjectList

public java.util.List<AbstractBindableObject> getRelatedObjectList()
                                                            throws java.lang.IllegalArgumentException,
                                                                   java.lang.IllegalAccessException
Gets flat list of all objects related to this object via old-style static named relations.

Returns:
List of related objects. The List may contain instances of several different classes derived from TendukeObject.
Throws:
java.lang.IllegalArgumentException
java.lang.IllegalAccessException

getRelatedObjectList

public java.util.List<AbstractBindableObject> getRelatedObjectList(java.lang.String relationName)
                                                            throws java.lang.IllegalArgumentException,
                                                                   java.lang.IllegalAccessException
Gets list of related objects with given old-style static relation name.

Parameters:
relationName -
Returns:
List of TendukeObjects annotated with @FieldName(relationName)
Throws:
java.lang.IllegalArgumentException
java.lang.IllegalAccessException

getRelatedObjectLists

public java.util.Map<java.lang.String,java.util.List<AbstractBindableObject>> getRelatedObjectLists()
                                                                                             throws java.lang.IllegalArgumentException,
                                                                                                    java.lang.IllegalAccessException
Gets old-style static relations for this object.

Returns:
Map containing all FieldName annotated lists of objects related to this object, Map key being the FieldName annotation value
Throws:
java.lang.IllegalArgumentException
java.lang.IllegalAccessException

getRelatedObjectLists

public static java.util.Map<java.lang.String,java.util.List<AbstractBindableObject>> getRelatedObjectLists(AbstractBindableObject object)
                                                                                                    throws java.lang.IllegalArgumentException,
                                                                                                           java.lang.IllegalAccessException
Gets old-style static relations for the given object.

Returns:
Map containing all FieldName annotated lists of objects related to the object, Map key being the FieldName annotation value.
Throws:
java.lang.IllegalArgumentException
java.lang.IllegalAccessException

getRelatedObjects

public java.util.Map<ObjectRelation<? extends AbstractBindableObject,? extends AbstractBindableObject>,java.util.List<? extends AbstractBindableObject>> getRelatedObjects()

Gets objects related to this object. Map key is description of the relation (assigned dynamically in the context where this field is used), map value is List of objects related to this object with the named relation.

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.

Returns:
Map of related objects by relation description.

getRelatedObjects

public <T extends AbstractBindableObject,U extends AbstractBindableObject> java.util.List<T> getRelatedObjects(java.lang.Class<U> relationType,
                                                                                                               java.lang.Class<T> relatedObjectType)

Gets objects related to this object with given 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:
relationType - Relation type.
relatedObjectType - Type of related objects.
Returns:
List of related objects by given relation type.

getRelatedObjects

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

Gets objects related to this object with given relation type and 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:
relationType - Relation type.
relationName - Name of relation. May be null. For null relation name default relation naming may be used e.g. for binding.
relatedObjectType - Type of related objects.
Returns:
List of related objects by given relation name.

getRelatedObjects

public <T extends AbstractBindableObject,U extends AbstractBindableObject> java.util.List<T> getRelatedObjects(ObjectRelation<T,U> relation)

Gets objects related to this object with given relation.

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:
relation - Description of the relation.
Returns:
List of related objects by given relation name.

getRelatedObjects

public java.util.List<? extends AbstractBindableObject> getRelatedObjects(java.lang.String relationName)

Gets objects related to this object with given relation relation name and any relation type.

This overload provides untyped access to a related object list. Use getRelatedObjects(java.lang.String, java.lang.Class) for typed access.

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 relation. May be null. For null relation name default relation naming may be used e.g. for binding.
Returns:
List of related objects by given relation name, or null if not found.

getRelatedObjects

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

Gets objects related to this object with given relation relation name and any relation type.

This overload provides typed access to a related object list. Use getRelatedObjects(java.lang.String) for untyped access.

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 relation. May be null. For null relation name default relation naming may be used e.g. for binding.
relatedObjectType - Type of related objects.
Returns:
List of related objects by given relation name, or null if not found.

getRelationAttributeObject

public <U> U getRelationAttributeObject(java.lang.Class<U> relationAttributeObjectType)
Gets object that is an attribute of a relation from another object to this object. This object is defined in a case when this object is accessed as child object of a parent from which the relation is defined.

Specified by:
getRelationAttributeObject in interface RelationObject
Type Parameters:
U - Type of the relation attribute object.
Parameters:
relationAttributeObjectType - Class of the relation attribute object.
Returns:
Object that is an attribute of a relation from another object to this object.

getRelationField

public <T> T getRelationField(java.lang.Class<T> fieldValueClass,
                              java.lang.String fieldName)
Gets value of a field in relation attribute object. Type conversion is provided with no runtime error checking.

Type Parameters:
T - Type of relation field's value object.
Parameters:
fieldValueClass - The class of the field value object.
fieldName - Name of the relation field.
Returns:
Relation field value.

getRelationHandler

public ObjectRelationHandler getRelationHandler()
Gets handler that encapsulates object dynamic relations.

Specified by:
getRelationHandler in interface RelationObject
Returns:
ObjectRelationHandler that encapsulated object dynamic relations

getRelationType

public java.lang.Class<? extends AbstractBindableObject> getRelationType(java.lang.String relationName)

Gets type of relation with given 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:
relationName - Name of relation. May be null. For null relation name default relation naming may be used e.g. for binding.
Returns:
Type of relation with given name, or null if not found.

getReplaces

public AbstractBindableObject getReplaces()

Handle to object that is replaced in a model state change. Requirements for the instance:

Returns:
Object (prototype) instance that describes replaced.

getShortId

public java.lang.String getShortId()
Gets short id of the object. Short id is an optional, secondary object id that can be used to provider shorter and more user-friendly unique object id.

Returns:
Short id

getStateChange

public java.lang.Integer getStateChange()
Gets instance member for state change flag (default value for an object instance is ObjectStateChange.UNDEFINED).

Returns:
state change flags value.

hasRelatedObjects

public <T extends AbstractBindableObject,U extends AbstractBindableObject> boolean hasRelatedObjects(ObjectRelation<T,U> relation)
Does this object have related objects with given relation.

Type Parameters:
T - Type of related objects.
Parameters:
relation - Relation description.
Returns:
true if the map of objects related to this object contains key with the given relation.

hasRelatedObjects

public boolean hasRelatedObjects(java.lang.String relationName)
Does this object have related objects with given relation name.

Parameters:
relationName - Relation name.
Returns:
true if the map of objects related to this object contains key with the given relation name.

resolveParentBindableType

protected void resolveParentBindableType()
Resolves and sets getParentBindableType() based on currently set parent object. Called by getParent() after setting parent, parent type and parent id. This default implementation sets the newly set value of getParentType() to the parent bindable object type. May be overridden by derived classes.


resolveParentBindableTypeByTreeParent

protected java.lang.String resolveParentBindableTypeByTreeParent()

Gets parent bindable object type for the object by iterating parents in the current object tree. This method may be used in resolveParentBindableType() overrides for classes that want to suggest parent based bind naming that's different from the resolveParentBindableType default implementation.

The following conditions are applied when resolving parent bindable object type:

Returns:
Parent bindable object type fully qualified class name, or null if no parent object of different type found.

setCreated

public abstract void setCreated(java.util.Date created)
Set created timestamp.

Parameters:
created - The date (timestamp) when object was created.

setCreatingActor

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

Parameters:
actor - Handle to actor that created this object.

setGrantedObjectPermissionActions

public void setGrantedObjectPermissionActions(java.lang.Long grantedObjectPermissionActions)
Sets permission actions granted for handling the object in current context. This is transient information that may be used for authorization purposes.

Parameters:
grantedObjectPermissionActions - Permission actions granted, bitmask of PERMISSION_ACTION values defined by AbstractBindableObject.

setId

public abstract void setId(java.util.UUID identifier)
Sets object's unique id.

Specified by:
setId in interface SerializableObject
Parameters:
identifier - Unique id for this object.

setModified

public abstract void setModified(java.util.Date modified)
Set modified timestamp.

Parameters:
modified - The date (timestamp) when object was modified.

setModifyingActor

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

Parameters:
actor - Handle to actor that modified this object.

setObjectCategoryId

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

Parameters:
categoryId - The category id to set.

setParent

public void setParent(AbstractBindableObject parent)
Set parent object, i.e. object that aggregates this object in the current object hierarchy.

Parameters:
parent - Handle to parent object.

setParent

public static void setParent(java.util.List<? extends AbstractBindableObject> objects,
                             AbstractBindableObject parent)
Set parent object for each object in list, i.e. object that aggregates each object in list.

Parameters:
-
parent - Handle to parent object.

setParentBindableType

public void setParentBindableType(java.lang.String parentBindableType)
Sets type to be used as parent bindable object. This information can be used by bind implementations that do parent-based bind naming.

Parameters:
parentBindableType - Fully qualified name of class to be used as parent bindable type.

setParentNode

public void setParentNode(SerializableObject parent)
Set parent object, i.e. object that aggregates this object in the current object hierarchy.

Specified by:
setParentNode in interface SerializableObject
Parameters:
parent - Handle to parent object (shall be of type AbstractBindableObject).

setRelatedObjectList

public void setRelatedObjectList(java.lang.String relationName,
                                 java.util.List<AbstractBindableObject> relationList)
                          throws java.lang.IllegalArgumentException,
                                 java.lang.IllegalAccessException
Sets value of old-style static @FieldName(relationName) annotated field in this object to relationList.

Parameters:
relationName -
relationList -
Throws:
java.lang.IllegalArgumentException
java.lang.IllegalAccessException

setRelatedObjects

public <T extends AbstractBindableObject> void setRelatedObjects(java.lang.Class<? extends AbstractBindableObject> relationType,
                                                                 java.util.List<T> objects)

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

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:
relationType - Type of relation.
objects - List of objects to be set as related objects with given relation name.

setRelatedObjects

public <T extends AbstractBindableObject> void setRelatedObjects(java.lang.Class<? extends AbstractBindableObject> relationType,
                                                                 java.lang.String relationName,
                                                                 T object)

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

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 object.
Parameters:
relationType - Type of relation.
relationName - Name of relation. May be null. For null relation name default relation naming may be used e.g. for binding.
object - Object to be set as the only related object with given relation name.

setRelatedObjects

public <T extends AbstractBindableObject> void setRelatedObjects(java.lang.Class<? extends AbstractBindableObject> relationType,
                                                                 T object)

Sets the list of related objects with given relation type, replacing earlier related objects for the relation, to the single object.

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 object.
Parameters:
relationType - Type of relation.
object - Object to be set as the only related object with given relation name.

setRelatedObjects

public <T extends AbstractBindableObject,U extends AbstractBindableObject> void setRelatedObjects(java.lang.Class<U> relationType,
                                                                                                  java.lang.String relationName,
                                                                                                  java.util.List<T> objects)

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

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:
relationType - Type of relation.
relationName - Name of relation. May be null. For null relation name default relation naming may be used e.g. for binding.
objects - List of objects to be set as related objects with given relation name.

setRelatedObjects

public <T extends AbstractBindableObject,U extends AbstractBindableObject> void setRelatedObjects(ObjectRelation<T,U> relation,
                                                                                                  java.util.List<T> objects)

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

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:
relation - Description of relation. Relation description may be defined dynamically in the context where relations are associated and used.
objects - List of objects to be set as related objects with given relation name.

setRelatedObjects

public <T extends AbstractBindableObject,U extends AbstractBindableObject> void setRelatedObjects(ObjectRelation<T,U> relation,
                                                                                                  T object)

Sets the list of related objects with given relation, replacing earlier related objects for the relation, to the single object.

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 object.
Parameters:
relation - Description of relation. Relation description may be defined dynamically in the context where relations are associated and used.
object - Object to be set as the only related object with given relation name.

setRelationAttributeObject

public <U> void setRelationAttributeObject(U relationAttributeObject)
Gets object that is an attribute of a relation from another object to this object. This object is defined in a case when this object is accessed as child object of a parent from which the relation is defined.

Specified by:
setRelationAttributeObject in interface RelationObject
Type Parameters:
U - Type of the relation attribute object.
Parameters:
relationAttributeObject - Object that is an attribute of a relation from another object to this object.

setRelationHandler

public void setRelationHandler(ObjectRelationHandler relationHandler)
Sets handler that encapsulates object dynamic relations.

Specified by:
setRelationHandler in interface RelationObject
Parameters:
relationHandler - ObjectRelationHandler that encapsulated object dynamic relations

setReplaces

public void setReplaces(AbstractBindableObject replaces)

Handle to object that is replaced in a model state change. Requirements for the instance:

Parameters:
replaces - Object (prototype) instance that describes replaced.

setShortId

public void setShortId(java.lang.String shortId)
Sets short id of the object. Short id is an optional, secondary object id that can be used to provider shorter and more user-friendly unique object id.

Parameters:
shortId - Short id

setStateChange

public void setStateChange(java.lang.Integer stateChange)
Sets instance member for state change flag (default value for an object instance is ObjectStateChange.UNDEFINED).

Parameters:
stateChange - the state change value to set.