Package si.mazi.rescu
Class ResponseReader
java.lang.Object
si.mazi.rescu.ResponseReader
- Direct Known Subclasses:
JacksonResponseReader,PlainTextResponseReader
public abstract class ResponseReader extends Object
Interface for deserializing of REST returned data.
- Author:
- Martin ZIMA
-
Field Summary
Fields Modifier and Type Field Description static intBODY_FRAGMENT_CHARS -
Constructor Summary
Constructors Constructor Description ResponseReader(boolean ignoreHttpErrorCodes) -
Method Summary
Modifier and Type Method Description static <T extends Throwable, C extends Class<? extends T>>
TfindCause(Throwable root, C... ofClasses)Search the cause chain of t (starting from and including t) for a Throwable that is assignable to any of ofClasses, or null if not found.booleanisIgnoreHttpErrorCodes()protected abstract <T> Tread(String httpBody, Type returnType)Objectread(InvocationResult invocationResult, RestMethodMetadata methodMetadata)protected abstract RuntimeExceptionreadException(String httpBody, Class<? extends RuntimeException> exceptionType)
-
Field Details
-
BODY_FRAGMENT_CHARS
public static final int BODY_FRAGMENT_CHARS- See Also:
- Constant Field Values
-
-
Constructor Details
-
ResponseReader
public ResponseReader(boolean ignoreHttpErrorCodes)
-
-
Method Details
-
isIgnoreHttpErrorCodes
public boolean isIgnoreHttpErrorCodes() -
read
public Object read(InvocationResult invocationResult, RestMethodMetadata methodMetadata) throws IOException- Throws:
IOException
-
read
protected abstract <T> T read(String httpBody, Type returnType) throws IOException, ExceptionalReturnContentException -
readException
protected abstract RuntimeException readException(String httpBody, Class<? extends RuntimeException> exceptionType) throws IOException- Throws:
IOException
-
findCause
@SafeVarargs public static <T extends Throwable, C extends Class<? extends T>> T findCause(Throwable root, C... ofClasses)Search the cause chain of t (starting from and including t) for a Throwable that is assignable to any of ofClasses, or null if not found. The chain is first fully searched for the first of C, then second, etc.- Type Parameters:
T- This should be figured out by the compiler: the lowest common ancestor of ofClasses.C- Should be figured out by the compiler too.- Parameters:
ofClasses- Throwable classes in order of priority to be searched for.root- The cause from which the search is to be started.
-