Class AbstractErrorResponseAdapter<T extends org.eclipse.ditto.signals.commands.base.ErrorResponse<T>>

  • Type Parameters:
    T - the type of the ErrorResponse
    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 a ErrorResponse to and from an Adaptable.
    • 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 generic DittoRuntimeException 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 given adaptable to its corresponding T.
        Specified by:
        fromAdaptable in interface Adapter<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 given t to its corresponding Adaptable.
        Specified by:
        toAdaptable in interface Adapter<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 a TopicPathBuilder for the given errorResponse.
        Parameters:
        errorResponse - the processed error response
        Returns:
        the TopicPathBuilder used to processed the given errorResponse
      • 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 the ErrorResponse from the given parameters.
        Parameters:
        topicPath - the TopicPath used to build the error response
        exception - the DittoRuntimeException used to build the error response
        dittoHeaders - the DittoHeaders used to build the error response
        Returns:
        the built error response