com.abubusoft.kripton.retrofit2.KriptonResponseBodyConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kripton-retrofit-converter Show documentation
Show all versions of kripton-retrofit-converter Show documentation
Kripton adapter for Retrofit library
/*******************************************************************************
* Copyright 2018 Francesco Benincasa ([email protected])
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy
* of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
******************************************************************************/
package com.abubusoft.kripton.retrofit2;
import java.io.IOException;
import com.abubusoft.kripton.BinderContext;
import okhttp3.ResponseBody;
import retrofit2.Converter;
// TODO: Auto-generated Javadoc
/**
* The Class KriptonResponseBodyConverter.
*
* @param the generic type
*/
final class KriptonResponseBodyConverter implements Converter {
/** The binder context. */
private BinderContext binderContext;
/** The clazz. */
private Class clazz;
/**
* Instantiates a new kripton response body converter.
*
* @param binderContext the binder context
* @param clazz the clazz
*/
KriptonResponseBodyConverter(BinderContext binderContext, Class clazz) {
this.binderContext = binderContext;
this.clazz = clazz;
}
/* (non-Javadoc)
* @see retrofit2.Converter#convert(java.lang.Object)
*/
@Override
public T convert(ResponseBody value) throws IOException {
try {
return binderContext.parse(value.byteStream(), clazz);
} catch (Exception e) {
e.printStackTrace();
return null;
} finally {
value.close();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy