package com.atlassian.bitbucket.internal.cluster;

import com.atlassian.bitbucket.cluster.ClusterService;
import com.atlassian.plugin.PluginParseException;
import com.atlassian.plugin.web.Condition;

import java.util.Map;

public class IsClusteringAvailableAndRunningCondition implements Condition {

    private final ClusterService clusterService;

    public IsClusteringAvailableAndRunningCondition(ClusterService clusterService) {
        this.clusterService = clusterService;
    }

    @Override
    public void init(Map<String, String> stringStringMap) throws PluginParseException {
    }

    @Override
    public boolean shouldDisplay(Map<String, Object> stringObjectMap) {
        return clusterService.isAvailable() && clusterService.getInformation().isRunning();
    }
}
