Package net.ggtools.grand.filters
Class AbstractGraphFilter
- java.lang.Object
-
- net.ggtools.grand.filters.AbstractGraphFilter
-
- All Implemented Interfaces:
GraphFilter
,GraphConsumer
,GraphProducer
- Direct Known Subclasses:
GraphWalkFilter
,IsolatedNodeFilter
,MissingNodeFilter
,NodeRemoverFilter
,PrefixedNodeFilter
public abstract class AbstractGraphFilter extends Object implements GraphFilter
- Author:
- Christophe Labouisse
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractGraphFilter()
Creates an anonymous filter.protected
AbstractGraphFilter(String name)
Creates a named filter.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract Collection<Node>
getFilteredNodes()
Get the nodes from the graph that pass the filter.Graph
getGraph()
Method getGraph.protected GraphProducer
getGraphProducer()
Returns the current graph producer.String
getName()
Method getName.protected Graph
getProducersGraph()
Returns the graph from the current producer.void
setProducer(GraphProducer producer)
Method setProducer.
-
-
-
Field Detail
-
name
protected final String name
Field name.
-
-
Constructor Detail
-
AbstractGraphFilter
protected AbstractGraphFilter()
Creates an anonymous filter.
-
AbstractGraphFilter
protected AbstractGraphFilter(String name)
Creates a named filter.- Parameters:
name
- String
-
-
Method Detail
-
getGraph
public final Graph getGraph() throws GrandException
Method getGraph.- Specified by:
getGraph
in interfaceGraphProducer
- Returns:
- Graph
- Throws:
GrandException
- if an error occurs in getNodes()/getFilteredNodes()- See Also:
GraphProducer.getGraph()
-
setProducer
public final void setProducer(GraphProducer producer)
Method setProducer.- Specified by:
setProducer
in interfaceGraphConsumer
- Parameters:
producer
- GraphProducer- See Also:
GraphConsumer.setProducer(net.ggtools.grand.graph.GraphProducer)
-
getName
public final String getName()
Method getName.- Specified by:
getName
in interfaceGraphFilter
- Returns:
- String
- See Also:
GraphFilter.getName()
-
getFilteredNodes
protected abstract Collection<Node> getFilteredNodes() throws GrandException
Get the nodes from the graph that pass the filter. This method should not alter the input graph. The returned collection may be read only and returnUnsupportedOperationException
on modification methods.- Returns:
- a collection of nodes.
- Throws:
GrandException
- if the filtering cannot be done
-
getGraphProducer
protected final GraphProducer getGraphProducer()
Returns the current graph producer.- Returns:
- graph producer.
-
getProducersGraph
protected final Graph getProducersGraph() throws GrandException
Returns the graph from the current producer. This method is intended to prevent calling several time the producer to get a graph.- Returns:
- current graph.
- Throws:
GrandException
- if something goes wrong.
-
-