Brooklyn

brooklyn.util.config
[Java] Class ConfigBag

java.lang.Object
  brooklyn.util.config.ConfigBag

public class ConfigBag

Stores config in such a way that usage can be tracked. Either ConfigKey or java.lang.String keys can be inserted; they will be stored internally as strings. It is recommended to use ConfigKey instances to access, although in some cases (such as setting fields from flags, or copying a map) it may be necessary to mark things as used, or put, when only a string key is available.

Authors:
alex


Field Summary
protected java.lang.String description

 
Method Summary
ConfigBag configure(ConfigKey key, java.lang.Object value)

as put(ConfigKey, Object) but returning this ConfigBag for fluent-style coding

boolean containsKey(HasConfigKey key)

boolean containsKey(ConfigKey key)

boolean containsKey(java.lang.String key)

ConfigBag copy(ConfigBag other)

java.lang.Object get(ConfigKey key)

returns the value of this config key, falling back to its default (use containsKey to see whether it was contained); also marks it as having been used (use peek to prevent marking as used)

protected java.lang.Object get(ConfigKey key, boolean remove)

java.util.Map getAllConfig()

current values for all entries

java.util.Map getAllConfigRaw()

internal map containing the current values for all entries; for use where the caller wants to modify this directly and knows it is safe to do so

java.lang.String getDescription()

optional description used to provide context for operations

java.lang.Object getStringKey(java.lang.String key)

gets a value from a string-valued key; ConfigKey is preferred, but this is useful in some contexts (e.g. setting from flags)

protected java.lang.Object getStringKey(java.lang.String key, boolean remove)

java.util.Map getUnusedConfig()

current values for all entries which have not yet been used

java.util.Map getUnusedConfigRaw()

internal map containing the current values for all entries which have not yet been used; for use where the caller wants to modify this directly and knows it is safe to do so

boolean isUnused(ConfigKey key)

ConfigBag markAll(java.lang.Iterable usedFlags)

void markFlagUsed(java.lang.String key)

@deprecated don't use, remove ASAP

void markUsed(java.lang.String key)

indicates that a string key in the config map has been accessed

static ConfigBag newInstanceCopying(ConfigBag configBag)

creates a new ConfigBag instance which includes all of the supplied ConfigBag's values, but which tracks usage separately (already used values are marked as such, but uses in the original set will not be marked here, and vice versa)

static ConfigBag newInstanceExtending(ConfigBag configBag, java.util.Map flags)

creates a new ConfigBag instance which includes all of the supplied ConfigBag's values, plus an additional set of or pairs

java.lang.Object peek(ConfigKey key)

like get, but without marking it as used

java.lang.Object put(ConfigKey key, java.lang.Object value)

ConfigBag putAll(java.util.Map addlConfig)

protected void putAsStringKey(java.lang.Object key, java.lang.Object value)

void putIfNotNull(ConfigKey key, java.lang.Object value)

java.lang.Object putStringKey(java.lang.String key, java.lang.Object value)

recommended to use put(ConfigKey, Object) but there are times (e.g. when copying a map) where we want to put a string key directly @return

void remove(ConfigKey key)

void remove(java.lang.String key)

ConfigBag removeAll(ConfigKey... keys)

ConfigBag removeAll(java.lang.Iterable keys)

ConfigBag setDescription(java.lang.String description)

 
Methods inherited from class java.lang.Object
java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()
 

Field Detail

description

protected java.lang.String description


 
Method Detail

configure

public ConfigBag configure(ConfigKey key, java.lang.Object value)
as put(ConfigKey, Object) but returning this ConfigBag for fluent-style coding


containsKey

public boolean containsKey(HasConfigKey key)


containsKey

public boolean containsKey(ConfigKey key)


containsKey

public boolean containsKey(java.lang.String key)


copy

public ConfigBag copy(ConfigBag other)


get

public java.lang.Object get(ConfigKey key)
returns the value of this config key, falling back to its default (use containsKey to see whether it was contained); also marks it as having been used (use peek to prevent marking as used)


get

protected java.lang.Object get(ConfigKey key, boolean remove)


getAllConfig

public java.util.Map getAllConfig()
current values for all entries
Returns:
non-modifiable map of strings to object


getAllConfigRaw

public java.util.Map getAllConfigRaw()
internal map containing the current values for all entries; for use where the caller wants to modify this directly and knows it is safe to do so


getDescription

public java.lang.String getDescription()
optional description used to provide context for operations


getStringKey

public java.lang.Object getStringKey(java.lang.String key)
gets a value from a string-valued key; ConfigKey is preferred, but this is useful in some contexts (e.g. setting from flags)


getStringKey

protected java.lang.Object getStringKey(java.lang.String key, boolean remove)


getUnusedConfig

public java.util.Map getUnusedConfig()
current values for all entries which have not yet been used
Returns:
non-modifiable map of strings to object


getUnusedConfigRaw

public java.util.Map getUnusedConfigRaw()
internal map containing the current values for all entries which have not yet been used; for use where the caller wants to modify this directly and knows it is safe to do so


isUnused

public boolean isUnused(ConfigKey key)


markAll

public ConfigBag markAll(java.lang.Iterable usedFlags)


markFlagUsed

public void markFlagUsed(java.lang.String key)
deprecated:
don't use, remove ASAP


markUsed

public void markUsed(java.lang.String key)
indicates that a string key in the config map has been accessed


newInstanceCopying

public static ConfigBag newInstanceCopying(ConfigBag configBag)
creates a new ConfigBag instance which includes all of the supplied ConfigBag's values, but which tracks usage separately (already used values are marked as such, but uses in the original set will not be marked here, and vice versa)


newInstanceExtending

public static ConfigBag newInstanceExtending(ConfigBag configBag, java.util.Map flags)
creates a new ConfigBag instance which includes all of the supplied ConfigBag's values, plus an additional set of or pairs

values from the original set which are used here will be marked as used in the original set (note: this applies even for values which are overridden and the overridden value is used); however subsequent uses in the original set will not be marked here


peek

public java.lang.Object peek(ConfigKey key)
like get, but without marking it as used


put

@SuppressWarnings("unchecked")
public java.lang.Object put(ConfigKey key, java.lang.Object value)


putAll

public ConfigBag putAll(java.util.Map addlConfig)


putAsStringKey

protected void putAsStringKey(java.lang.Object key, java.lang.Object value)


putIfNotNull

public void putIfNotNull(ConfigKey key, java.lang.Object value)


putStringKey

public java.lang.Object putStringKey(java.lang.String key, java.lang.Object value)
recommended to use put(ConfigKey, Object) but there are times (e.g. when copying a map) where we want to put a string key directly @return


remove

public void remove(ConfigKey key)


remove

public void remove(java.lang.String key)


removeAll

public ConfigBag removeAll(ConfigKey... keys)


removeAll

public ConfigBag removeAll(java.lang.Iterable keys)


setDescription

public ConfigBag setDescription(java.lang.String description)


 

Brooklyn Multi-Cloud Application Management Platform
brooklyncentral.github.com. Apache License. © 2012.