mirror of
https://github.com/java-diff-utils/java-diff-utils.git
synced 2026-03-13 10:11:17 +08:00
remove verification from applyTo
This commit is contained in:
@@ -57,10 +57,18 @@ public abstract class AbstractDelta<T> implements Serializable {
|
||||
protected VerifyChunk verifyChunkToFitTarget(List<T> target) throws PatchFailedException {
|
||||
return getSource().verifyChunk(target);
|
||||
}
|
||||
|
||||
protected VerifyChunk verifyAntApplyTo(List<T> target) throws PatchFailedException {
|
||||
final VerifyChunk verify = verifyChunkToFitTarget(target);
|
||||
if (verify == VerifyChunk.OK) {
|
||||
applyTo(target);
|
||||
}
|
||||
return verify;
|
||||
}
|
||||
|
||||
public abstract void applyTo(List<T> target) throws PatchFailedException;
|
||||
protected abstract void applyTo(List<T> target) throws PatchFailedException;
|
||||
|
||||
public abstract void restore(List<T> target);
|
||||
protected abstract void restore(List<T> target);
|
||||
|
||||
/**
|
||||
* Create a new delta of the actual instance with customized chunk data.
|
||||
|
||||
@@ -39,8 +39,7 @@ public final class ChangeDelta<T> extends AbstractDelta<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyTo(List<T> target) throws PatchFailedException {
|
||||
verifyChunk(target);
|
||||
protected void applyTo(List<T> target) throws PatchFailedException {
|
||||
int position = getSource().getPosition();
|
||||
int size = getSource().size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
@@ -54,7 +53,7 @@ public final class ChangeDelta<T> extends AbstractDelta<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restore(List<T> target) {
|
||||
protected void restore(List<T> target) {
|
||||
int position = getTarget().getPosition();
|
||||
int size = getTarget().size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
|
||||
@@ -36,8 +36,7 @@ public final class DeleteDelta<T> extends AbstractDelta<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyTo(List<T> target) throws PatchFailedException {
|
||||
verifyChunk(target);
|
||||
protected void applyTo(List<T> target) throws PatchFailedException {
|
||||
int position = getSource().getPosition();
|
||||
int size = getSource().size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
@@ -46,7 +45,7 @@ public final class DeleteDelta<T> extends AbstractDelta<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restore(List<T> target) {
|
||||
protected void restore(List<T> target) {
|
||||
int position = this.getTarget().getPosition();
|
||||
List<T> lines = this.getSource().getLines();
|
||||
for (int i = 0; i < lines.size(); i++) {
|
||||
|
||||
@@ -28,12 +28,11 @@ public class EqualDelta<T> extends AbstractDelta<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyTo(List<T> target) throws PatchFailedException {
|
||||
verifyChunk(target);
|
||||
protected void applyTo(List<T> target) throws PatchFailedException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restore(List<T> target) {
|
||||
protected void restore(List<T> target) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -36,8 +36,7 @@ public final class InsertDelta<T> extends AbstractDelta<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyTo(List<T> target) throws PatchFailedException {
|
||||
verifyChunk(target);
|
||||
protected void applyTo(List<T> target) throws PatchFailedException {
|
||||
int position = this.getSource().getPosition();
|
||||
List<T> lines = this.getTarget().getLines();
|
||||
for (int i = 0; i < lines.size(); i++) {
|
||||
@@ -46,7 +45,7 @@ public final class InsertDelta<T> extends AbstractDelta<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restore(List<T> target) {
|
||||
protected void restore(List<T> target) {
|
||||
int position = getTarget().getPosition();
|
||||
int size = getTarget().size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
|
||||
Reference in New Issue
Block a user