Class Format<L extends Label>
java.lang.Object
org.variantsync.diffdetective.variation.diff.serialize.Format<L>
Format used for exporting a
VariationDiff
.
For easy reusability this class is composed of separate node and edge formats.
The exported VariationDiff
can be influenced in the following ways:
- Providing both a node and an edge label format.
- Changing the order, filtering or adding the nodes and edges by creating a subclass of
Format
.
-
Field Summary
Modifier and TypeFieldDescriptionprivate final EdgeLabelFormat<? super L>
private final DiffNodeLabelFormat<? super L>
-
Constructor Summary
ConstructorDescriptionFormat
(DiffNodeLabelFormat<? super L> nodeFormat, EdgeLabelFormat<? super L> edgeFormat) -
Method Summary
Modifier and TypeMethodDescription<La extends L>
voidforEachEdge
(VariationDiff<La> variationDiff, Consumer<StyledEdge<La>> callback) Iterates over all edges invariationDiff
and callscallback
, visiting parallel edges only once.<La extends L>
voidforEachNode
(VariationDiff<La> variationDiff, Consumer<DiffNode<La>> callback) EdgeLabelFormat<? super L>
DiffNodeLabelFormat<? super L>
protected <La extends L>
voidsortedEdgeWithLabel
(DiffNode<La> originalFrom, DiffNode<La> originalTo, StyledEdge.Style style, Consumer<StyledEdge<La>> callback)
-
Field Details
-
nodeFormat
-
edgeFormat
-
-
Constructor Details
-
Format
-
-
Method Details
-
getNodeFormat
-
getEdgeFormat
-
forEachNode
public <La extends L> void forEachNode(VariationDiff<La> variationDiff, Consumer<DiffNode<La>> callback) Iterates over allDiffNode
s invariationDiff
and callscallback
. Exporters should use this method to enable subclasses ofFormat
to filter nodes, add new nodes and change the order of the exported nodes. This implementation is equivalent toVariationDiff.forAll(java.util.function.Consumer<org.variantsync.diffdetective.variation.diff.DiffNode<L>>)
.- Parameters:
variationDiff
- to be exportedcallback
- is called for each node
-
forEachEdge
public <La extends L> void forEachEdge(VariationDiff<La> variationDiff, Consumer<StyledEdge<La>> callback) Iterates over all edges invariationDiff
and callscallback
, visiting parallel edges only once. If an edge is unchanged (there are equal before and after edges)callback
is only called once. Exporters should use this method to enable subclasses ofFormat
to filter edges, add new edges and change the order of the exported edges.- Parameters:
variationDiff
- to be exportedcallback
- is called for each unique edge
-
sortedEdgeWithLabel
protected <La extends L> void sortedEdgeWithLabel(DiffNode<La> originalFrom, DiffNode<La> originalTo, StyledEdge.Style style, Consumer<StyledEdge<La>> callback) Constructs aStyledEdge
fromoriginalFrom
tooriginalTo
. The order of these nodes is permuted according toEdgeLabelFormat.getEdgeDirection()
ofgetEdgeFormat()
.- Parameters:
originalFrom
- the origin of the constructed edgeoriginalTo
- the destination of the constructed edgestyle
- the export style of the constructed edgecallback
- the consumer which is called with the resultingStyledEdge
-