Class AbstractErrorResponseAdapter<T extends org.eclipse.ditto.signals.commands.base.ErrorResponse<T>>
- java.lang.Object
-
- org.eclipse.ditto.protocoladapter.AbstractErrorResponseAdapter<T>
-
- Type Parameters:
T
- the type of theErrorResponse
- All Implemented Interfaces:
Adapter<T>
,ErrorResponseAdapter<T>
public abstract class AbstractErrorResponseAdapter<T extends org.eclipse.ditto.signals.commands.base.ErrorResponse<T>> extends Object implements ErrorResponseAdapter<T>
Adapter for mapping aErrorResponse
to and from anAdaptable
.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractErrorResponseAdapter(HeaderTranslator headerTranslator, org.eclipse.ditto.signals.base.ErrorRegistry<org.eclipse.ditto.model.base.exceptions.DittoRuntimeException> errorRegistry)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract T
buildErrorResponse(TopicPath topicPath, org.eclipse.ditto.model.base.exceptions.DittoRuntimeException exception, org.eclipse.ditto.model.base.headers.DittoHeaders dittoHeaders)
Implementations can build theErrorResponse
from the given parameters.T
fromAdaptable(Adaptable adaptable)
Maps the givenadaptable
to its correspondingT
.abstract TopicPathBuilder
getTopicPathBuilder(T errorResponse)
Implementations must provide aTopicPathBuilder
for the givenerrorResponse
.static org.eclipse.ditto.model.base.exceptions.DittoRuntimeException
parseWithErrorRegistry(org.eclipse.ditto.json.JsonObject errorJson, org.eclipse.ditto.model.base.headers.DittoHeaders dittoHeaders, org.eclipse.ditto.signals.base.ErrorRegistry<?> errorRegistry)
Parse an error JSON using an error registry, or construct a genericDittoRuntimeException
if the error code is not in the registry.Adaptable
toAdaptable(T errorResponse, TopicPath.Channel channel)
Maps the givent
to its correspondingAdaptable
.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.eclipse.ditto.protocoladapter.Adapter
getChannels, getGroups, getSearchActions, requiresSubject, toAdaptable
-
Methods inherited from interface org.eclipse.ditto.protocoladapter.ErrorResponseAdapter
getActions, getCriteria, isForResponses
-
-
-
-
Constructor Detail
-
AbstractErrorResponseAdapter
protected AbstractErrorResponseAdapter(HeaderTranslator headerTranslator, org.eclipse.ditto.signals.base.ErrorRegistry<org.eclipse.ditto.model.base.exceptions.DittoRuntimeException> errorRegistry)
-
-
Method Detail
-
parseWithErrorRegistry
public static org.eclipse.ditto.model.base.exceptions.DittoRuntimeException parseWithErrorRegistry(org.eclipse.ditto.json.JsonObject errorJson, org.eclipse.ditto.model.base.headers.DittoHeaders dittoHeaders, org.eclipse.ditto.signals.base.ErrorRegistry<?> errorRegistry)
Parse an error JSON using an error registry, or construct a genericDittoRuntimeException
if the error code is not in the registry.- Parameters:
errorJson
- JSON representation of the error.dittoHeaders
- Headers of the error.errorRegistry
- The error registry.- Returns:
- The parsed
DittoRuntimeException
. - Since:
- 1.1.0
-
fromAdaptable
public T fromAdaptable(Adaptable adaptable)
Description copied from interface:Adapter
Maps the givenadaptable
to its correspondingT
.- Specified by:
fromAdaptable
in interfaceAdapter<T extends org.eclipse.ditto.signals.commands.base.ErrorResponse<T>>
- Parameters:
adaptable
- the adaptable to map.- Returns:
- the mapped object.
-
toAdaptable
public Adaptable toAdaptable(T errorResponse, TopicPath.Channel channel)
Description copied from interface:Adapter
Maps the givent
to its correspondingAdaptable
.- Specified by:
toAdaptable
in interfaceAdapter<T extends org.eclipse.ditto.signals.commands.base.ErrorResponse<T>>
- Parameters:
errorResponse
- the object to map.channel
- the channel that was used to send the signal- Returns:
- the mapped adaptable.
-
getTopicPathBuilder
public abstract TopicPathBuilder getTopicPathBuilder(T errorResponse)
Implementations must provide aTopicPathBuilder
for the givenerrorResponse
.- Parameters:
errorResponse
- the processed error response- Returns:
- the
TopicPathBuilder
used to processed the givenerrorResponse
-
buildErrorResponse
public abstract T buildErrorResponse(TopicPath topicPath, org.eclipse.ditto.model.base.exceptions.DittoRuntimeException exception, org.eclipse.ditto.model.base.headers.DittoHeaders dittoHeaders)
Implementations can build theErrorResponse
from the given parameters.- Parameters:
topicPath
- theTopicPath
used to build the error responseexception
- theDittoRuntimeException
used to build the error responsedittoHeaders
- theDittoHeaders
used to build the error response- Returns:
- the built error response
-
-