org.molwind.model
Class BaseRelationship

java.lang.Object
  extended by org.molwind.model.BaseRelationship
All Implemented Interfaces:
PartialMatch, Relationship
Direct Known Subclasses:
PartOf

public class BaseRelationship
extends java.lang.Object
implements Relationship, PartialMatch

BaseRelationship specifies a basic relationship type.

Version:
1.0
Author:
Oliver Karch

Constructor Summary
BaseRelationship(WorldEntity newRight)
          Creates a new relationship object where the left argument is assigned at a later stage.
BaseRelationship(WorldEntity newLeft, WorldEntity newRight)
          Creates a new relationship object.
 
Method Summary
 boolean equals(java.lang.Object object)
          Compares this relationship to another.
 WorldEntity getLeft()
          Gets the left entity.
 WorldEntity getRight()
          Gets the right entity.
 int hashCode()
          Returns a hash code value for this relationship.
 boolean isTransitive()
          Returns whether this relationship supports transitivity.
static BaseRelationship left(WorldEntity entity)
          Returns a new relationship object with the given entity assigned as the left argument.
 boolean matches(Relationship relation)
          Match the given relationship.
static BaseRelationship right(WorldEntity entity)
          Returns a new relationship object with the given entity assigned as the right argument.
 void setLeft(WorldEntity newLeft)
          Set the Left value.
 void setRight(WorldEntity newRight)
          Set the Right value.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseRelationship

public BaseRelationship(WorldEntity newLeft,
                        WorldEntity newRight)
Creates a new relationship object.

Parameters:
newLeft - left argument world entity
newRight - right argument world entity

BaseRelationship

public BaseRelationship(WorldEntity newRight)
Creates a new relationship object where the left argument is assigned at a later stage.

Parameters:
newRight - right argument world entity
Method Detail

setLeft

public void setLeft(WorldEntity newLeft)
Set the Left value.

Parameters:
newLeft - the new Left value

getLeft

public WorldEntity getLeft()
Gets the left entity.

Specified by:
getLeft in interface Relationship
Returns:
the left entity

setRight

public void setRight(WorldEntity newRight)
Set the Right value.

Parameters:
newRight - the new Right value

getRight

public WorldEntity getRight()
Gets the right entity.

Specified by:
getRight in interface Relationship
Returns:
the right entity

isTransitive

public boolean isTransitive()
Returns whether this relationship supports transitivity.

Specified by:
isTransitive in interface Relationship
Returns:
true if relationship type is transitive, otherwise false

equals

public boolean equals(java.lang.Object object)
Compares this relationship to another. A relationship is equal if it is of exactly the same class and left and right arguments are equal to each other.

Overrides:
equals in class java.lang.Object
Parameters:
object - the reference object with which to compare
Returns:
true if this object is the same as the object argument, false otherwise

hashCode

public int hashCode()
Returns a hash code value for this relationship. The method must be defined, because this class overrides equals(Object).

Overrides:
hashCode in class java.lang.Object
Returns:
a hash code value for this object

matches

public boolean matches(Relationship relation)
Match the given relationship.

Specified by:
matches in interface PartialMatch
Parameters:
relation - the relationship template to match
Returns:
true if this relationship matches the given one

right

public static BaseRelationship right(WorldEntity entity)
Returns a new relationship object with the given entity assigned as the right argument.

Parameters:
entity - the world entity
Returns:
the relationship object

left

public static BaseRelationship left(WorldEntity entity)
Returns a new relationship object with the given entity assigned as the left argument.

Parameters:
entity - the world entity
Returns:
the relationship object


Copyright © 2008-2010. All Rights Reserved.