Class AbstractGrailsClass

    • Constructor Summary

      Constructors 
      Constructor Description
      AbstractGrailsClass​(java.lang.Class<?> clazz, java.lang.String trailingName)
      Used by all child classes to create a new instance and get the name right.
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      GrailsApplication getApplication()
      The GrailsApplication that this class belongs to
      java.lang.Class<?> getClazz()
      Returns the actual clazz represented by the GrailsClass.
      java.lang.String getFullName()
      Returns the full name of the class in the application with the trailing convention part and with the package name.
      java.lang.String getLogicalPropertyName()
      Returns the logical name of the class as a property name.
      groovy.lang.MetaClass getMetaClass()  
      java.util.List<groovy.lang.MetaProperty> getMetaProperties()  
      java.lang.String getName()
      Returns the logical name of the class in the application without the trailing convention part if applicable and without the package name.
      java.lang.String getNaturalName()
      Returns the name of the property in natural terms (eg.
      java.lang.String getPackageName()
      Returns the package name of the class.
      java.lang.String getPluginName()  
      java.beans.PropertyDescriptor[] getPropertyDescriptors()
      Deprecated.
      java.lang.String getPropertyName()
      Returns the name of the class as a property name.
      protected <T> T getPropertyOrStaticPropertyOrFieldValue​(java.lang.String name, java.lang.Class<T> type)
      Looks for a property of the reference instance with a given name and type.
      java.lang.Class<?> getPropertyType​(java.lang.String typeName)  
      java.lang.Object getPropertyValue​(java.lang.String propName)
      Gets the initial value of the given property on the class.
      <T> T getPropertyValue​(java.lang.String propName, java.lang.Class<T> type)
      Get the value of the named property, with support for static properties in both Java and Groovy classes (which as of Groovy JSR 1.0 RC 01 only have getters in the metaClass)
      java.lang.Object getPropertyValueObject​(java.lang.String propertyNAme)  
      java.lang.Object getReferenceInstance()  
      java.lang.String getShortName()
      Returns the short name of the class without package prefix.
      <T> T getStaticPropertyValue​(java.lang.String propName, java.lang.Class<T> type)
      Get the value of the named static property.
      boolean hasMetaMethod​(java.lang.String methodName)  
      boolean hasMetaMethod​(java.lang.String methodName, java.lang.Object[] args)  
      boolean hasMetaProperty​(java.lang.String propName)  
      boolean hasProperty​(java.lang.String propName)
      Returns true if the class has the specified property.
      boolean isAbstract()
      Whether the class is abstract or not
      boolean isActionMethod​(java.lang.String methodName)  
      boolean isReadableProperty​(java.lang.String propName)  
      java.lang.Object newInstance()
      Creates a new instance of this class.
      void setGrailsApplication​(GrailsApplication grailsApplication)
      This method is called by the ApplicationContext that loads the Grails application.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • AbstractGrailsClass

        public AbstractGrailsClass​(java.lang.Class<?> clazz,
                                   java.lang.String trailingName)
        Used by all child classes to create a new instance and get the name right.
        Parameters:
        clazz - the Grails class
        trailingName - the trailing part of the name for this class type
    • Method Detail

      • getPluginName

        public java.lang.String getPluginName()
        Specified by:
        getPluginName in interface GrailsClass
        Returns:
        The plugin where the artefact originates from
      • getShortName

        public java.lang.String getShortName()
        Description copied from interface: GrailsClass
        Returns the short name of the class without package prefix.
        Specified by:
        getShortName in interface GrailsClass
        Returns:
        The short name
      • getClazz

        public java.lang.Class<?> getClazz()
        Description copied from interface: GrailsClass
        Returns the actual clazz represented by the GrailsClass.
        Specified by:
        getClazz in interface GrailsClass
        Returns:
        The class
      • newInstance

        public java.lang.Object newInstance()
        Description copied from interface: GrailsClass
        Creates a new instance of this class. This method can be used as factory method in the Spring application context.
        Specified by:
        newInstance in interface GrailsClass
        Returns:
        A new instance of this class
      • getName

        public java.lang.String getName()
        Description copied from interface: GrailsClass
        Returns the logical name of the class in the application without the trailing convention part if applicable and without the package name.
        Specified by:
        getName in interface GrailsClass
        Returns:
        The logical name
      • getNaturalName

        public java.lang.String getNaturalName()
        Description copied from interface: GrailsClass
        Returns the name of the property in natural terms (eg. 'lastName' becomes 'Last Name')
        Specified by:
        getNaturalName in interface GrailsClass
        Returns:
        The natural property name.
      • getFullName

        public java.lang.String getFullName()
        Description copied from interface: GrailsClass
        Returns the full name of the class in the application with the trailing convention part and with the package name.
        Specified by:
        getFullName in interface GrailsClass
        Returns:
        The full name
      • getPropertyName

        public java.lang.String getPropertyName()
        Description copied from interface: GrailsClass
        Returns the name of the class as a property name.
        Specified by:
        getPropertyName in interface GrailsClass
        Returns:
        The property name representation
      • getLogicalPropertyName

        public java.lang.String getLogicalPropertyName()
        Description copied from interface: GrailsClass
        Returns the logical name of the class as a property name.
        Specified by:
        getLogicalPropertyName in interface GrailsClass
        Returns:
        The logical property name
      • getPackageName

        public java.lang.String getPackageName()
        Description copied from interface: GrailsClass
        Returns the package name of the class.
        Specified by:
        getPackageName in interface GrailsClass
        Returns:
        The package name
      • getReferenceInstance

        public java.lang.Object getReferenceInstance()
        Specified by:
        getReferenceInstance in interface GrailsClass
        Returns:
        Sample (reference) instance for this Grails class
      • getPropertyDescriptors

        @Deprecated
        public java.beans.PropertyDescriptor[] getPropertyDescriptors()
        Deprecated.
      • getMetaProperties

        public java.util.List<groovy.lang.MetaProperty> getMetaProperties()
      • getPropertyType

        public java.lang.Class<?> getPropertyType​(java.lang.String typeName)
      • isReadableProperty

        public boolean isReadableProperty​(java.lang.String propName)
      • isActionMethod

        public boolean isActionMethod​(java.lang.String methodName)
      • hasMetaMethod

        public boolean hasMetaMethod​(java.lang.String methodName)
      • hasMetaMethod

        public boolean hasMetaMethod​(java.lang.String methodName,
                                     java.lang.Object[] args)
      • hasMetaProperty

        public boolean hasMetaProperty​(java.lang.String propName)
      • getPropertyOrStaticPropertyOrFieldValue

        protected <T> T getPropertyOrStaticPropertyOrFieldValue​(java.lang.String name,
                                                                java.lang.Class<T> type)

        Looks for a property of the reference instance with a given name and type.

        If found its value is returned. We follow the Java bean conventions with augmentation for groovy support and static fields/properties. We will therefore match, in this order:

        1. Public static field
        2. Public static property with getter method
        3. Standard public bean property (with getter or just public field, using normal introspection)
        Returns:
        property value or null if no property or static field was found
      • getStaticPropertyValue

        public <T> T getStaticPropertyValue​(java.lang.String propName,
                                            java.lang.Class<T> type)
        Get the value of the named static property.
        Parameters:
        propName -
        type -
        Returns:
        The property value or null
      • getPropertyValue

        public <T> T getPropertyValue​(java.lang.String propName,
                                      java.lang.Class<T> type)
        Get the value of the named property, with support for static properties in both Java and Groovy classes (which as of Groovy JSR 1.0 RC 01 only have getters in the metaClass)
        Specified by:
        getPropertyValue in interface GrailsClass
        Parameters:
        propName -
        type -
        Returns:
        The property value or null
      • getPropertyValueObject

        public java.lang.Object getPropertyValueObject​(java.lang.String propertyNAme)
      • getPropertyValue

        public java.lang.Object getPropertyValue​(java.lang.String propName)
        Description copied from interface: GrailsClass
        Gets the initial value of the given property on the class.
        Specified by:
        getPropertyValue in interface GrailsClass
        Parameters:
        propName - The name of the property
        Returns:
        The initial value
      • isAbstract

        public boolean isAbstract()
        Description copied from interface: GrailsClass
        Whether the class is abstract or not
        Specified by:
        isAbstract in interface GrailsClass
        Returns:
        true if it is abstract
      • hasProperty

        public boolean hasProperty​(java.lang.String propName)
        Description copied from interface: GrailsClass
        Returns true if the class has the specified property.
        Specified by:
        hasProperty in interface GrailsClass
        Parameters:
        propName - The name of the property
        Returns:
        true if it does
      • getMetaClass

        public groovy.lang.MetaClass getMetaClass()
        Specified by:
        getMetaClass in interface GrailsClass
        Returns:
        the metaClass
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object