package com.atlassian.bitbucket.mesh.git.gc;

import org.apache.commons.lang3.StringUtils;

import javax.annotation.Nonnull;

import static com.atlassian.bitbucket.mesh.git.GitConstants.CONFIG_GC_PRUNE_EXPIRE_NEVER;

/**
 * Describes GC configuration for a repository.
 */
class GcSettings {

    private final String pruneExpire;

    GcSettings(String pruneExpire, String defaultPruneExpire) {
        this.pruneExpire = StringUtils.defaultIfBlank(pruneExpire, defaultPruneExpire);
    }

    @Nonnull
    String getPruneExpire() {
        return pruneExpire;
    }

    boolean isPruneEnabled() {
        return !isPruneDisabled();
    }

    boolean isPruneDisabled() {
        return CONFIG_GC_PRUNE_EXPIRE_NEVER.equals(pruneExpire);
    }
}
