Java 类com.mashape.unirest.http.ObjectMapper 实例源码

项目:airtable.java    文件:Airtable.java   
/**
 * Configure, <code>AIRTABLE_API_KEY</code> passed by Java property,
 * enviroment variable or within credentials.properties.
 *
 * @param objectMapper A custom ObjectMapper implementation
 * @return An Airtable instance configured with supplied ObjectMapper
 * @throws com.sybit.airtable.exception.AirtableException Missing API-Key
 */
@SuppressWarnings("UnusedReturnValue")
public Airtable configure(ObjectMapper objectMapper) throws AirtableException {

    LOG.info("System-Property: Using Java property '-D" + AIRTABLE_API_KEY + "' to get apikey.");
    String airtableApi = System.getProperty(AIRTABLE_API_KEY);

    if (airtableApi == null) {
        LOG.info("Environment-Variable: Using OS environment '" + AIRTABLE_API_KEY + "' to get apikey.");
        airtableApi = System.getenv(AIRTABLE_API_KEY);
    }
    if (airtableApi == null) {
        airtableApi = getCredentialProperty(AIRTABLE_API_KEY);
    }

    return this.configure(airtableApi, objectMapper);
}
项目:airtable.java    文件:Airtable.java   
/**
 * Configure the Airtable client by given config.
 * 
 * @param config Configuration of client.
 * @param objectMapper A custom ObjectMapper implementation
 * @return
 * @throws AirtableException Missing API-Key or Endpoint
 */
@SuppressWarnings("WeakerAccess")
public Airtable configure(Configuration config, ObjectMapper objectMapper) throws AirtableException {
    assert config != null : "config was null";
    assert objectMapper != null : "objectMapper was null";

    if (config.getApiKey() == null) {
        throw new AirtableException("Missing Airtable API-Key");
    }
    if (config.getEndpointUrl() == null) {
        throw new AirtableException("Missing endpointUrl");
    }

    this.config = config;

    if (config.getTimeout() != null) {
        LOG.info("Set connection timeout to: " + config.getTimeout() + "ms.");
        Unirest.setTimeouts(config.getTimeout(), config.getTimeout());
    }

    configureProxy(config.getEndpointUrl());

    // Only one time
    Unirest.setObjectMapper(objectMapper);

    // Add specific Converter for Date
    DateTimeConverter dtConverter = new DateConverter();
    dtConverter.setPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
    ConvertUtils.register(dtConverter, Date.class);

    ListConverter lConverter = new ListConverter();
    lConverter.setListClass(Attachment.class);
    ConvertUtils.register(lConverter, List.class);

    MapConverter thConverter = new MapConverter();
    thConverter.setMapClass(Thumbnail.class);
    ConvertUtils.register(thConverter, Map.class);

    return this;
}
项目:msbotframework4j    文件:BotConnectorClientFactory.java   
private BotConnectorClientFactory() {
  Unirest.setObjectMapper(new ObjectMapper() {
    @Override
    public <T> T readValue(String s, Class<T> aClass) {
      return SerializerFacade.fromJsonString(aClass, s);
    }

    @Override
    public String writeValue(Object o) {
      return SerializerFacade.toJsonString(o.getClass(), o);
    }
  });
}
项目:groovejames    文件:JacksonObjectMapper.java   
public JacksonObjectMapper() {
    jacksonObjectMapper = new com.fasterxml.jackson.databind.ObjectMapper()
            .disable(FAIL_ON_UNKNOWN_PROPERTIES);
}
项目:airtable.java    文件:Airtable.java   
/**
 * Configure Airtable.
 *
 * @param apiKey API-Key of Airtable.
 * @param objectMapper A custom ObjectMapper implementation
 * @return
 * @throws com.sybit.airtable.exception.AirtableException Missing API-Key
 */
@SuppressWarnings("WeakerAccess")
public Airtable configure(String apiKey, ObjectMapper objectMapper) throws AirtableException {
    return configure(new Configuration(apiKey, Configuration.ENDPOINT_URL, null), objectMapper);
}
项目:kinto-http-java    文件:KintoClient.java   
/**
 * {@link KintoClient} constructor that allows to specify a remote kinto installation as well as an
 * {@link ObjectMapper} that will allow unmarshalling of responses as objects (that must be properly annotated
 * with jackson annotations).
 * @param remote The remote URL. Must contain the version
 * @param objectMapper {@link ObjectMapper} to use for deserialization
 * @throws IllegalArgumentException if remote is null or an empty String or if headers is null
 */
public KintoClient(String remote, ObjectMapper objectMapper) {
    this(remote);
    Unirest.setObjectMapper(objectMapper);
}
项目:kinto-http-java    文件:KintoClient.java   
/**
 * {@link KintoClient} constructor that allows to specify a remote kinto installation, default headers and an
 * {@link ObjectMapper} that will allow unmarshalling of responses as objects (that must be properly annotated
 * with jackson annotations).
 * @param remote The remote URL. Must contain the version
 * @param headers Custom http headers added to each requests
 * @param objectMapper Custom object mapper
 * @throws IllegalArgumentException if remote is null or an empty String or if headers is null
 */
public KintoClient(String remote, Map<String, String> headers, ObjectMapper objectMapper) {
    this(remote, headers);
    Unirest.setObjectMapper(objectMapper);
}