Skip to content

Commit

Permalink
Update Configuration Javadocs (#18736)
Browse files Browse the repository at this point in the history
Updated Javadocs in Configuration
  • Loading branch information
alzimmermsft authored Feb 5, 2021
1 parent 8a0fe63 commit ef2a853
Showing 1 changed file with 26 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ public class Configuration implements Cloneable {
PROPERTY_AZURE_CLIENT_ID,
PROPERTY_AZURE_CLIENT_SECRET,
PROPERTY_AZURE_TENANT_ID,
PROPERTY_AZURE_CLIENT_CERTIFICATE_PATH,
PROPERTY_AZURE_RESOURCE_GROUP,
PROPERTY_AZURE_CLOUD,
PROPERTY_AZURE_AUTHORITY_HOST,
Expand Down Expand Up @@ -174,17 +175,23 @@ public static Configuration getGlobalConfiguration() {

/**
* Gets the value of the configuration.
* <p>
* This method first checks the values previously loaded from the environment, if the configuration is found there
* it will be returned. Otherwise, this will attempt to load the value from the environment.
*
* @param name Name of the configuration.
* @return Value of the configuration if found, otherwise {@code null}.
* @return Value of the configuration if found, otherwise null.
*/
public String get(String name) {
return getOrLoad(name);
}

/**
* Gets the value of the configuration converted to {@code T}.
*
* <p>
* This method first checks the values previously loaded from the environment, if the configuration is found there
* it will be returned. Otherwise, this will attempt to load the value from the environment.
* <p>
* If no configuration is found, the {@code defaultValue} is returned.
*
* @param name Name of the configuration.
Expand All @@ -197,11 +204,16 @@ public <T> T get(String name, T defaultValue) {
}

/**
* Gets the converted value of the configuration.
* Gets the value of the configuration and converts it with the {@code converter}.
* <p>
* This method first checks the values previously loaded from the environment, if the configuration is found there
* it will be returned. Otherwise, this will attempt to load the value from the environment.
* <p>
* If no configuration is found the {@code converter} won't be called and null will be returned.
*
* @param name Name of the configuration.
* @param converter Converter used to map the configuration to {@code T}.
* @param <T> Generic type that the configuration is converted to if found.
* @param <T> Type that the configuration is converted to if found.
* @return The converted configuration if found, otherwise null.
*/
public <T> T get(String name, Function<String, T> converter) {
Expand Down Expand Up @@ -266,8 +278,8 @@ String loadFromProperties(String name) {

/**
* Adds a configuration with the given value.
*
* If a configuration with the same name already exists, this will update it to the passed value.
* <p>
* This will overwrite the previous configuration value if it existed.
*
* @param name Name of the configuration.
* @param value Value of the configuration.
Expand All @@ -280,16 +292,21 @@ public Configuration put(String name, String value) {

/**
* Removes the configuration.
* <p>
* This returns the value of the configuration if it previously existed.
*
* @param name Name of the configuration.
* @return If the configuration was removed the value of it, otherwise {@code null}.
* @return The configuration if it previously existed, otherwise null.
*/
public String remove(String name) {
return configurations.remove(name);
}

/**
* Determines if the configuration exists.
* <p>
* This only checks against values previously loaded into the Configuration object, this won't inspect the
* environment for containing the value.
*
* @param name Name of the configuration.
* @return True if the configuration exists, otherwise false.
Expand All @@ -299,6 +316,8 @@ public boolean contains(String name) {
}

/**
* Clones this Configuration object.
*
* @return A clone of the Configuration object.
*/
@SuppressWarnings("CloneDoesntCallSuperClone")
Expand Down

0 comments on commit ef2a853

Please sign in to comment.