package com.atlassian.bitbucket.mesh.request;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

/**
 * Callback provided to callers of {@link RequestManager#withContext(RequestDescriptor, RequestCallback)}.
 *
 * @param <T> the type returned by the callback
 */
@FunctionalInterface
public interface RequestCallback<T> {

    /**
     * Called with a {@link RequestContext} to perform processing related to the request.
     *
     * @param context the request context
     * @return the value to return from {@link RequestManager#withContext}, which may be {@code null}
     */
    @Nullable
    T callWithRequest(@Nonnull RequestContext context);
}
