Interface Delta
- All Known Subinterfaces:
DeltaNode,DeltaRange
Delta.Kind of
difference within each pair. DeltaNode (folder comparisons) and
DeltaRange (text comparisons) are the two kinds of Delta.
A two-way comparison has a single pair, also called a relation: the item
with Role.REF and the item with Role.ONE, and so a single
Kind. A three-way comparison has three relations, each with its own
Kind:
Role.ONEandRole.REFRole.REFandRole.TWORole.ONEandRole.TWO
In a three-way comparison it therefore makes sense to talk about the
overall result, the combination of the kinds of the individual
relations. For instance, if Role.ONE and Role.REF differ by
Delta.Kind.ADDED and there is no difference between Role.REF and
Role.TWO, the overall result is Kind.ADDED. When more than
one relation has a difference, the overall result can be a
conflict or a pseudo-conflict.
The is...() methods test the overall result; kind(Role[])
returns the kind of a single relation.
const node = nodes[i];
if (node.isAdded()) { ... }
else if (node.isConflict()) { ... }
const kind = node.kind([Role.ONE, Role.REF]);
- Since:
- 2.0
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumThe kinds of difference between the two items of a relation. -
Method Summary
Modifier and TypeMethodDescriptionDelta[]Returns the children of this delta.Returns the parent of this delta: aDeltaNodein folder comparisons, aDeltaRangein text comparisons.booleanAnswers whether this delta has children, based on the information available so far; this method does not start, or wait for, a comparison.booleanisAdded()Checks whether the overall result represented by thisDeltaisDelta.Kind.ADDED, that is, whether every relation is eitherADDEDorDelta.Kind.SAME, and at least one isADDED.booleanChecks whether the overall result represented by thisDeltaisDelta.Kind.CHANGED, that is, whether every relation is eitherCHANGEDorDelta.Kind.SAME, and at least one isCHANGED.booleanChecks whether the overall result represented by thisDeltais a conflict.booleanChecks whether the overall result represented by thisDeltaisDelta.Kind.DELETED, that is, whether every relation is eitherDELETEDorDelta.Kind.SAME, and at least one isDELETED.booleanisOverallKind(Delta.Kind kind) Checks whether the overall result is of the specifiedDelta.Kind: whether every relation is either of that kind orDelta.Kind.SAME, and at least one is of that kind.booleanbooleanisSame()Checks whether the overall result represented by thisDeltaisDelta.Kind.SAME, that is, whether there is no difference in any relation.Returns theDelta.Kindof difference within the specified relation, that is, pair of roles.
-
Method Details
-
getChildren
Delta[] getChildren()Returns the children of this delta. In a text comparison the children areDeltaRanges representing differences within a block of text, also known as inline differences. In a folder comparison they areDeltaNodes representing the files and folders inside this folder.- Returns:
- an array of child deltas; empty, never
null, when there are no children
-
getParent
Delta getParent()Returns the parent of this delta: aDeltaNodein folder comparisons, aDeltaRangein text comparisons.The parent is
nullin these cases:- in folder comparisons, for the root node;
- in text comparisons, for top-level blocks of text. Only inline differences have a parent: the block of text that contains them.
- Returns:
- the parent of this
Delta, ornull - Since:
- 2.0
-
hasChildren
boolean hasChildren()Answers whether this delta has children, based on the information available so far; this method does not start, or wait for, a comparison.- Returns:
trueif this delta has children,falseotherwise- Since:
- 2.0
-
isAdded
boolean isAdded()Checks whether the overall result represented by thisDeltaisDelta.Kind.ADDED, that is, whether every relation is eitherADDEDorDelta.Kind.SAME, and at least one isADDED.- Returns:
trueif this difference is of typeKind#ADDED,falseotherwise.- Since:
- 2.0
- See Also:
-
isChanged
boolean isChanged()Checks whether the overall result represented by thisDeltaisDelta.Kind.CHANGED, that is, whether every relation is eitherCHANGEDorDelta.Kind.SAME, and at least one isCHANGED.- Returns:
trueif this difference is of typeKind#CHANGED,falseotherwise.- Since:
- 2.0
- See Also:
-
isConflict
boolean isConflict()Checks whether the overall result represented by thisDeltais a conflict. In addition to the fourDelta.Kinds, the overall result of a three-way comparison can be a conflict or a pseudo-conflict. In a conflict, bothRole.ONEandRole.TWOdiffer fromRole.REFand also differ from each other. In a pseudo-conflict,Role.ONEandRole.TWOhave changed in the same way relative toRole.REF, so they are the same when compared with each other.Always
falsein a two-way comparison.- Returns:
trueif this difference is a conflict,falseotherwise.- Since:
- 2.0
-
isDeleted
boolean isDeleted()Checks whether the overall result represented by thisDeltaisDelta.Kind.DELETED, that is, whether every relation is eitherDELETEDorDelta.Kind.SAME, and at least one isDELETED.- Returns:
trueif this difference is of typeKind#DELETED,falseotherwise.- Since:
- 2.0
- See Also:
-
isOverallKind
Checks whether the overall result is of the specifiedDelta.Kind: whether every relation is either of that kind orDelta.Kind.SAME, and at least one is of that kind.Most of the time it is the overall result that matters. In a three-way comparison with a conflict or pseudo-conflict this method returns
falsefor every kind other thanSAME, because the relations differ in more than one way.To get the exact
Delta.Kindof a single relation, usekind(Role[]).- Parameters:
kind- the kind to check for- Returns:
trueif the 'overall'Kindof thisDeltais the same as the specifiedkind.- Since:
- 2.0
- See Also:
-
isPseudoConflict
boolean isPseudoConflict()Answers whether the overall result represented by thisDeltais a pseudo-conflict:Role.ONEandRole.TWOboth differ fromRole.REFbut are the same as each other. Alwaysfalsein a two-way comparison.- Returns:
trueif this difference is a pseudo-conflict,falseotherwise.- Since:
- 2.0
- See Also:
-
isSame
boolean isSame()Checks whether the overall result represented by thisDeltaisDelta.Kind.SAME, that is, whether there is no difference in any relation.- Returns:
trueif this difference is of typeKind#SAME,falseotherwise.- Since:
- 2.0
- See Also:
-
kind
Returns theDelta.Kindof difference within the specified relation, that is, pair of roles. A two-way comparison has a single relation,Role.REFandRole.ONE. A three-way comparison has three:Role.REFandRole.ONE,Role.REFandRole.TWO, andRole.ONEandRole.TWO.const kind = delta.kind([Role.ONE, Role.REF]); if (kind == Delta.Kind.ADDED) { ... }Most of the time, however, it is the overall kind that matters: the kind that results from all relations together, which is also what the DeltaWalker UI shows. Use the
is...()methods for that.A relation does not depend on the order of its roles: the kind of
[Role.REF, Role.ONE]is the same as that of[Role.ONE, Role.REF]. When one of the roles isRole.REF,Delta.Kind.ADDEDandDelta.Kind.DELETEDare reported relative to that reference role. When a relation does not includeRole.REF, for instanceRole.ONEandRole.TWO, any difference is reported asDelta.Kind.CHANGED; whether content was added or deleted can be worked out from the other two relations.- Parameters:
relation- the two roles of the relation, in any order- Returns:
- the
Kindof the specifiedrelation - Since:
- 2.0
- See Also:
-