Top Description Fields Constructors Methods
org.assertj.core.util.diff.myers

public Class MyersDiff<T>

extends Object
implements DiffAlgorithm<T>
Class Inheritance
All Implemented Interfaces
org.assertj.core.util.diff.DiffAlgorithm
Type Parameters
<T>
The type of the compared elements in the 'lines'.
Static Imports
org.assertj.core.util.Preconditions.checkArgument, .Preconditions.checkState

Copy from https://code.google.com/p/java-diff-utils/.

A clean-room implementation of Eugene Myers differencing algorithm.

See the paper at http://www.cs.arizona.edu/people/gene/PAPERS/diff.ps

Author
Juanco Anez

Field Summary

Modifier and TypeField and Description
private final Equalizer<T>
equalizer

The equalizer.

Constructor Summary

AccessConstructor and Description
public
MyersDiff()

Constructs an instance of the Myers differencing algorithm.

Method Summary

Modifier and TypeMethod and Description
public PathNode

Returns:

A minimum Path across the differences graph.
buildPath
(final List<T>
The original sequence.
orig
,
final List<T>
The revised sequence.
rev
)

Computes the minimum diffpath that expresses de differences between the original and revised sequences, according to Gene Myers differencing algorithm.

public Patch<T>

Returns:

A Patch script corresponding to the path.
buildRevision
(PathNode
The path.
path
,
List<T>
The original sequence.
orig
,
List<T>
The revised sequence.
rev
)

Constructs a Patch from a difference path.

private List<T>

Returns:

A new list of the specified range within the original list.
copyOfRange
(final List<T>
The original sequence. Must not be null.
original
,
final int
low endpoint (inclusive) of the subList.
fromIndex
,
final int
high endpoint (exclusive) of the subList.
to
)

Creates a new list containing the elements returned by List#subList(int, int).

public Patch<T>
diff(final List<T>
The original sequence. Must not be null.
original
,
final List<T>
The revised sequence. Must not be null.
revised
)

Implements org.assertj.core.util.diff.DiffAlgorithm.diff.

Computes the difference between the original sequence and the revised sequence and returns it as a Patch object.
private boolean
equals(T orig, T rev)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

equalizerback to summary
private final Equalizer<T> equalizer

The equalizer.

Constructor Detail

MyersDiffback to summary
public MyersDiff()

Constructs an instance of the Myers differencing algorithm.

Method Detail

buildPathback to summary
public PathNode buildPath(final List<T> orig, final List<T> rev)

Computes the minimum diffpath that expresses de differences between the original and revised sequences, according to Gene Myers differencing algorithm.

Parameters
orig:List<T>

The original sequence.

rev:List<T>

The revised sequence.

Returns:PathNode

A minimum Path across the differences graph.

Exceptions
IllegalStateException:
if a diff path could not be found.
buildRevisionback to summary
public Patch<T> buildRevision(PathNode path, List<T> orig, List<T> rev)

Constructs a Patch from a difference path.

Parameters
path:PathNode

The path.

orig:List<T>

The original sequence.

rev:List<T>

The revised sequence.

Returns:Patch<T>

A Patch script corresponding to the path.

copyOfRangeback to summary
private List<T> copyOfRange(final List<T> original, final int fromIndex, final int to)

Creates a new list containing the elements returned by List#subList(int, int).

Parameters
original:List<T>

The original sequence. Must not be null.

fromIndex:int

low endpoint (inclusive) of the subList.

to:int

high endpoint (exclusive) of the subList.

Returns:List<T>

A new list of the specified range within the original list.

diffback to summary
public Patch<T> diff(final List<T> original, final List<T> revised)

Implements org.assertj.core.util.diff.DiffAlgorithm.diff.

Doc from org.assertj.core.util.diff.DiffAlgorithm.diff.

Computes the difference between the original sequence and the revised sequence and returns it as a Patch object. Return empty diff if get the error while procession the difference.

Parameters
original:List<T>

The original sequence. Must not be null.

revised:List<T>

The revised sequence. Must not be null.

Returns:Patch<T>

The patch representing the diff of the given sequences. Never null.

Annotations
@Override
equalsback to summary
private boolean equals(T orig, T rev)