package com.atlassian.bitbucket.internal.integration.jira.idx;

import com.atlassian.bitbucket.integration.jira.JiraConstants;
import com.atlassian.integration.jira.JiraService;
import com.atlassian.bitbucket.idx.CommitPropertyConfiguration;
import com.atlassian.bitbucket.repository.Repository;

import java.util.Collection;
import java.util.Collections;
import java.util.Set;

/**
 * @since 4.0
 */
public class JiraCommitPropertyConfiguration implements CommitPropertyConfiguration {

    public static final Set<String> ISSUE_KEYS = Collections.singleton(JiraConstants.IDX_PROP_ISSUE_KEYS);

    private final JiraService jiraService;

    public JiraCommitPropertyConfiguration(JiraService jiraService) {
        this.jiraService = jiraService;
    }

    @Override
    public Collection<String> getPropertiesToPreload(Repository repository) {
        return jiraService.isLinked() ? ISSUE_KEYS : Collections.<String>emptySet();
    }
}
