package com.atlassian.bitbucket.rest.fragment;

import javax.annotation.Nonnull;
import java.util.Map;

/**
 * Factory for {@link RestFragments}. Use to get the {@link RestFragments} for a particular REST endpoint.
 *
 * @see RestFragments
 * @since 4.7
 */
public interface RestFragmentsFactory {

    /**
     * Checks if any REST fragment is associated with a REST endpoint key.
     *
     * @param restKey the key of the REST endpoint to check for associated REST fragments
     * @return {@code true} if any REST fragment is associated with the key
     */
    boolean existsForKey(@Nonnull String restKey);

    /**
     * Gets the REST fragments associated with a REST endpoint key.
     *
     * @param restKey the key of the REST endpoint to retrieve {@link RestFragment}s for
     * @param requestContext any properties provided by the request (such as the project, repository, or pull request,
     *                       if relevant)
     * @return {@link RestFragments} collating all {@link RestFragment}s registered for the specified key
     */
    @Nonnull
    RestFragments forKey(@Nonnull String restKey, @Nonnull Map<String, Object> requestContext);
}