Package com.helger.photon.api
Class APIDescriptor
- java.lang.Object
-
- com.helger.photon.api.APIDescriptor
-
- All Implemented Interfaces:
IAPIDescriptor
@NotThreadSafe public class APIDescriptor extends Object implements IAPIDescriptor
Default implementation ofIAPIDescriptor.- Author:
- Philip Helger
-
-
Constructor Summary
Constructors Constructor Description APIDescriptor(APIPath aPath, IAPIExecutor aExecutor)ConstructorAPIDescriptor(APIPath aPath, Class<? extends IAPIExecutor> aExecutorClass)ConstructorAPIDescriptor(APIPath aPath, Supplier<? extends IAPIExecutor> aExecutorFactory)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description APIDescriptoraddRequiredHeader(String sHeaderName)Add a required HTTP header.APIDescriptoraddRequiredHeaders(String... aHeaderNames)Add one or more required HTTP headers.APIDescriptoraddRequiredParam(String sParamName)Add a required request parameter.APIDescriptoraddRequiredParams(String... aParamNames)Add one or more required request parameters.com.helger.commons.collection.impl.ICommonsOrderedSet<String>allowedMimeTypes()APIPathgetAPIPath()IAPIExceptionMappergetExceptionMapper()IAPIExecutionFiltergetExecutionFilter()Supplier<? extends IAPIExecutor>getExecutorFactory()PathDescriptorgetPathDescriptor()com.helger.commons.collection.impl.ICommonsOrderedSet<String>requiredHeaders()com.helger.commons.collection.impl.ICommonsOrderedSet<String>requiredParams()APIDescriptorsetExceptionMapper(IAPIExceptionMapper aExceptionMapper)APIDescriptorsetExecutionFilter(IAPIExecutionFilter aExecutionFilter)StringtoString()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.helger.photon.api.IAPIDescriptor
getHttpMethod, hasExceptionMapper, hasExecutionFilter
-
-
-
-
Constructor Detail
-
APIDescriptor
public APIDescriptor(@Nonnull APIPath aPath, @Nonnull IAPIExecutor aExecutor)
Constructor- Parameters:
aPath- API Path to be used. May not benull.aExecutor- The executor to be invoked for that API. May not benull.
-
APIDescriptor
public APIDescriptor(@Nonnull APIPath aPath, @Nonnull Class<? extends IAPIExecutor> aExecutorClass)
Constructor- Parameters:
aPath- API Path to be used. May not benull.aExecutorClass- The executor class to be instantiated for every API invocation. May not benull.
-
APIDescriptor
public APIDescriptor(@Nonnull APIPath aPath, @Nonnull Supplier<? extends IAPIExecutor> aExecutorFactory)
Constructor- Parameters:
aPath- API Path to be used. May not benull.aExecutorFactory- The factory to be used to create executor instances for every API invocation. May not benull.
-
-
Method Detail
-
getAPIPath
@Nonnull public final APIPath getAPIPath()
- Specified by:
getAPIPathin interfaceIAPIDescriptor- Returns:
- The API path used. Never
null.
-
getPathDescriptor
@Nonnull public final PathDescriptor getPathDescriptor()
- Specified by:
getPathDescriptorin interfaceIAPIDescriptor- Returns:
- The path descriptor required to call this API.
-
getExecutorFactory
@Nonnull public final Supplier<? extends IAPIExecutor> getExecutorFactory()
- Specified by:
getExecutorFactoryin interfaceIAPIDescriptor- Returns:
- The non-
nullfactory used to create the main invoker.
-
addRequiredHeader
@Nonnull public final APIDescriptor addRequiredHeader(@Nullable String sHeaderName)
Add a required HTTP header. If this HTTP header is not present, invocation will not be possible.- Parameters:
sHeaderName- The name of the required HTTP header. May benullor empty in which case the header is ignored.- Returns:
- this for chaining
- See Also:
addRequiredHeaders(String...)
-
addRequiredHeaders
@Nonnull public final APIDescriptor addRequiredHeaders(@Nullable String... aHeaderNames)
Add one or more required HTTP headers. If one of these HTTP headers are not present, invocation will not be possible.- Parameters:
aHeaderNames- The names of the required HTTP headers. May benullor empty.- Returns:
- this for chaining
- See Also:
addRequiredHeader(String)
-
requiredHeaders
@Nonnull @ReturnsMutableObject public final com.helger.commons.collection.impl.ICommonsOrderedSet<String> requiredHeaders()
- Specified by:
requiredHeadersin interfaceIAPIDescriptor- Returns:
- The names of all required HTTP headers. Never
nullbut maybe empty.
-
addRequiredParam
@Nonnull public final APIDescriptor addRequiredParam(@Nullable String sParamName)
Add a required request parameter. If this request parameter is not present, invocation will not be possible.- Parameters:
sParamName- The name of the required request parameter. May benullor empty in which case the parameter is ignored.- Returns:
- this for chaining
- See Also:
addRequiredParams(String...)
-
addRequiredParams
@Nonnull public final APIDescriptor addRequiredParams(@Nullable String... aParamNames)
Add one or more required request parameters. If one of these request parameters are not present, invocation will not be possible.- Parameters:
aParamNames- The names of the required HTTP parameters. May benullor empty.- Returns:
- this for chaining
- See Also:
addRequiredParam(String)
-
requiredParams
@Nonnull @ReturnsMutableObject public final com.helger.commons.collection.impl.ICommonsOrderedSet<String> requiredParams()
- Specified by:
requiredParamsin interfaceIAPIDescriptor- Returns:
- The names of all required request parameters. Never
nullbut maybe empty.
-
allowedMimeTypes
@Nonnull @ReturnsMutableObject public final com.helger.commons.collection.impl.ICommonsOrderedSet<String> allowedMimeTypes()
- Specified by:
allowedMimeTypesin interfaceIAPIDescriptor- Returns:
- The names of all allowed MIME types for the data. Never
nullbut maybe empty. Only MIME types without parameters (as in ";x=y") should be added here. Also unified casing should be considered.
-
getExecutionFilter
@Nullable public final IAPIExecutionFilter getExecutionFilter()
- Specified by:
getExecutionFilterin interfaceIAPIDescriptor- Returns:
- The current execution filter. May be
null.
-
setExecutionFilter
@Nonnull public final APIDescriptor setExecutionFilter(@Nullable IAPIExecutionFilter aExecutionFilter)
-
getExceptionMapper
@Nullable public final IAPIExceptionMapper getExceptionMapper()
- Specified by:
getExceptionMapperin interfaceIAPIDescriptor- Returns:
- The exception mapper for this descriptor. May be
null.
-
setExceptionMapper
@Nonnull public final APIDescriptor setExceptionMapper(@Nullable IAPIExceptionMapper aExceptionMapper)
-
-