forked from Qortal/qortal
Removed ArbitraryDataPatches class
This was essentially just a wrapper for a single method.
This commit is contained in:
parent
4b5bd6eed7
commit
fa684eabab
@ -40,6 +40,7 @@ public class ArbitraryDataBuilder {
|
||||
this.fetchTransactions();
|
||||
this.validateTransactions();
|
||||
this.processTransactions();
|
||||
this.validatePaths();
|
||||
this.buildLatestState();
|
||||
}
|
||||
|
||||
@ -118,10 +119,30 @@ public class ArbitraryDataBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
private void buildLatestState() throws IOException, DataException {
|
||||
ArbitraryDataPatches arbitraryDataPatches = new ArbitraryDataPatches(this.paths);
|
||||
arbitraryDataPatches.applyPatches();
|
||||
this.finalPath = arbitraryDataPatches.getFinalPath();
|
||||
private void validatePaths() {
|
||||
if (this.paths == null || this.paths.isEmpty()) {
|
||||
throw new IllegalStateException(String.format("No paths available from which to build latest state"));
|
||||
}
|
||||
}
|
||||
|
||||
private void buildLatestState() throws IOException {
|
||||
if (this.paths.size() == 1) {
|
||||
// No patching needed
|
||||
this.finalPath = this.paths.get(0);
|
||||
return;
|
||||
}
|
||||
|
||||
Path pathBefore = this.paths.get(0);
|
||||
|
||||
// Loop from the second path onwards
|
||||
for (int i=1; i<paths.size(); i++) {
|
||||
Path pathAfter = this.paths.get(i);
|
||||
ArbitraryDataCombiner combiner = new ArbitraryDataCombiner(pathBefore, pathAfter);
|
||||
combiner.combine();
|
||||
combiner.cleanup();
|
||||
pathBefore = combiner.getFinalPath();
|
||||
}
|
||||
this.finalPath = pathBefore;
|
||||
}
|
||||
|
||||
public Path getFinalPath() {
|
||||
|
@ -1,67 +0,0 @@
|
||||
package org.qortal.arbitrary;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import org.qortal.repository.DataException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
|
||||
public class ArbitraryDataPatches {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger(ArbitraryDataPatches.class);
|
||||
|
||||
private List<Path> paths;
|
||||
private Path finalPath;
|
||||
|
||||
public ArbitraryDataPatches(List<Path> paths) {
|
||||
this.paths = paths;
|
||||
}
|
||||
|
||||
public void applyPatches() throws DataException, IOException {
|
||||
try {
|
||||
this.preExecute();
|
||||
this.process();
|
||||
|
||||
} finally {
|
||||
this.postExecute();
|
||||
}
|
||||
}
|
||||
|
||||
private void preExecute() {
|
||||
if (this.paths == null || this.paths.isEmpty()) {
|
||||
throw new IllegalStateException(String.format("No paths available to build latest state"));
|
||||
}
|
||||
}
|
||||
|
||||
private void postExecute() {
|
||||
|
||||
}
|
||||
|
||||
private void process() throws IOException {
|
||||
if (this.paths.size() == 1) {
|
||||
// No patching needed
|
||||
this.finalPath = this.paths.get(0);
|
||||
return;
|
||||
}
|
||||
|
||||
Path pathBefore = this.paths.get(0);
|
||||
|
||||
// Loop from the second path onwards
|
||||
for (int i=1; i<paths.size(); i++) {
|
||||
Path pathAfter = this.paths.get(i);
|
||||
ArbitraryDataCombiner combiner = new ArbitraryDataCombiner(pathBefore, pathAfter);
|
||||
combiner.combine();
|
||||
combiner.cleanup();
|
||||
pathBefore = combiner.getFinalPath();
|
||||
}
|
||||
this.finalPath = pathBefore;
|
||||
}
|
||||
|
||||
public Path getFinalPath() {
|
||||
return this.finalPath;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user