mirror of
https://github.com/java-diff-utils/java-diff-utils.git
synced 2026-03-13 10:11:17 +08:00
This commit is contained in:
@@ -39,11 +39,6 @@ public final class ChangeDelta<T> extends Delta<T> {
|
||||
super(DeltaType.CHANGE, original, revised);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @throws PatchFailedException
|
||||
*/
|
||||
@Override
|
||||
public void applyTo(List<T> target) throws PatchFailedException {
|
||||
verify(target);
|
||||
@@ -59,9 +54,6 @@ public final class ChangeDelta<T> extends Delta<T> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void restore(List<T> target) {
|
||||
int position = getRevised().getPosition();
|
||||
@@ -76,18 +68,6 @@ public final class ChangeDelta<T> extends Delta<T> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void verify(List<T> target) throws PatchFailedException {
|
||||
getOriginal().verify(target);
|
||||
if (getOriginal().getPosition() > target.size()) {
|
||||
throw new PatchFailedException("Incorrect patch for delta: "
|
||||
+ "delta original position > target size");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[ChangeDelta, position: " + getOriginal().getPosition() + ", lines: "
|
||||
|
||||
@@ -68,7 +68,7 @@ public final class Chunk<T> {
|
||||
* @param target the sequence to verify against.
|
||||
*/
|
||||
public void verify(List<T> target) throws PatchFailedException {
|
||||
if (last() > target.size()) {
|
||||
if (position > target.size() || last() > target.size()) {
|
||||
throw new PatchFailedException("Incorrect Chunk: the position of chunk > target size");
|
||||
}
|
||||
for (int i = 0; i < size(); i++) {
|
||||
|
||||
@@ -39,11 +39,6 @@ public final class DeleteDelta<T> extends Delta<T> {
|
||||
super(DeltaType.DELETE, original, revised);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @throws PatchFailedException
|
||||
*/
|
||||
@Override
|
||||
public void applyTo(List<T> target) throws PatchFailedException {
|
||||
verify(target);
|
||||
@@ -53,10 +48,7 @@ public final class DeleteDelta<T> extends Delta<T> {
|
||||
target.remove(position);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void restore(List<T> target) {
|
||||
int position = this.getRevised().getPosition();
|
||||
@@ -66,11 +58,6 @@ public final class DeleteDelta<T> extends Delta<T> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void verify(List<T> target) throws PatchFailedException {
|
||||
getOriginal().verify(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[DeleteDelta, position: " + getOriginal().getPosition() + ", lines: "
|
||||
|
||||
@@ -79,7 +79,9 @@ public abstract class Delta<T> {
|
||||
* @param target the text to patch.
|
||||
* @throws PatchFailedException if the patch cannot be applied.
|
||||
*/
|
||||
public abstract void verify(List<T> target) throws PatchFailedException;
|
||||
public void verify(List<T> target) throws PatchFailedException {
|
||||
getOriginal().verify(target);
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies this delta as the patch for a given target
|
||||
|
||||
@@ -39,11 +39,6 @@ public final class InsertDelta<T> extends Delta<T> {
|
||||
super(DeltaType.INSERT, original, revised);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @throws PatchFailedException
|
||||
*/
|
||||
@Override
|
||||
public void applyTo(List<T> target) throws PatchFailedException {
|
||||
verify(target);
|
||||
@@ -53,10 +48,7 @@ public final class InsertDelta<T> extends Delta<T> {
|
||||
target.add(position + i, lines.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void restore(List<T> target) {
|
||||
int position = getRevised().getPosition();
|
||||
@@ -66,15 +58,6 @@ public final class InsertDelta<T> extends Delta<T> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void verify(List<T> target) throws PatchFailedException {
|
||||
if (getOriginal().getPosition() > target.size()) {
|
||||
throw new PatchFailedException("Incorrect patch for delta: "
|
||||
+ "delta original position > target size");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[InsertDelta, position: " + getOriginal().getPosition()
|
||||
|
||||
Reference in New Issue
Block a user