<commit_before>/*
 * Copyright 2015 Hewlett-Packard Development Company, L.P.
 * Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
 */

package com.hp.autonomy.hod.client.config;

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.hp.autonomy.hod.client.converter.HodConverter;
import com.hp.autonomy.hod.client.error.DefaultHodErrorHandler;
import com.hp.autonomy.hod.client.error.HodErrorHandler;
import com.hp.autonomy.hod.client.token.InMemoryTokenRepository;
import com.hp.autonomy.hod.client.token.TokenRepository;
import com.hp.autonomy.hod.client.token.TokenProxyService;
import lombok.Data;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.apache.http.client.HttpClient;
import retrofit.RestAdapter;
import retrofit.client.ApacheClient;
import retrofit.client.Client;
import retrofit.converter.JacksonConverter;

/**
 * Configuration class for a HodService
 */
@Data
public class HodServiceConfig {

    private final RestAdapter restAdapter;
    private final TokenRepository tokenRepository;
    private final Requester requester;
    private final String endpoint;

    private HodServiceConfig(final Builder builder) {
        final RestAdapter.Builder restAdapterBuilder = new RestAdapter.Builder()
            .setEndpoint(builder.endpoint)
            .setErrorHandler(new ErrorHandlerWrapper(builder.errorHandler));

        if(builder.client != null) {
            restAdapterBuilder.setClient(builder.client);
        }

        final ObjectMapper objectMapper;

        if (builder.objectMapper != null) {
            objectMapper = builder.objectMapper.copy();
        }
        else {
            objectMapper = new ObjectMapper();
        }

        // HP Haven OnDemand does not consider adding new properties to be a breaking change, so ignore any unknown
        // properties
        objectMapper.configure(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES, false);

        final JacksonConverter jacksonConverter = new JacksonConverter(objectMapper);
        final HodConverter converter = new HodConverter(jacksonConverter);
        restAdapterBuilder.setConverter(converter);

        restAdapter = restAdapterBuilder.build();
        tokenRepository = builder.tokenRepository;<commit_msg>Set correct feature so we get the effect we want. [rev: matthew.gordon]<commit_after>/*
 * Copyright 2015 Hewlett-Packard Development Company, L.P.
 * Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
 */

package com.hp.autonomy.hod.client.config;

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.hp.autonomy.hod.client.converter.HodConverter;
import com.hp.autonomy.hod.client.error.DefaultHodErrorHandler;
import com.hp.autonomy.hod.client.error.HodErrorHandler;
import com.hp.autonomy.hod.client.token.InMemoryTokenRepository;
import com.hp.autonomy.hod.client.token.TokenRepository;
import com.hp.autonomy.hod.client.token.TokenProxyService;
import lombok.Data;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.apache.http.client.HttpClient;
import retrofit.RestAdapter;
import retrofit.client.ApacheClient;
import retrofit.client.Client;
import retrofit.converter.JacksonConverter;

/**
 * Configuration class for a HodService
 */
@Data
public class HodServiceConfig {

    private final RestAdapter restAdapter;
    private final TokenRepository tokenRepository;
    private final Requester requester;
    private final String endpoint;

    private HodServiceConfig(final Builder builder) {
        final RestAdapter.Builder restAdapterBuilder = new RestAdapter.Builder()
            .setEndpoint(builder.endpoint)
            .setErrorHandler(new ErrorHandlerWrapper(builder.errorHandler));

        if(builder.client != null) {
            restAdapterBuilder.setClient(builder.client);
        }

        final ObjectMapper objectMapper;

        if (builder.objectMapper != null) {
            objectMapper = builder.objectMapper.copy();
        }
        else {
            objectMapper = new ObjectMapper();
        }

        // HP Haven OnDemand does not consider adding new properties to be a breaking change, so ignore any unknown
        // properties
        objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

        final JacksonConverter jacksonConverter = new JacksonConverter(objectMapper);
        final HodConverter converter = new HodConverter(jacksonConverter);
        restAdapterBuilder.setConverter(converter);

        restAdapter = restAdapterBuilder.build();
        tokenRepository = builder.tokenRepository;
{'fraction_non_alphanumeric': 0.08160299003322259, 'fraction_numerical': 0.0016611295681063123, 'mean_word_length': 3.8558467741935485, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3110520', 'n_tokens_mistral': 1301, 'n_tokens_neox': 1237, 'n_words': 306}