Interface GraphObserver
-
public interface GraphObserver
Observer over a graph to monitor changes and obtain the list of differences.The graph observer is a mechanism used to monitor periodically changes made to the graph. This scenario is common in multi-threaded application where a thread is modifying the graph and one or multiple threads need to take action when updates are made.
Graph observer users should periodically call the
hasGraphChanged()
method to check the status. Each call resets the observer so if the method returns true and the graph doesn't change after that it will return false next time.In addition of a boolean flag whether the graph has changed, an observer can collect data about the differences such as nodes added or removed. Users should call the
getDiff()
method after callinghasGraphChanged()
to obtain the diff.Observers should be destroyed when not needed anymore. A new observer can be obtained from the
GraphModel
.Note that observer instances are not thread-safe and should not be called from multiple threads simultaneously.
- See Also:
GraphModel
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
destroy()
Destroys this graph observer.GraphDiff
getDiff()
Gets the graph difference.Graph
getGraph()
Gets the graph this observer is observing.boolean
hasGraphChanged()
Returns true if the graph has changed.boolean
isDestroyed()
Returns true if this observer has been destroyed.boolean
isNew()
Returns true if this observer has never got its hasGraphChanged() method called.
-
-
-
Method Detail
-
hasGraphChanged
boolean hasGraphChanged()
Returns true if the graph has changed.- Returns:
- true if changed, false otherwise
-
getDiff
GraphDiff getDiff()
Gets the graph difference.- Returns:
- the graph diff
-
getGraph
Graph getGraph()
Gets the graph this observer is observing.- Returns:
- the graph
-
destroy
void destroy()
Destroys this graph observer.
-
isDestroyed
boolean isDestroyed()
Returns true if this observer has been destroyed.- Returns:
- true if destroyed, false otherwise
-
isNew
boolean isNew()
Returns true if this observer has never got its hasGraphChanged() method called.- Returns:
- true if new observer, false otherwise
-
-