java类com.mashape.unirest.http.ObjectMapper的实例源码

Airtable.java 文件源码 项目:airtable.java 阅读 23 收藏 0 点赞 0 评论 0
/**
 * 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 阅读 26 收藏 0 点赞 0 评论 0
/**
 * 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;
}
BotConnectorClientFactory.java 文件源码 项目:msbotframework4j 阅读 27 收藏 0 点赞 0 评论 0
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);
    }
  });
}
JacksonObjectMapper.java 文件源码 项目:groovejames 阅读 22 收藏 0 点赞 0 评论 0
public JacksonObjectMapper() {
    jacksonObjectMapper = new com.fasterxml.jackson.databind.ObjectMapper()
            .disable(FAIL_ON_UNKNOWN_PROPERTIES);
}
Airtable.java 文件源码 项目:airtable.java 阅读 20 收藏 0 点赞 0 评论 0
/**
 * 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);
}
KintoClient.java 文件源码 项目:kinto-http-java 阅读 32 收藏 0 点赞 0 评论 0
/**
 * {@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);
}
KintoClient.java 文件源码 项目:kinto-http-java 阅读 22 收藏 0 点赞 0 评论 0
/**
 * {@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);
}


问题


面经


文章

微信
公众号

扫码关注公众号