Package com.coherentlogic.fred.client.core.factories

Source Code of com.coherentlogic.fred.client.core.factories.QueryBuilderFactory

package com.coherentlogic.fred.client.core.factories;

import org.springframework.web.client.RestTemplate;

import com.coherentlogic.fred.client.core.builders.QueryBuilder;

/**
* A factory which is used for creating instances of QueryBuilder.
* <p>
* Since the QueryBuilder is not thread-safe, it cannot be set as a member
* variable -- instead, use this factory and call {@link #getInstance()}
* whenever you need to query the FRED web services.
* <p>
* This class can be extended, for example, if you need to always return the
* same value for some query parameter -- for example, in this class we always
* return the same API key.
* <p>
* @author <a href="support@coherentlogic.com">Support</a>
*/
public class QueryBuilderFactory
    implements Factory<QueryBuilder> {

    private final RestTemplate restTemplate;

    private final String uri;

    private final String apiKey;

    public QueryBuilderFactory (
        RestTemplate restTemplate,
        String uri,
        String apiKey
    ) {
        this.restTemplate = restTemplate;
        this.uri = uri;
        this.apiKey = apiKey;
    }

    @Override
    public QueryBuilder getInstance() {

        QueryBuilder result = new QueryBuilder (restTemplate, uri);

        result.setApiKey(apiKey);

        return result;
    }
}
TOP

Related Classes of com.coherentlogic.fred.client.core.factories.QueryBuilderFactory

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.