[Biojava-l] Proposal: ChangeType hierarchies

Thomas Down td2@sanger.ac.uk
Thu, 22 Feb 2001 10:58:08 +0000


Now that we're comfortable working with ChangeEvents, I'd
like to propose a really simple enhancement to the
ChangeType objects:

  - Add two methods to ChangeType:

     public ChangeType getParent();
     public boolean isSubType(ChangeType t);

  - Add extra constructors to ChangeType objects which allow
    a parent to be specified.  If the current (no-parent)
    constructors are used, we default to ChangeType.UNKNOWN
    (which becomes the root of the type hierarchy).

    [Open issue: what is the value of ChangeType.UNKNOWN.getParent()?]

  - ChangeEvent sources use isSubType() to check if a listener
    is interested in a given ChangeType, rather than simple
    object equality.  Right  now, I can't think of any event sources
    which don't use ChangeSupport, so that's the only  place
    we would have to make this change.

  - Once nice side effect of this is that registering a listener
    with no specified type becomes exactly equivalent to listening
    for ChangeType.UNKNOWN

This change would make it easy for specific implementations of
an interface to fire specialized sub-types of some common change
types.  Client code can then listen either to one or more of
the specialized types, OR to the common base type.

Impact on current code would be minimal -- The only
place I can think of where any changes will be needed
is ChangeSupport.

What do people think of this one?

   Thomas.