From: David ‘Bombe’ Roden Date: Wed, 22 Jul 2015 04:43:00 +0000 (+0200) Subject: Rename fields to better reflect their purpose X-Git-Tag: 0.9.3^2~5 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=34cc31a6120dce9f25652e002f25697dc0596567;p=Sone.git Rename fields to better reflect their purpose --- diff --git a/src/main/java/net/pterodactylus/sone/core/SoneInserter.java b/src/main/java/net/pterodactylus/sone/core/SoneInserter.java index 45c617c..dbb7ef1 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneInserter.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneInserter.java @@ -180,7 +180,7 @@ public class SoneInserter extends AbstractService { * @return The fingerprint of the last insert */ public String getLastInsertFingerprint() { - return soneModificationDetector.getOriginalFingerprint(); + return soneModificationDetector.getLastInsertFingerprint(); } /** diff --git a/src/main/java/net/pterodactylus/sone/core/SoneModificationDetector.java b/src/main/java/net/pterodactylus/sone/core/SoneModificationDetector.java index 71c28bb..810241a 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneModificationDetector.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneModificationDetector.java @@ -27,8 +27,8 @@ class SoneModificationDetector { private final LockableFingerprintProvider lockableFingerprintProvider; private final AtomicInteger insertionDelay; private Optional lastModificationTime; - private String originalFingerprint; - private String lastFingerprint; + private String lastInsertFingerprint; + private String lastCheckFingerprint; SoneModificationDetector(LockableFingerprintProvider lockableFingerprintProvider, AtomicInteger insertionDelay) { this(systemTicker(), lockableFingerprintProvider, insertionDelay); @@ -39,36 +39,36 @@ class SoneModificationDetector { this.ticker = ticker; this.lockableFingerprintProvider = lockableFingerprintProvider; this.insertionDelay = insertionDelay; - lastFingerprint = originalFingerprint; + lastCheckFingerprint = lastInsertFingerprint; } public boolean isEligibleForInsert() { if (lockableFingerprintProvider.isLocked()) { lastModificationTime = absent(); - lastFingerprint = ""; + lastCheckFingerprint = ""; return false; } String fingerprint = lockableFingerprintProvider.getFingerprint(); - if (fingerprint.equals(originalFingerprint)) { + if (fingerprint.equals(lastInsertFingerprint)) { lastModificationTime = absent(); - lastFingerprint = fingerprint; + lastCheckFingerprint = fingerprint; return false; } - if (!Objects.equal(lastFingerprint, fingerprint)) { + if (!Objects.equal(lastCheckFingerprint, fingerprint)) { lastModificationTime = of(ticker.read()); - lastFingerprint = fingerprint; + lastCheckFingerprint = fingerprint; return false; } return insertionDelayHasPassed(); } - public String getOriginalFingerprint() { - return originalFingerprint; + public String getLastInsertFingerprint() { + return lastInsertFingerprint; } public void setFingerprint(String fingerprint) { - originalFingerprint = fingerprint; - lastFingerprint = originalFingerprint; + lastInsertFingerprint = fingerprint; + lastCheckFingerprint = lastInsertFingerprint; lastModificationTime = absent(); } @@ -77,7 +77,7 @@ class SoneModificationDetector { } public boolean isModified() { - return !Objects.equal(lockableFingerprintProvider.getFingerprint(), originalFingerprint); + return !Objects.equal(lockableFingerprintProvider.getFingerprint(), lastInsertFingerprint); } /** diff --git a/src/test/java/net/pterodactylus/sone/core/SoneModificationDetectorTest.java b/src/test/java/net/pterodactylus/sone/core/SoneModificationDetectorTest.java index 8153e3b..230f0b6 100644 --- a/src/test/java/net/pterodactylus/sone/core/SoneModificationDetectorTest.java +++ b/src/test/java/net/pterodactylus/sone/core/SoneModificationDetectorTest.java @@ -71,7 +71,7 @@ public class SoneModificationDetectorTest { @Test public void originalFingerprintIsRetained() { - assertThat(soneModificationDetector.getOriginalFingerprint(), is("original")); + assertThat(soneModificationDetector.getLastInsertFingerprint(), is("original")); } @Test