pl.edu.agh.cast.data.model.general
Class OneToOneRelation

java.lang.Object
  extended by pl.edu.agh.cast.data.model.property.PropertyContainer
      extended by pl.edu.agh.cast.data.model.AbstractElement
          extended by pl.edu.agh.cast.data.model.general.ManyToManyRelation
              extended by pl.edu.agh.cast.data.model.general.OneToOneRelation
All Implemented Interfaces:
Serializable, Observer, IDisposable, IReplicable, IValidatable, IDomainElement, IGeneralElement, IManyToManyRelation, IOneToOneRelation, Identifiable, IElement, IPropertyContainer

public class OneToOneRelation
extends ManyToManyRelation
implements IOneToOneRelation

Default implementation of IOneToOneRelation interface.

All public constructors set the element type to IOneToOneRelation.TYPE. Protected constructors should only be used by direct subclasses to provide the concrete type to the super constructor.

Author:
AGH CAST Team
See Also:
IOneToOneRelation, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface pl.edu.agh.cast.data.model.general.IManyToManyRelation
IManyToManyRelation.Properties
 
Field Summary
 
Fields inherited from interface pl.edu.agh.cast.data.model.general.IOneToOneRelation
TYPE
 
Constructor Summary
  OneToOneRelation()
          Default constructor.
  OneToOneRelation(IEntity source, IEntity target, boolean directed)
          Creates new one-to-one relation with given source and target entity, direction and newly-generated ID.
  OneToOneRelation(IGeneralDataSet<? extends IGeneralElement> dataSet, IEntity source, IEntity target, boolean directed)
          Creates new one-to-one relation with given data set, source and target entity, direction and newly-generated ID.
protected OneToOneRelation(Type type)
          Initializes element with type.
protected OneToOneRelation(Type type, UUID id, IReferenceList<IEntity> source, IReferenceList<IEntity> target, boolean directed)
          Initializes element with given type, ID, source and target entity and direction.
  OneToOneRelation(UUID id, IEntity source, IEntity target, boolean directed)
          Creates new one-to-one relation with given ID, source and target entity and direction.
  OneToOneRelation(UUID id, IReferenceList<IEntity> sources, IReferenceList<IEntity> targets, boolean directed)
          Creates new one-to-one relation with given ID, source and target entity (in form of lists), direction.
 
Method Summary
 IEntity getSourceEntity()
          Returns the source entity.
 IEntity getTargetEntity()
          Returns the target entity.
 OneToOneRelation replicate()
          Returns a replicated instance of this instance.
 OneToOneRelation replicateTo(Object replica)
          Replicates this instance state to given replica object.
 void setSourceEntity(IEntity entity)
          Sets the source entity.
 void setTargetEntity(IEntity entity)
          Sets the target entity.
 
Methods inherited from class pl.edu.agh.cast.data.model.general.ManyToManyRelation
addSourceEntitiy, addTargetEntitiy, getDescString, getSourceEntities, getSourceEntitiy, getTargetEntities, getTargetEntitiy, isDirected, isEntityListValid, isEntityValid, isSourceEntitiesResolved, isSourceEntityListValid, isTargetEntitiesResolved, isTargetEntityListValid, removeSourceEntitiy, removeTargetEntitiy, setDirected, setSourceEntities, setTargetEntities
 
Methods inherited from class pl.edu.agh.cast.data.model.AbstractElement
afterSetMetaPropertyManager, canReplicateTo, checkIfValid, equals, getDataSet, getId, getType, hashCode, isValid, setDataSet, setId, setType, toString
 
Methods inherited from class pl.edu.agh.cast.data.model.property.PropertyContainer
addProperty, createProperty, dispose, getCustomProperties, getMetaPropertyManager, getPermanentProperties, getProperties, getProperty, getTransientProperties, initializeProperties, matches, removeProperty, setMetaPropertyManager, setProperty, update
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface pl.edu.agh.cast.data.model.general.IManyToManyRelation
addSourceEntitiy, addTargetEntitiy, getSourceEntities, getSourceEntitiy, getTargetEntities, getTargetEntitiy, isDirected, removeSourceEntitiy, removeTargetEntitiy, setDirected, setSourceEntities, setTargetEntities
 
Methods inherited from interface pl.edu.agh.cast.data.model.IElement
getDataSet
 
Methods inherited from interface pl.edu.agh.cast.data.model.Identifiable
getId, getType
 
Methods inherited from interface pl.edu.agh.cast.data.model.property.IPropertyContainer
addProperty, getCustomProperties, getMetaPropertyManager, getPermanentProperties, getProperties, getProperty, getTransientProperties, matches, removeProperty, setProperty
 
Methods inherited from interface java.util.Observer
update
 
Methods inherited from interface pl.edu.agh.cast.common.IValidatable
isValid
 
Methods inherited from interface pl.edu.agh.cast.common.IDisposable
dispose
 

Constructor Detail

