Class AbstractChangeable

    • Method Detail

      • hasListeners

        protected boolean hasListeners()
        Discover if we have any listeners registered.
        true if there is at least one listener
      • hasListeners

        protected boolean hasListeners​(ChangeType ct)
        Discover if we have listeners registered for a particular change type.
        ct - the ChangeType we are interested in
        true if there is at least one listener
      • generateChangeSupport

        protected ChangeSupport generateChangeSupport()
        Called the first time a ChangeSupport object is needed. Override this if you want to set the Unchanging set on the ChangeSupport, or if you want to install listeners on other objects when the change system is initialized.
      • getChangeSupport

        protected ChangeSupport getChangeSupport​(ChangeType ct)
        Called to retrieve the ChangeSupport for this object.

        Your implementation of this method should have the following structure:

         ChangeSupport cs = super.getChangeSupport(ct);
         if(someForwarder == null && ct.isMatching(SomeInterface.SomeChangeType)) {
           someForwarder = new ChangeForwarder(...
           this.stateVariable.addChangeListener(someForwarder, VariableInterface.AChange);
         return cs;
        It is usual for the forwarding listeners (someForwarder in this example) to be transient and lazily instantiated. Be sure to register & unregister the forwarder in the code that does the ChangeEvent handling in setter methods.
      • isUnchanging

        public final boolean isUnchanging​(ChangeType ct)
        Description copied from interface: Changeable

        A particular ChangeType can never be raised by this Changeable.

        If this returns true, then it is guaranteed that change events of this type (and all child types) can never under any circumstances be fired by this Changeable instance. If it returns false, that does not mean that this type of event will or even can be raised, but that it is worth registering listeners incase.

        Specified by:
        isUnchanging in interface Changeable
        ct - the ChangeType to check
        true if ChangeEvents of this type are guaranteed to never be fired