|
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||
java.lang.Objectav.tob.KinSet<R,T>
R - class of the source relationsT - class of the related objectspublic final class KinSet<R extends TheRelation,T extends TheObject>
The KinSet class serves as the type of kin set fields, a kin set contains
multiple Kins.
Kin and KinSet fields are means by which persistent objects
can reach their related objects that related by existence of corresponding
relation objects.
A relation object ties 2 or more persistent objects together with 2 or more
Tie fields. The tied objects each performs its own
role in the relation, which is reflected by name of the
Tie field tying it. These tied objects directly see
eachother through their own Kin and KinSet fields.
A relation object can also have only 1 Tie field,
which used to tie itself to another object. In this case the tied object can
have a direct Kin or KinSet field to see back the
relation object.
A kin presents a related object connected via existence of
a source relation object. The R type parameter
declares the source relation class of the kin, while the T type
parameter declares the class of the related object. Roles in the
source relation are essential for kins. To define the semantics of a
Kin or KinSet field, 2 list of roles are concerned:
Tie fields in the source
relation class, that may tie the object defines the Kin or
KinSet field. This list may be explicitly specified with a
IAm annotation. Or TOB can determine it by comparing the defining
class to target type of all Tie fields in the source
relation class.Tie fields in the source
relation class, that may tie the related object. This
list may be explicitly specified with a ThisIs annotation for a
Kin field or with a TheyAre annotation for a KinSet
field. Or TOB can determine it by comparing the related object class (the
T) to target type of all Tie fields in the
source relation class.
The runtime values of Kin fields and contents of KinSet
fields are automatically maintained by TOB, according to corresponsive
relation object manipulations. Applications just define and read these fields
to traverse across the persistent object topograph.
Applications normally don't initialize kin set fields at their persistent
classes, it can be safely assumed that kin set fields of born objects are
always properly initialized. Since TOB will generate code to initialize kin
set fields for born objects if they are null at runtime. And
UseKinComparator annotations are honored on kin set fields, so that
if specified, the field will be initilized with a KinSet object
constructed with that comparator.
Omitting initializations for kin set fields at application classes improves runtime performance, and is memory economic for fetus objects to be used unborn.
See the Object-Relation-Kin Model.
| Constructor Summary | |
|---|---|
KinSet()
Construct a kin set with a FirstCreatedFirst comparator. |
|
KinSet(Comparator<? extends Kin<?,?>> comparator)
Construct a kin set with sorting order determined by the comparator. |
|
| Method Summary | |
|---|---|
boolean |
containsObject(TheObject p)
Test whether a persistent object is referenced as the target object by at lease one kin in this kin set. |
Iterable<T> |
distinctObjects()
Get a distinct set of related objects. |
Comparator<? extends Kin<?,?>> |
getComparator()
Get the comparator used to sort this kin set. |
boolean |
isEmpty()
Test whether this set is empty. |
Iterator<Kin<R,T>> |
iterator()
Get a snapshot iterator of this kin set. |
int |
size()
Get how many kins in this set. |
List<Kin<R,T>> |
toList()
Get a snapshot of this kin set, as a list of kins. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public KinSet()
FirstCreatedFirst comparator.
public KinSet(Comparator<? extends Kin<?,?>> comparator)
null is specified here as the comparator, a
FirstCreatedFirst comparator will be used.
Note:
Kins.
That is, only immutable attributes should be used to perform the
comparation. The persistent object ID, the creation time of both the
source relation object and the related object are good candidates. And
values of some persistent fields, e.g. a Person object's
Gender value, can be used if they are guarannteed not to change.
comparator - A comparator used to sort kins in this set| Method Detail |
|---|
public int size()
public boolean isEmpty()
public List<Kin<R,T>> toList()
The returned list is immutable.
public Iterator<Kin<R,T>> iterator()
The returned iterator is immutable.
iterator in interface Iterable<Kin<R extends TheRelation,T extends TheObject>>public Iterable<T> distinctObjects()
public boolean containsObject(TheObject p)
p - a persistent object
public Comparator<? extends Kin<?,?>> getComparator()
|
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||