mirror of
https://github.com/java-diff-utils/java-diff-utils.git
synced 2026-03-13 10:11:17 +08:00
add type information to the interface
This commit is contained in:
@@ -84,4 +84,9 @@ public class ChangeDelta extends Delta {
|
||||
return "[ChangeDelta, position: " + getOriginal().getPosition() + ", lines: "
|
||||
+ getOriginal().getLines() + " to " + getRevised().getLines() + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public TYPE getType() {
|
||||
return Delta.TYPE.CHANGE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,6 +58,11 @@ public class DeleteDelta extends Delta {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TYPE getType() {
|
||||
return Delta.TYPE.DELETE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void verify(List<?> target) throws PatchFailedException {
|
||||
getOriginal().verify(target);
|
||||
|
||||
@@ -26,6 +26,10 @@ public abstract class Delta {
|
||||
private Chunk original;
|
||||
private Chunk revised;
|
||||
|
||||
public enum TYPE {
|
||||
CHANGE, DELETE, INSERT
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the delta for original and revised chunks
|
||||
*
|
||||
@@ -61,6 +65,12 @@ public abstract class Delta {
|
||||
*/
|
||||
public abstract void restore(List<Object> target);
|
||||
|
||||
/**
|
||||
* Returns the type of delta
|
||||
* @return the type enum
|
||||
*/
|
||||
public abstract TYPE getType();
|
||||
|
||||
/**
|
||||
* @return the Chunk describing the original text
|
||||
*/
|
||||
|
||||
@@ -66,6 +66,10 @@ public class InsertDelta extends Delta {
|
||||
|
||||
}
|
||||
|
||||
public TYPE getType() {
|
||||
return Delta.TYPE.INSERT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[InsertDelta, position: " + getOriginal().getPosition() + ", lines: "
|
||||
|
||||
Reference in New Issue
Block a user