This commit is contained in:
wumpz
2017-04-04 07:21:10 +02:00
parent 0312493e26
commit 11519058d8
5 changed files with 6 additions and 54 deletions

View File

@@ -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: "

View File

@@ -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++) {

View File

@@ -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: "

View File

@@ -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

View File

@@ -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()