class FileBackedFingerprintRepository implements FingerprintRepository {

  @Override
  public void addFingerprint(String identifier, Bytes fingerprint) {
    if (!contains(identifier, fingerprint)) {
      synchronized (this) {
        if (!contains(identifier, fingerprint)) {
          // put into a copy first, then atomically replace
          HashMap<String, Bytes> fingerprintsCopy = new HashMap<>(fingerprints);
          fingerprintsCopy.put(identifier, fingerprint);
          fingerprints = writeFingerprintFile(fingerprintFile, fingerprintsCopy);
        }
      }
    }
  }

    FileBackedFingerprintRepository(Path fingerprintFile);

}