Rename fields to better reflect their purpose
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 22 Jul 2015 04:43:00 +0000 (06:43 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 22 Jul 2015 04:43:00 +0000 (06:43 +0200)
src/main/java/net/pterodactylus/sone/core/SoneInserter.java
src/main/java/net/pterodactylus/sone/core/SoneModificationDetector.java
src/test/java/net/pterodactylus/sone/core/SoneModificationDetectorTest.java

index 45c617c..dbb7ef1 100644 (file)
@@ -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();
        }
 
        /**
index 71c28bb..810241a 100644 (file)
@@ -27,8 +27,8 @@ class SoneModificationDetector {
        private final LockableFingerprintProvider lockableFingerprintProvider;
        private final AtomicInteger insertionDelay;
        private Optional<Long> 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);
        }
 
        /**
index 8153e3b..230f0b6 100644 (file)
@@ -71,7 +71,7 @@ public class SoneModificationDetectorTest {
 
        @Test
        public void originalFingerprintIsRetained() {
-               assertThat(soneModificationDetector.getOriginalFingerprint(), is("original"));
+               assertThat(soneModificationDetector.getLastInsertFingerprint(), is("original"));
        }
 
        @Test