Package groovy.util

Class Expando

All Implemented Interfaces:
GroovyObject

public class Expando extends GroovyObjectSupport
Represents a dynamically expandable bean.
  • Constructor Details

    • Expando

      public Expando()
      Creates an empty expando.
    • Expando

      public Expando(Map expandoProperties)
      Creates an expando backed by the supplied properties.
      Parameters:
      expandoProperties - the initial properties map
  • Method Details

    • getProperties

      public Map getProperties()
      Returns:
      the dynamically expanded properties
    • getMetaPropertyValues

      public List getMetaPropertyValues()
      Returns meta-properties representing the current dynamic properties.
      Returns:
      the meta-property values
    • getProperty

      public Object getProperty(String property)
      Resolves a property from the dynamic property map before normal lookup.
      Parameters:
      property - the property name
      Returns:
      the property value, or null if it is not defined
    • setProperty

      public void setProperty(String property, Object newValue)
      Stores a dynamic property.
      Parameters:
      property - the property name
      newValue - the property value
    • invokeMethod

      public Object invokeMethod(String name, Object args)
      Invokes a declared method or a closure stored as a dynamic property.
      Parameters:
      name - the method name
      args - the invocation arguments
      Returns:
      the invocation result
    • toString

      public String toString()
      This allows toString to be overridden by a closure field method attached to the expando object.
      Overrides:
      toString in class Object
      See Also:
    • equals

      public boolean equals(Object obj)
      This allows equals to be overridden by a closure field method attached to the expando object.
      Overrides:
      equals in class Object
      See Also:
    • hashCode

      public int hashCode()
      This allows hashCode to be overridden by a closure field method attached to the expando object.
      Overrides:
      hashCode in class Object
      See Also:
    • createMap

      protected Map createMap()
      Factory method to create a new Map used to store the expando properties map
      Returns:
      a newly created Map implementation