retrofit.converter.Converter Java Examples

The following examples show how to use retrofit.converter.Converter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HttpService.java    From aptoide-client with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected Converter createConverter() {

    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);

    return new JacksonConverter(objectMapper);
}
 
Example #2
Source File: DelegatingConverter.java    From wear-notify-for-reddit with Apache License 2.0 5 votes vote down vote up
public DelegatingConverter(Converter originalConverter, TokenConverter tokenConverter,
                           PostConverter postConverter, MarkAsReadConverter markAsReadConverter,
                           SubscriptionConverter subscriptionConverter,
                           CommentsConverter commentsConverter) {
    mSubscriptionConverter = subscriptionConverter;
    mMarkAsReadConverter = markAsReadConverter;
    mOriginalConverter = originalConverter;
    mCommentsConverter = commentsConverter;
    mTokenConverter = tokenConverter;
    mPostConverter = postConverter;
}
 
Example #3
Source File: RestAdapter.java    From android-discourse with Apache License 2.0 5 votes vote down vote up
/**
 * The converter used for serialization and deserialization of objects.
 */
public Builder setConverter(Converter converter) {
    if (converter == null) {
        throw new NullPointerException("Converter may not be null.");
    }
    this.converter = converter;
    return this;
}
 
Example #4
Source File: RestAdapter.java    From android-discourse with Apache License 2.0 5 votes vote down vote up
private RestAdapter(Server server, Client.Provider clientProvider, Executor httpExecutor, Executor callbackExecutor, RequestInterceptor requestInterceptor, Converter converter, Profiler profiler, ErrorHandler errorHandler, Log log, LogLevel logLevel) {
    this.server = server;
    this.clientProvider = clientProvider;
    this.httpExecutor = httpExecutor;
    this.callbackExecutor = callbackExecutor;
    this.requestInterceptor = requestInterceptor;
    this.converter = converter;
    this.profiler = profiler;
    this.errorHandler = errorHandler;
    this.log = log;
    this.logLevel = logLevel;
}
 
Example #5
Source File: RetrofitError.java    From android-discourse with Apache License 2.0 5 votes vote down vote up
private RetrofitError(String url, Response response, Converter converter, Type successType, boolean networkError, Throwable exception) {
    super(exception);
    this.url = url;
    this.response = response;
    this.converter = converter;
    this.successType = successType;
    this.networkError = networkError;
}
 
Example #6
Source File: AptoideSpiceHttpService.java    From aptoide-client with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected Converter createConverter() {

    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);

    return new JacksonConverter(objectMapper);
}
 
Example #7
Source File: AptoideSpiceHttpsService.java    From aptoide-client with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected Converter createConverter() {

    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);

    return new JacksonConverter(objectMapper);
}
 
Example #8
Source File: OauthErrorHandler.java    From aptoide-client with GNU General Public License v2.0 5 votes vote down vote up
public static Converter createConverter() {

        ObjectMapper objectMapper = new ObjectMapper();
        objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
        objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);

        return new JacksonConverter(objectMapper);
    }
 
Example #9
Source File: RetrofitClientFactory.java    From kayenta with Apache License 2.0 5 votes vote down vote up
public <T> T createClient(
    Class<T> type,
    Converter converter,
    RemoteService remoteService,
    OkHttpClient okHttpClient,
    String username,
    String password,
    String usernamePasswordFile)
    throws IOException {
  String baseUrl = remoteService.getBaseUrl();

  baseUrl = baseUrl.endsWith("/") ? baseUrl.substring(0, baseUrl.length() - 1) : baseUrl;

  Endpoint endpoint = newFixedEndpoint(baseUrl);

  if (!(StringUtils.isEmpty(username)
      && StringUtils.isEmpty(password)
      && StringUtils.isEmpty(usernamePasswordFile))) {
    okHttpClient = createAuthenticatedClient(username, password, usernamePasswordFile);
  }

  Slf4jRetrofitLogger logger = createRetrofitLogger.apply(type);

  return new RestAdapter.Builder()
      .setEndpoint(endpoint)
      .setClient(new OkClient(okHttpClient))
      .setConverter(converter)
      .setLogLevel(RestAdapter.LogLevel.valueOf(retrofitLogLevel))
      .setLog(logger)
      .build()
      .create(type);
}
 
