mirror of
https://github.com/java-diff-utils/java-diff-utils.git
synced 2026-03-13 10:11:17 +08:00
Repo init
This commit is contained in:
42
src/difflib/Patch.java
Normal file
42
src/difflib/Patch.java
Normal file
@@ -0,0 +1,42 @@
|
||||
package difflib;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Describes the patch holding all deltas between the original and revised texts.
|
||||
*
|
||||
* @author <a href="dm.naumenko@gmail.com">Dmitry Naumenko</a>
|
||||
*/
|
||||
public class Patch {
|
||||
private List<Delta> deltas = new LinkedList<Delta>();
|
||||
|
||||
public List<?> applyTo(List<?> target) {
|
||||
List<Object> result = new LinkedList<Object>(target);
|
||||
for (Delta delta: deltas) {
|
||||
delta.applyTo(result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given delta to this patch
|
||||
* @param delta the given delta
|
||||
*/
|
||||
public void addDelta(Delta delta) {
|
||||
deltas.add(delta);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param deltas the deltas to set
|
||||
*/
|
||||
public void setDeltas(List<Delta> deltas) {
|
||||
this.deltas = deltas;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the deltas
|
||||
*/
|
||||
public List<Delta> getDeltas() {
|
||||
return deltas;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user