mirror of https://github.com/micromata/borgbackup-butler.git

Kai Reinhard
08.45.2018 e01e6d75d5667a723b6aebd0abfebe323514f7fa
borgbutler-core/src/main/java/de/micromata/borgbutler/cache/AbstractCache.java
@@ -3,6 +3,7 @@
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import de.micromata.borgbutler.json.JsonUtils;
import de.micromata.borgbutler.json.borg.RepositoryMatcher;
import lombok.Getter;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
@@ -38,11 +39,26 @@
        return null;
    }
    public abstract boolean matches(T element, String identifier);
    public boolean matches(T element, String identifier) {
        if (!(element instanceof RepositoryMatcher)) {
            throw new UnsupportedOperationException("matches not implemented, only available for RepositoryMatcher: " + this.getClass());
        }
        return ((RepositoryMatcher) element).matches(identifier);
    }
    public abstract String getIdentifier(T element);
    public String getIdentifier(T element) {
        if (!(element instanceof RepositoryMatcher)) {
            throw new UnsupportedOperationException("matches not implemented, only available for RepositoryMatcher: " + this.getClass());
        }
        return ((RepositoryMatcher)element).getRepository().getId();
    }
    public abstract void updateFrom(T dest, T source);
    public void updateFrom(T dest, T source) {
        if (!(dest instanceof RepositoryMatcher)) {
            throw new UnsupportedOperationException("matches not implemented, only available for RepositoryMatcher: " + this.getClass());
        }
        ((RepositoryMatcher)dest).updateFrom(((RepositoryMatcher)source));
    }
    /**
     * Removes all entries (doesn't effect the cache files!).