All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.netflix.governator.configuration.ConfigurationProvider Maven / Gradle / Ivy

There is a newer version: 1.17.13
Show newest version
/*
 * Copyright 2013 Netflix, Inc.
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package com.netflix.governator.configuration;

import com.google.common.base.Supplier;
import com.google.inject.ImplementedBy;
import com.netflix.governator.annotations.Configuration;
import com.netflix.governator.lifecycle.LifecycleConfigurationProviders;

import java.util.Date;

/**
 * Abstraction for get configuration values to use for fields annotated
 * with {@link Configuration}
 */
@ImplementedBy(LifecycleConfigurationProviders.class)
public interface ConfigurationProvider
{
    /**
     * Return true if there is a configuration value set for the given key
     *
     * @param key configuration key
     * @return true/false
     */
    public boolean has(ConfigurationKey key);

    /**
     * Return the given configuration as a boolean.  Use this when the configuration
     * value is expected to change at run time.
     *
     * @param key configuration key
     * @return value
     */
    public Supplier getBooleanSupplier(ConfigurationKey key, Boolean defaultValue);

    /**
     * Return the given configuration as an integer.   Use this when the configuration
     * value is expected to change at run time.
     *
     * @param key configuration key
     * @return value
     */
    public Supplier getIntegerSupplier(ConfigurationKey key, Integer defaultValue);

    /**
     * Return the given configuration as a long.  Use this when the configuration
     * value is expected to change at run time.
     *
     * @param key configuration key
     * @return value
     */
    public Supplier getLongSupplier(ConfigurationKey key, Long defaultValue);

    /**
     * Return the given configuration as a double.  Use this when the configuration
     * value is expected to change at run time.
     *
     * @param key configuration key
     * @return value
     */
    public Supplier getDoubleSupplier(ConfigurationKey key, Double defaultValue);

    /**
     * Return the given configuration as a string.  Use this when the configuration
     * value is expected to change at run time.
     *
     * @param key configuration key
     * @return value
     */
    public Supplier getStringSupplier(ConfigurationKey key, String defaultValue);

    /**
     * Return the given configuration as a date.  Use this when the configuration
     * value is expected to change at run time.
     *
     * @param key configuration key
     * @return value
     */
    public Supplier getDateSupplier(ConfigurationKey key, Date defaultValue);

    /**
     * Return the given configuration as an object of the given type.
     *
     * @param key             configuration key
     * @param defaultValue    value to return when key is not found
     * @param objectType      Class of the configuration to return
     * @param              type of the configuration to return
     * @return the object for this configuration.
     */
    public  Supplier getObjectSupplier(ConfigurationKey key, T defaultValue, Class objectType);
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy