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

public abstract Class Delta<T>

extends Object
Class Inheritance
Known Direct Subclasses
org.assertj.core.util.diff.InsertDelta, org.assertj.core.util.diff.ChangeDelta, org.assertj.core.util.diff.DeleteDelta
Type Parameters
<T>
The type of the compared elements in the 'lines'.
Static Imports
org.assertj.core.util.Preconditions.checkArgument

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

Describes the delta between original and revised texts.

Author
Dmitry Naumenko

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
Delta.TYPE

Specifies the type of the delta.

Field Summary

Modifier and TypeField and Description
public static final String
public static final String
private Chunk<T>
original

The original chunk.

private Chunk<T>
revised

The revised chunk.

Constructor Summary

AccessConstructor and Description
public
Delta(Chunk<T>
Chunk describing the original text. Must not be null.
original
,
Chunk<T>
Chunk describing the revised text. Must not be null.
revised
)

Construct the delta for original and revised chunks

Method Summary

Modifier and TypeMethod and Description
public abstract void
applyTo(List<T>
the given target
target
)

Applies this delta as the patch for a given target

public boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public Chunk<T>

Returns:

The Chunk describing the original text.
getOriginal
()

public Chunk<T>

Returns:

The Chunk describing the revised text.
getRevised
()

public abstract Delta.TYPE

Returns:

the type enum
getType
()

Returns the type of delta

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.
public int
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public abstract void
verify(List<T>
the text to patch.
target
)

Verifies that this delta can be used to patch the given text.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

DEFAULT_ENDback to summary
public static final String DEFAULT_END
DEFAULT_STARTback to summary
public static final String DEFAULT_START
originalback to summary
private Chunk<T> original

The original chunk.

revisedback to summary
private Chunk<T> revised

The revised chunk.

Constructor Detail

Deltaback to summary
public Delta(Chunk<T> original, Chunk<T> revised)

Construct the delta for original and revised chunks

Parameters
original:Chunk<T>

Chunk describing the original text. Must not be null.

revised:Chunk<T>

Chunk describing the revised text. Must not be null.

Method Detail

applyToback to summary
public abstract void applyTo(List<T> target) throws IllegalStateException

Applies this delta as the patch for a given target

Parameters
target:List<T>

the given target

Exceptions
IllegalStateException:
if verify(List) fails
equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getOriginalback to summary
public Chunk<T> getOriginal()
Returns:Chunk<T>

The Chunk describing the original text.

getRevisedback to summary
public Chunk<T> getRevised()
Returns:Chunk<T>

The Chunk describing the revised text.

getTypeback to summary
public abstract Delta.TYPE getType()

Returns the type of delta

Returns:Delta.TYPE

the type enum

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
lineNumberback to summary
public int lineNumber()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
verifyback to summary
public abstract void verify(List<T> target) throws IllegalStateException

Verifies that this delta can be used to patch the given text.

Parameters
target:List<T>

the text to patch.

Exceptions
IllegalStateException:
if the patch cannot be applied.
org.assertj.core.util.diff back to summary

public final Enum Delta.TYPE

extends Enum<Delta.TYPE>
Class Inheritance

Specifies the type of the delta.

Field Summary

Modifier and TypeField and Description
public static final Delta.TYPE
CHANGE

A change in the original.

public static final Delta.TYPE
DELETE

A delete from the original.

public static final Delta.TYPE
INSERT

An insert into the original.

Constructor Summary

AccessConstructor and Description
private
TYPE()

Method Summary

Modifier and TypeMethod and Description
public static Delta.TYPE
public static Delta.TYPE[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

CHANGEback to summary
public static final Delta.TYPE CHANGE

A change in the original.

DELETEback to summary
public static final Delta.TYPE DELETE

A delete from the original.

INSERTback to summary
public static final Delta.TYPE INSERT

An insert into the original.

Constructor Detail

TYPEback to summary
private TYPE()

Method Detail

valueOfback to summary
public static Delta.TYPE valueOf(String name)
valuesback to summary
public static Delta.TYPE[] values()