Example usage for com.fasterxml.jackson.core Version compareTo

List of usage examples for com.fasterxml.jackson.core Version compareTo

Introduction

In this page you can find the example usage for com.fasterxml.jackson.core Version compareTo.

Prototype

@Override
    public int compareTo(Version other) 

Source Link

Usage

From source file:synapticloop.scaleway.api.ScalewayApiClient.java

/**
 * Instantiate a new API Client for the Scaleway API Provider, each API
 * client points to a specific Region.  Once this region is set, it cannot
 * be changed.  Instead instantiate a new API client for the new region,
 *
 * @param accessToken the access token that is authorised to invoke the API -
 *                    see the credentials section: <a href="https://cloud.scaleway.com/#/credentials">https://cloud.scaleway.com/#/credentials</a>
 *                    for access tokens//  w w  w.ja  v a  2 s.c o m
 * @param region      the scaleway datacentre region that this API points to (see
 *                    {@link Region} for all of the regions available at the moment)
 */
public ScalewayApiClient(String accessToken, Region region) {
    this.accessToken = accessToken;
    this.region = region;
    this.computeUrl = String.format(Constants.COMPUTE_URL, region);

    HttpClientBuilder httpBuilder = HttpClients.custom();
    httpBuilder.setUserAgent(Constants.USER_AGENT);
    this.httpclient = httpBuilder.build();

    Version currentJacksonVersion = new ObjectMapper().version();
    Version earliestSupportedVersion = new Version(2, 8, 7, null, currentJacksonVersion.getGroupId(),
            currentJacksonVersion.getArtifactId());
    int versionCompared = currentJacksonVersion.compareTo(earliestSupportedVersion);
    if (versionCompared < 0) {
        LOGGER.error("Jackson version: {}, version compared: {}", currentJacksonVersion.toString(),
                versionCompared);
        throw new RuntimeException(
                "Sorry, scaleway-api-client requires Jackson version 2.8.7 due to bugs in earlier versions.");
    }
}