All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.univapay.sdk.converters.DomainConverterFactory Maven / Gradle / Ivy

There is a newer version: 0.2.35
Show newest version
package com.univapay.sdk.converters;

import com.univapay.sdk.models.common.Domain;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import retrofit2.Converter;
import retrofit2.Retrofit;

public class DomainConverterFactory extends Converter.Factory {
  class DomainConverter implements Converter {
    @Override
    public String convert(Domain domain) throws IOException {
      if (domain == null) {
        return null;
      } else {
        return domain.asString();
      }
    }
  }

  @Override
  public Converter stringConverter(
      Type type, Annotation[] annotations, Retrofit retrofit) {
    if (type instanceof Class && ((Domain.class.isAssignableFrom((Class) type)))) {
      return new DomainConverter();
    }
    return super.stringConverter(type, annotations, retrofit);
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy