public class PruneForest extends Object

Forest of "prune trees" where a prune tree is a location that can be pruned with a tree of descendants that must be excluded from the pruning.

Internally we store this as a single tree of booleans with the following characteristics: * 'true' indicates a location that can be pruned, possibly with some excluded descendants. * 'false' indicates a location that we should keep (i.e. exclude from pruning). * 'true' (prune) cannot be a descendant of 'false' (keep). This will trigger an exception. * 'true' cannot be a descendant of 'true' (we'll just keep the more shallow 'true'). * 'false' cannot be a descendant of 'false' (we'll just keep the more shallow 'false').

Public Constructor Summary

Public Method Summary

boolean
PruneForest
child(Path path)
PruneForest
boolean
<T> T
foldKeptNodes(T startValue, TreeVisitor<Void, T> treeVisitor)
int
PruneForest
keep(Path path)
PruneForest
keepAll(Path path, Set<ChildKey> children)
PruneForest
prune(Path path)
PruneForest
pruneAll(Path path, Set<ChildKey> children)
boolean
boolean
boolean
shouldPruneUnkeptDescendants(Path path)
Indicates that path is marked for pruning, so anything below it that didn't have keep() called on it should be pruned.
String

Inherited Method Summary

Public Constructors

public PruneForest ()

Public Methods

public boolean affectsPath (Path path)

Parameters
path

public PruneForest child (Path path)

Parameters
path

public PruneForest child (ChildKey key)

Parameters
key

public boolean equals (Object o)

Parameters
o

public T foldKeptNodes (T startValue, TreeVisitor<Void, T> treeVisitor)

Parameters
startValue
treeVisitor

public int hashCode ()

public PruneForest keep (Path path)

Parameters
path

public PruneForest keepAll (Path path, Set<ChildKey> children)

Parameters
path
children

public PruneForest prune (Path path)

Parameters
path

public PruneForest pruneAll (Path path, Set<ChildKey> children)

Parameters
path
children

public boolean prunesAnything ()

public boolean shouldKeep (Path path)

Parameters
path

public boolean shouldPruneUnkeptDescendants (Path path)

Indicates that path is marked for pruning, so anything below it that didn't have keep() called on it should be pruned.

Parameters
path The path in question
Returns
  • True if we should prune descendants that didn't have keep() called on them.

public String toString ()