+ this.soneModificationDetector = soneModificationDetector;
+ this.delay = delay;
+ }
+
+ //
+ // ACCESSORS
+ //
+
+ /**
+ * Sets the Sone to insert.
+ *
+ * @param sone
+ * The Sone to insert
+ * @return This Sone inserter
+ */
+ public SoneInserter setSone(Sone sone) {
+ checkArgument(sone.equals(this.sone), "Sone to insert can not be set to a different Sone");
+ this.sone = sone;
+ return this;
+ }
+
+ @VisibleForTesting
+ static AtomicInteger getInsertionDelay() {
+ return insertionDelay;
+ }
+
+ /**
+ * Changes the insertion delay, i.e. the time the Sone inserter waits after it
+ * has noticed a Sone modification before it starts the insert.
+ *
+ * @param insertionDelay
+ * The insertion delay (in seconds)
+ */
+ public static void setInsertionDelay(int insertionDelay) {
+ SoneInserter.insertionDelay.set(insertionDelay);
+ }
+
+ /**
+ * Returns the fingerprint of the last insert.
+ *
+ * @return The fingerprint of the last insert
+ */
+ public String getLastInsertFingerprint() {
+ return soneModificationDetector.getOriginalFingerprint();
+ }
+
+ /**
+ * Sets the fingerprint of the last insert.
+ *
+ * @param lastInsertFingerprint
+ * The fingerprint of the last insert
+ */
+ public void setLastInsertFingerprint(String lastInsertFingerprint) {
+ soneModificationDetector.setFingerprint(lastInsertFingerprint);
+ }
+
+ /**
+ * Returns whether the Sone inserter has detected a modification of the
+ * Sone.
+ *
+ * @return {@code true} if the Sone has been modified, {@code false}
+ * otherwise
+ */
+ public boolean isModified() {
+ return soneModificationDetector.isModified();