Example #10
Source File: RetrofitClientFactory.java    From kayenta with Apache License 2.0 5 votes vote down vote up
public <T> T createClient(
    Class<T> type, Converter converter, RemoteService remoteService, OkHttpClient okHttpClient) {
  try {
    return createClient(type, converter, remoteService, okHttpClient, null, null, null);
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
}
 
Example #11
Source File: RetrofitAbstractGenerator.java    From httpdoc with Apache License 2.0 5 votes vote down vote up
protected RetrofitAbstractGenerator(Modeler<ClassFragment> modeler, String prefix, String suffix, Collection<Class<? extends Converter>> converterFactories) {
    super(modeler);
    if (prefix == null || suffix == null || converterFactories == null) throw new NullPointerException();
    this.prefix = prefix.trim();
    this.suffix = suffix.trim();
    this.converterFactories.addAll(converterFactories);
}
 
Example #12
Source File: SecuredRestBuilder.java    From mobilecloud-15 with Apache License 2.0 4 votes vote down vote up
@Override
public SecuredRestBuilder setConverter(Converter converter) {

	return (SecuredRestBuilder) super.setConverter(converter);
}
 
Example #13
Source File: RetrofitRxJavaGenerator.java    From httpdoc with Apache License 2.0 4 votes vote down vote up
public RetrofitRxJavaGenerator(String prefix, String suffix, Collection<Class<? extends Converter>> converterFactories) {
    super(prefix, suffix, converterFactories);
}
 
Example #14
Source File: TokenConverter.java    From wear-notify-for-reddit with Apache License 2.0 4 votes vote down vote up
public TokenConverter(Converter originalConverter) {
    mOriginalConverter = originalConverter;
}
 
Example #15
Source File: RequestBuilder.java    From android-discourse with Apache License 2.0 4 votes vote down vote up
RequestBuilder(Converter converter, RestMethodInfo methodInfo) {
    this.converter = converter;

    paramNames = methodInfo.requestParamNames;
    paramUsages = methodInfo.requestParamUsage;
    requestMethod = methodInfo.requestMethod;
    isSynchronous = methodInfo.isSynchronous;

    headers = new ArrayList<Header>();
    if (methodInfo.headers != null) {
        headers.addAll(methodInfo.headers);
    }

    queryParams = new StringBuilder();

    relativeUrl = methodInfo.requestUrl;

    String requestQuery = methodInfo.requestQuery;
    if (requestQuery != null) {
        queryParams.append('?').append(requestQuery);
    }

    switch (methodInfo.requestType) {
        case FORM_URL_ENCODED:
            formBody = new FormUrlEncodedTypedOutput();
            multipartBody = null;
            body = formBody;
            break;
        case MULTIPART:
            formBody = null;
            multipartBody = new MultipartTypedOutput();
            body = multipartBody;
            break;
        case SIMPLE:
            formBody = null;
            multipartBody = null;
            // If present, 'body' will be set in 'setArguments' call.
            break;
        default:
            throw new IllegalArgumentException("Unknown request type: " + methodInfo.requestType);
    }
}
 
Example #16
Source File: Platform.java    From android-discourse with Apache License 2.0 4 votes vote down vote up
@Override
Converter defaultConverter() {
    return new GsonConverter(new Gson());
}
 
Example #17
Source File: Platform.java    From android-discourse with Apache License 2.0 4 votes vote down vote up
@Override
Converter defaultConverter() {
    return new GsonConverter(new Gson());
}
 
Example #18
Source File: RetrofitRxJavaGenerator.java    From httpdoc with Apache License 2.0 4 votes vote down vote up
public RetrofitRxJavaGenerator(Modeler<ClassFragment> modeler, Collection<Class<? extends Converter>> converterFactories) {
    super(modeler, converterFactories);
}
 
Example #19
Source File: RetrofitRxJavaGenerator.java    From httpdoc with Apache License 2.0 4 votes vote down vote up
public RetrofitRxJavaGenerator(Modeler<ClassFragment> modeler, String prefix, String suffix, Collection<Class<? extends Converter>> converterFactories) {
    super(modeler, prefix, suffix, converterFactories);
}
 
Example #20
Source File: RetrofitError.java    From android-discourse with Apache License 2.0 4 votes vote down vote up
public static RetrofitError httpError(String url, Response response, Converter converter, Type successType) {
    return new RetrofitError(url, response, converter, successType, false, null);
}
 
Example #21
Source File: RetrofitError.java    From android-discourse with Apache License 2.0 4 votes vote down vote up
public static RetrofitError conversionError(String url, Response response, Converter converter, Type successType, ConversionException exception) {
    return new RetrofitError(url, response, converter, successType, false, exception);
}
 
Example #22
Source File: RetrofitStandardGenerator.java    From httpdoc with Apache License 2.0 4 votes vote down vote up
public RetrofitStandardGenerator(Collection<Class<? extends Converter>> converterFactories) {
    super(converterFactories);
}
 
Example #23
Source File: SecuredRestBuilder.java    From mobilecloud-15 with Apache License 2.0 4 votes vote down vote up
@Override
public SecuredRestBuilder setConverter(Converter converter) {

	return (SecuredRestBuilder) super.setConverter(converter);
}
 
Example #24
Source File: SecuredRestBuilder.java    From mobilecloud-15 with Apache License 2.0 4 votes vote down vote up
@Override
public SecuredRestBuilder setConverter(Converter converter) {

	return (SecuredRestBuilder) super.setConverter(converter);
}
 
Example #25
Source File: RetrofitAbstractGenerator.java    From httpdoc with Apache License 2.0 4 votes vote down vote up
protected RetrofitAbstractGenerator(Modeler<ClassFragment> modeler, String prefix, String suffix) {
    this(modeler, prefix, suffix, Collections.<Class<? extends Converter>>emptyList());
}
 
Example #26
Source File: RepoManager.java    From dhis2-android-dashboard with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private static Converter provideJacksonConverter() {
    return new JacksonConverter(ObjectMapperProvider.getInstance());
}
 
Example #27
Source File: AppModule.java    From Android-REST-API-Explorer with MIT License 4 votes vote down vote up
@Provides
public Converter providesConverter() {
    return new GsonConverter(GsonDateTime.getOneNoteBuilder()
            .create());
}
 
Example #28
Source File: RetrofitStandardGenerator.java    From httpdoc with Apache License 2.0 4 votes vote down vote up
public RetrofitStandardGenerator(String prefix, String suffix, Collection<Class<? extends Converter>> converterFactories) {
    super(prefix, suffix, converterFactories);
}
 
Example #29
Source File: RetrofitStandardGenerator.java    From httpdoc with Apache License 2.0 4 votes vote down vote up
public RetrofitStandardGenerator(Modeler<ClassFragment> modeler, Collection<Class<? extends Converter>> converterFactories) {
    super(modeler, converterFactories);
}
 
Example #30
Source File: RetrofitRxJavaGenerator.java    From httpdoc with Apache License 2.0 4 votes vote down vote up
public RetrofitRxJavaGenerator(Collection<Class<? extends Converter>> converterFactories) {
    super(converterFactories);
}