Search in sources :

Example 1 with PagedResponseBase

use of com.azure.android.core.rest.util.paging.PagedResponseBase in project azure-sdk-for-android by Azure.

the class HttpResponseMapper method extractContentAndHeaderDecodeType.

private Pair<Type, Type> extractContentAndHeaderDecodeType(Type callbackType, String swaggerMethodName) {
    final Type callbackTypeArgument = TypeUtil.getTypeArgument(callbackType);
    // Pair<Type:HeaderDecodeType, Type:ContentDecodeType>
    Pair<Type, Type> decodeTypes;
    decodeTypes = tryExtractContentAndHeaderDecodeType(callbackTypeArgument, ResponseBase.class, swaggerMethodName);
    if (decodeTypes != null) {
        return decodeTypes;
    }
    decodeTypes = tryExtractContentAndHeaderDecodeType(callbackTypeArgument, PagedResponseBase.class, swaggerMethodName);
    if (decodeTypes != null) {
        return decodeTypes;
    }
    Type decodeType;
    decodeType = tryExtractContentDecodeType(callbackTypeArgument, PagedResponse.class, swaggerMethodName);
    if (decodeType != null) {
        return Pair.create(null, decodeType);
    }
    decodeType = tryExtractContentDecodeType(callbackTypeArgument, Response.class, swaggerMethodName);
    if (decodeType != null) {
        return Pair.create(null, decodeType);
    }
    throw logger.logExceptionAsError(new IllegalStateException("The type argument of " + Callback.class.getName() + " in the method " + swaggerMethodName + " must either ResponseBase<H, C>, PagedResponseBase<H, C>, PagedResponse<C> or Response<C>"));
}
Also used : HttpResponse(com.azure.android.core.http.HttpResponse) PagedResponse(com.azure.android.core.rest.util.paging.PagedResponse) UnexpectedResponseExceptionType(com.azure.android.core.rest.annotation.UnexpectedResponseExceptionType) ReturnValueWireType(com.azure.android.core.rest.annotation.ReturnValueWireType) ParameterizedType(java.lang.reflect.ParameterizedType) Type(java.lang.reflect.Type) PagedResponseBase(com.azure.android.core.rest.util.paging.PagedResponseBase) PagedResponseBase(com.azure.android.core.rest.util.paging.PagedResponseBase) PagedResponse(com.azure.android.core.rest.util.paging.PagedResponse)

Aggregations

HttpResponse (com.azure.android.core.http.HttpResponse)1 ReturnValueWireType (com.azure.android.core.rest.annotation.ReturnValueWireType)1 UnexpectedResponseExceptionType (com.azure.android.core.rest.annotation.UnexpectedResponseExceptionType)1 PagedResponse (com.azure.android.core.rest.util.paging.PagedResponse)1 PagedResponseBase (com.azure.android.core.rest.util.paging.PagedResponseBase)1 ParameterizedType (java.lang.reflect.ParameterizedType)1 Type (java.lang.reflect.Type)1