jp.gopay.sdk.converters.IdempotencyKeyConverterFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gopay-java-sdk Show documentation
Show all versions of gopay-java-sdk Show documentation
Official Gyro-n Payments Java SDK
package jp.gopay.sdk.converters;
import jp.gopay.sdk.models.common.IdempotencyKey;
import retrofit2.Converter;
import retrofit2.Retrofit;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
public class IdempotencyKeyConverterFactory extends Converter.Factory {
class IdempotencyKeyConverter implements Converter{
@Override
public String convert(IdempotencyKey idempotencyKey) throws IOException{
return idempotencyKey.getKey();
}
}
@Override
public Converter, String> stringConverter(Type type, Annotation[] annotations, Retrofit retrofit){
if(type instanceof Class> && ((IdempotencyKey.class.isAssignableFrom((Class>)type)))){
return new IdempotencyKeyConverter();
}
return super.stringConverter(type, annotations, retrofit);
}
}