Class InUseStateAggregator<T>

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Set<T> inUseObjects  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      boolean anyObjectInUse​(java.lang.Object... objects)
      Returns true if any of the given objects are in use.
      protected abstract void handleInUse()
      Called when the aggregated in-use state has changed to true, which means at least one object is in use.
      protected abstract void handleNotInUse()
      Called when the aggregated in-use state has changed to false, which means no object is in use.
      boolean isInUse()  
      void updateObjectInUse​(T object, boolean inUse)
      Update the in-use state of an object.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • inUseObjects

        private final java.util.Set<T> inUseObjects
    • Constructor Detail

      • InUseStateAggregator

        public InUseStateAggregator()
    • Method Detail

      • updateObjectInUse

        public final void updateObjectInUse​(T object,
                                            boolean inUse)
        Update the in-use state of an object. Initially no object is in use.

        This may call into handleInUse() or handleNotInUse() when appropriate.

      • isInUse

        public final boolean isInUse()
      • anyObjectInUse

        public final boolean anyObjectInUse​(java.lang.Object... objects)
        Returns true if any of the given objects are in use.
        Parameters:
        objects - The objects to consider.
        Returns:
        true if any of the given objects are in use.
      • handleInUse

        protected abstract void handleInUse()
        Called when the aggregated in-use state has changed to true, which means at least one object is in use.
      • handleNotInUse

        protected abstract void handleNotInUse()
        Called when the aggregated in-use state has changed to false, which means no object is in use.