Ableverse™
TOB 6.0

av.tob
Class TheRelation.Tie<T extends TheObject>

java.lang.Object
  extended by av.tob.TheRelation.Tie<T>
Type Parameters:
T - class of the tied object
All Implemented Interfaces:
Kin<TheRelation,T>
Enclosing class:
TheRelation

public class TheRelation.Tie<T extends TheObject>
extends Object
implements Kin<TheRelation,T>

This is the root class for all ties.

This is defined as the inner class of TheRelation so that application defined subclasses will be able to obtain the outer relation object when handling killingTargetNotify() and targetKilledNotify() notifications.

See the Object-Relation-Kin Model.

Author:
Compl

Field Summary
 T o
          The tied object
 
Constructor Summary
TheRelation.Tie(T o)
          Construct a tie.
 
Method Summary
<R extends TheRelation>
Kin<R,T>
asKin()
          This doesn't provide type safety but to enable generic casts for subclasses of TheRelation
 T getO()
          Get the related object of this kin.
 TheRelation getR()
          Get the source relation object of this kin.
protected  void killingTargetNotify()
          Override this method to perform custom validation against admissibility for the tied object to be killed.
protected  void targetKilledNotify()
          Override this method to get notified when tied object get actually killed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

o

public final T extends TheObject o
The tied object

Constructor Detail

TheRelation.Tie

public TheRelation.Tie(T o)
                throws NullPointerException,
                       ObjectNotBornException
Construct a tie.

Parameters:
o - the object to be tied, must be a born object
Throws:
NullPointerException - if o is null
ObjectNotBornException - if o is not born
Method Detail

asKin

public <R extends TheRelation> Kin<R,T> asKin()
This doesn't provide type safety but to enable generic casts for subclasses of TheRelation

Type Parameters:
R - must be assignable from the outer relation object enclosing this tie instance
Returns:
the same tie instance with the specified R as source relation type

getR

public TheRelation getR()
Description copied from interface: Kin
Get the source relation object of this kin.

Specified by:
getR in interface Kin<TheRelation,T extends TheObject>
Returns:
the outer relation object

getO

public T getO()
Description copied from interface: Kin
Get the related object of this kin.

Specified by:
getO in interface Kin<TheRelation,T extends TheObject>
Returns:
the tied object, same value as o.

killingTargetNotify

protected void killingTargetNotify()
                            throws ObjectDependedException
Override this method to perform custom validation against admissibility for the tied object to be killed. Throwing an exception here will prevent the tied object from being actually killed.

The default handling will try killing the outer relation object at this point, iff the outer relation doesn't have any persistent fields itself, and has no more than 2 tie fields (which means it only serves for connection between two objects or is just a dummy indicator, so should be get rid of as the connected object be killed).

Note: To enable this behavior, there has to be at least one kin field defined at class of the tied object, which take this tie field as one of its self roles (specified with IAm or implied by type). And this method will be invoked the same number of times as the number of such kin fields.

Throws:
ObjectDependedException

targetKilledNotify

protected void targetKilledNotify()
Override this method to get notified when tied object get actually killed. After this method returned, the tie field will be cleared to null.

Note: To enable this behavior, there has to be at least one kin field defined at class of the tied object, which take this tie field as one of its self roles (specified with IAm or implied by type). And this method will be invoked the same number of times as the number of such kin fields.


Ableverse™
TOB 6.0

Copyright© 2006 Ableverse Platform. All rights reserved.