public class ConfigObject extends GroovyObjectSupport implements Writable, Map, Cloneable
| Constructor and Description |
|---|
ConfigObject() |
ConfigObject(URL file) |
| Modifier and Type | Method and Description |
|---|---|
void |
clear() |
ConfigObject |
clone()
Returns a shallow copy of this ConfigObject, keys and configuration entries are not cloned.
|
boolean |
containsKey(Object key) |
boolean |
containsValue(Object value) |
Set |
entrySet() |
Map |
flatten()
A ConfigObject is a tree structure consisting of nested maps.
|
Map |
flatten(Map target)
Flattens this ConfigObject populating the results into the target Map
|
Object |
get(Object key) |
URL |
getConfigFile() |
Object |
getProperty(String name)
Overrides the default getProperty implementation to create nested ConfigObject instances on demand
for non-existent keys
|
boolean |
isEmpty() |
Boolean |
isSet(String option)
Checks if a config option is set.
|
Set |
keySet() |
Map |
merge(ConfigObject other)
Merges the given map with this ConfigObject overriding any matching configuration entries in this ConfigObject
|
String |
prettyPrint() |
Object |
put(Object key,
Object value) |
void |
putAll(Map m) |
Object |
remove(Object key) |
void |
setConfigFile(URL configFile) |
int |
size() |
Properties |
toProperties()
Converts this ConfigObject into a the java.util.Properties format, flattening the tree structure beforehand
|
Properties |
toProperties(String prefix)
Converts this ConfigObject ino the java.util.Properties format, flatten the tree and prefixing all entries with the given prefix
|
String |
toString() |
Collection |
values() |
Writer |
writeTo(Writer outArg)
Writes this config object into a String serialized representation which can later be parsed back using the parse()
method
|
getMetaClass, invokeMethod, setMetaClass, setPropertyequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitcompute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAllpublic ConfigObject(URL file)
public ConfigObject()
public URL getConfigFile()
public void setConfigFile(URL configFile)
public Writer writeTo(Writer outArg) throws IOException
writeTo in interface WritableoutArg - the Writer to which this Writable should output its data.IOException - if an error occurred while outputting data to the writerWritable.writeTo(java.io.Writer)public Object getProperty(String name)
getProperty in interface GroovyObjectgetProperty in class GroovyObjectSupportname - the name of the property of interestpublic Map flatten()
public Map flatten(Map target)
flatten()public Map merge(ConfigObject other)
other - The ConfigObject to merge withpublic Properties toProperties()
public Properties toProperties(String prefix)
prefix - The prefix to append before property entriespublic boolean containsKey(Object key)
containsKey in interface Mappublic boolean containsValue(Object value)
containsValue in interface Mappublic Collection values()
public ConfigObject clone()
public Boolean isSet(String option)
def config = new ConfigSlurper().parse("foo { password='' }")
assert config.foo.isSet('password')
assert config.foo.isSet('username') == false
The check works only for options one block below the current block.
E.g. config.isSet('foo.password') will always return false.option - The name of the optiontrue if the option is set false otherwisepublic String prettyPrint()