Package com.github.difflib.patch
Class Patch<T>
- java.lang.Object
-
- com.github.difflib.patch.Patch<T>
-
- Type Parameters:
T- The type of the compared elements in the 'lines'.
- All Implemented Interfaces:
Serializable
public final class Patch<T> extends Object implements Serializable
Describes the patch holding all deltas between the original and revised texts.- Author:
- Dmitry Naumenko
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description ConflictOutput<T>CONFLICT_PRODUCES_EXCEPTIONStandard Patch behaviour to throw an exception for pathching conflicts.static ConflictOutput<String>CONFLICT_PRODUCES_MERGE_CONFLICTGit like merge conflict output.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDelta(AbstractDelta<T> delta)Add the given delta to this patchList<T>applyTo(List<T> target)Apply this patch to the given targetstatic <T> Patch<T>generate(List<T> original, List<T> revised, List<Change> changes)static <T> Patch<T>generate(List<T> original, List<T> revised, List<Change> _changes, boolean includeEquals)List<AbstractDelta<T>>getDeltas()Get the list of computed deltasList<T>restore(List<T> target)Restore the text to original.StringtoString()PatchwithConflictOutput(ConflictOutput<T> conflictOutput)Alter normal conflict output behaviour to e.g.
-
-
-
Field Detail
-
CONFLICT_PRODUCES_EXCEPTION
public final ConflictOutput<T> CONFLICT_PRODUCES_EXCEPTION
Standard Patch behaviour to throw an exception for pathching conflicts.
-
CONFLICT_PRODUCES_MERGE_CONFLICT
public static final ConflictOutput<String> CONFLICT_PRODUCES_MERGE_CONFLICT
Git like merge conflict output.
-
-
Method Detail
-
applyTo
public List<T> applyTo(List<T> target) throws PatchFailedException
Apply this patch to the given target- Returns:
- the patched text
- Throws:
PatchFailedException- if can't apply patch
-
withConflictOutput
public Patch withConflictOutput(ConflictOutput<T> conflictOutput)
Alter normal conflict output behaviour to e.g. inclide some conflict statements in the result, like git does it.
-
restore
public List<T> restore(List<T> target)
Restore the text to original. Opposite to applyTo() method.- Parameters:
target- the given target- Returns:
- the restored text
-
addDelta
public void addDelta(AbstractDelta<T> delta)
Add the given delta to this patch- Parameters:
delta- the given delta
-
getDeltas
public List<AbstractDelta<T>> getDeltas()
Get the list of computed deltas- Returns:
- the deltas
-
generate
public static <T> Patch<T> generate(List<T> original, List<T> revised, List<Change> changes)
-
-