public class DefaultExtraPropertiesExtension extends GroovyObjectSupport implements ExtraPropertiesExtension
ExtraPropertiesExtension.UnknownPropertyExceptionEXTENSION_NAME| Constructor and Description |
|---|
DefaultExtraPropertiesExtension() |
| Modifier and Type | Method and Description |
|---|---|
Object |
get(String name)
Returns the value for the registered property with the given name.
|
Map<String,Object> |
getProperties()
Returns all of the registered properties and their current values as a map.
|
Object |
getProperty(String name) |
boolean |
has(String name)
Returns whether or not the extension has a property registered via the given name.
|
Object |
methodMissing(String name,
Object args) |
void |
set(String name,
Object value)
Updates the value for, or creates, the registered property with the given name to the given value.
|
void |
setProperty(String name,
Object newValue) |
getMetaClass, invokeMethod, setMetaClasspublic boolean has(String name)
ExtraPropertiesExtension
assert project.ext.has("foo") == false
assert project.hasProperty("foo") == false
project.ext.foo = "bar"
assert project.ext.has("foo")
assert project.hasProperty("foo")
has in interface ExtraPropertiesExtensionname - The name of the property to check fortrue if a property has been registered with this name, otherwise false.public Object get(String name)
ExtraPropertiesExtension
project.ext { foo = "bar" }
assert project.ext.get("foo") == "bar"
assert project.ext.foo == "bar"
assert project.ext["foo"] == "bar"
assert project.foo == "bar"
assert project["foo"] == "bar"
When using the first form, an ExtraPropertiesExtension.UnknownPropertyException exception will be thrown if the
extension does not have a property called ?foo?. When using the second forms (i.e. Groovy notation),
Groovy's MissingPropertyException will be thrown instead.get in interface ExtraPropertiesExtensionname - The name of the property to get the value ofpublic void set(String name, Object value)
ExtraPropertiesExtension
project.ext.set("foo", "bar")
project.ext.foo = "bar"
project.ext["foo"] = "bar"
// Once the property has been created via the extension, it can be changed by the owner.
project.foo = "bar"
project["foo"] = "bar"
set in interface ExtraPropertiesExtensionname - The name of the property to update the value of or createvalue - The value to set for the propertypublic Object getProperty(String name)
getProperty in interface GroovyObjectgetProperty in class GroovyObjectSupportpublic void setProperty(String name, Object newValue)
setProperty in interface GroovyObjectsetProperty in class GroovyObjectSupportpublic Map<String,Object> getProperties()
ExtraPropertiesExtension
project.version = "1.0"
assert project.hasProperty("version")
assert project.ext.properties.containsKey("version") == false
project.ext.foo = "bar"
assert project.ext.properties.containsKey("foo")
assert project.ext.properties.foo == project.ext.foo
assert project.ext.properties.every { key, value -> project.properties[key] == value }
getProperties in interface ExtraPropertiesExtensionCopyright © 2013. All rights reserved