OneToOneRelation

public OneToOneRelation()
Default constructor.

Usage of this constructor is discouraged, since it does not provide any integrity control. If, however, this constructor is used, the AbstractElement.isValid() method should be called in order to check the integrity.


OneToOneRelation

public OneToOneRelation(IEntity source,
                        IEntity target,
                        boolean directed)
Creates new one-to-one relation with given source and target entity, direction and newly-generated ID.

Parameters:
source - the source entity of this relation
target - the target entity of this relation
directed - the flag indicating whether the relation is directed or not (see IManyToManyRelation.isDirected())

OneToOneRelation

public OneToOneRelation(UUID id,
                        IEntity source,
                        IEntity target,
                        boolean directed)
Creates new one-to-one relation with given ID, source and target entity and direction.

Parameters:
id - ID of the element
source - the source entity of this relation
target - the target entity of this relation
directed - the flag indicating whether the relation is directed or not (see IManyToManyRelation.isDirected())

OneToOneRelation

public OneToOneRelation(IGeneralDataSet<? extends IGeneralElement> dataSet,
                        IEntity source,
                        IEntity target,
                        boolean directed)
Creates new one-to-one relation with given data set, source and target entity, direction and newly-generated ID.

Parameters:
dataSet - the general data set this relation is in
source - the source entity of this relation
target - the target entity of this relation
directed - the flag indicating whether the relation is directed or not (see IManyToManyRelation.isDirected())

OneToOneRelation

public OneToOneRelation(UUID id,
                        IReferenceList<IEntity> sources,
                        IReferenceList<IEntity> targets,
                        boolean directed)
Creates new one-to-one relation with given ID, source and target entity (in form of lists), direction.

Parameters:
id - ID of the element
sources - reference list to source entities - must contain exactly one reference
targets - reference list to target entities - must contain exactly one reference
directed - the flag indicating whether the relation is directed or not (see IManyToManyRelation.isDirected())

OneToOneRelation

protected OneToOneRelation(Type type)
Initializes element with type.

This constructor should be used only by extending classes to implement the default constructor.

Parameters:
type - type of the element
See Also:
ManyToManyRelation.ManyToManyRelation(Type)

OneToOneRelation

protected OneToOneRelation(Type type,
                           UUID id,
                           IReferenceList<IEntity> source,
                           IReferenceList<IEntity> target,
                           boolean directed)
Initializes element with given type, ID, source and target entity and direction.

Parameters:
type - type of element which extends this one
id - ID of the element
source - reference list to source entities - must contain exactly one reference
target - reference list to target entities - must contain exactly one reference
directed - the flag indicating whether the relation is directed or not (see IManyToManyRelation.isDirected())
Method Detail

getSourceEntity

public IEntity getSourceEntity()
Returns the source entity.

Specified by:
getSourceEntity in interface IOneToOneRelation
Returns:
the source entity (non-null)
See Also:
IOneToOneRelation.getSourceEntity()

setSourceEntity

public void setSourceEntity(IEntity entity)
Sets the source entity.

Specified by:
setSourceEntity in interface IOneToOneRelation
Parameters:
entity - the source entity
See Also:
#setSourceEntity(pl.edu.agh.cast.data.model.general.IEntity)

getTargetEntity

public IEntity getTargetEntity()
Returns the target entity.

Specified by:
getTargetEntity in interface IOneToOneRelation
Returns:
the target entity (non-null)
See Also:
IOneToOneRelation.getTargetEntity()

setTargetEntity

public void setTargetEntity(IEntity entity)
Sets the target entity.

Specified by:
setTargetEntity in interface IOneToOneRelation
Parameters:
entity - the target entity
See Also:
#setTargetEntity(pl.edu.agh.cast.data.model.general.IEntity)

replicateTo

public OneToOneRelation replicateTo(Object replica)
                             throws IllegalArgumentException,
                                    ReplicationException
Replicates this instance state to given replica object. The replica should be an instance of replicated instance's class (same class or subclass).

Replicates element type and ID.

Replicates relation direction, the lists of source and target entities are empty.

Replicates relation direction, the lists of source and target entities are empty.

Specified by:
replicateTo in interface IReplicable
Overrides:
replicateTo in class ManyToManyRelation
Parameters:
replica - the object to replicate to
Returns:
the replica object (the same instance as given)
Throws:
IllegalArgumentException - if given object is null or of invalid type
ReplicationException - if replication fails
See Also:
ManyToManyRelation.replicateTo(java.lang.Object)

replicate

public OneToOneRelation replicate()
                           throws ReplicationException
Returns a replicated instance of this instance.

Specified by:
replicate in interface IReplicable
Overrides:
replicate in class ManyToManyRelation
Returns:
replicated instance
Throws:
ReplicationException - if replication fails
See Also:
IReplicable.replicate()


Copyright © 2007-2009 IISG AGH-UST Krakow, Poland. All Rights Reserved.