Package: grails.core

## [Java] Class ArtefactHandlerAdapter

- grails.core.ArtefactHandlerAdapter

- All Implemented Interfaces and Traits:
    ArtefactHandler

      @java.lang.SuppressWarnings( "deprecation" )
      public class ArtefactHandlerAdapter
      extends java.lang.Object

  Adapter for the ArtefactHandler interface

  Authors:
    Marc Palmer (marc@anyware.co.uk)
    Graeme Rocher
  Since:
    1.0

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `protected boolean` | `allowAbstract` |
    `protected java.lang.String` | `artefactSuffix` |
    `protected java.lang.Class<?>` | `grailsClassImpl` |
    `protected java.lang.Class<?>` | `grailsClassType` |
    `protected java.lang.String` | `type` |

  - ### Constructor Summary

    Constructors
    Constructor and description
    `ArtefactHandlerAdapter (java.lang.String type, java.lang.Class<? extends GrailsClass> grailsClassType, java.lang.Class<?> grailsClassImpl, java.lang.String artefactSuffix)`
    `ArtefactHandlerAdapter (java.lang.String type, java.lang.Class<? extends GrailsClass> grailsClassType, java.lang.Class<?> grailsClassImpl, java.lang.String artefactSuffix, boolean allowAbstract)`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `GrailsClass` | `getArtefactForFeature(java.lang.Object feature)`
    `` | `java.lang.String` | `getPluginName()`
    `` | `java.lang.String` | `getType()`
    `` | `void` | `initialize(ArtefactInfo artefacts)` Sets up the relationships between the domain classes, this has to be done after the intial creation to avoid looping.
    `` | `boolean` | `isArtefact(org.codehaus.groovy.ast.ClassNode classNode)` Default implementation of ArtefactHandler.isArtefact which returns true if the ClassNode passes the isArtefactResource(org.grails.io.support.Resource) method and the name of the ClassNode ends with the artefactSuffix
    `` | `boolean` | `isArtefact(java.lang.Class aClass)`
    `` | `boolean` | `isArtefactClass(java.lang.Class clazz)`
    `` | `boolean` | `isArtefactGrailsClass(GrailsClass artefactGrailsClass)`
    `` | `protected boolean` | `isArtefactResource(Resource resource)` Subclasses can override to narrow down whether the given resource is an artefact of this type.
    `` | `protected boolean` | `isValidArtefactClassNode(org.codehaus.groovy.ast.ClassNode classNode, int modifiers)`
    `` | `GrailsClass` | `newArtefactClass(java.lang.Class artefactClass)`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class java.lang.Object` | `java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), 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

    - #### protected boolean allowAbstract

    - #### protected java.lang.String artefactSuffix

    - #### protected java.lang.Class<?> grailsClassImpl

    - #### protected java.lang.Class<?> grailsClassType

    - #### protected java.lang.String type

  - ### Constructor Detail

    - #### public ArtefactHandlerAdapter(java.lang.String type, java.lang.Class<? extends GrailsClass> grailsClassType, java.lang.Class<?> grailsClassImpl, java.lang.String artefactSuffix)

    - #### public ArtefactHandlerAdapter(java.lang.String type, java.lang.Class<? extends GrailsClass> grailsClassType, java.lang.Class<?> grailsClassImpl, java.lang.String artefactSuffix, boolean allowAbstract)

  - ### Method Detail

    - #### public GrailsClass getArtefactForFeature(java.lang.Object feature)

    - #### public java.lang.String getPluginName()

    - #### public java.lang.String getType()

    - #### public void initialize(ArtefactInfo artefacts)

      Sets up the relationships between the domain classes, this has to be done after the intial creation to avoid looping.

    - #### @java.lang.Override public boolean isArtefact(org.codehaus.groovy.ast.ClassNode classNode)

      Default implementation of ArtefactHandler.isArtefact which returns true if the ClassNode passes the isArtefactResource(org.grails.io.support.Resource) method and the name of the ClassNode ends with the artefactSuffix

      Parameters:
        `classNode` - The ClassNode instance
      Returns:
        True if the ClassNode is an artefact of this type

    - #### public final boolean isArtefact(@java.lang.SuppressWarnings("rawtypes") java.lang.Class aClass)

    - #### public boolean isArtefactClass(@java.lang.SuppressWarnings("rawtypes") java.lang.Class clazz)

      Checks that class's name ends in the suffix specified for this handler.

      Override for more complex criteria

      Parameters:
        `clazz` - The class to check
      Returns:
        true if it is an artefact of this type

    - #### public boolean isArtefactGrailsClass(GrailsClass artefactGrailsClass)

    - #### protected boolean isArtefactResource(Resource resource)

      Subclasses can override to narrow down whether the given resource is an artefact of this type. The default is to consider all files under "grails-app" to be a resource

      Parameters:
        `resource` - The resource
      Returns:
        True if it is a Grails artefact

    - #### protected boolean isValidArtefactClassNode(org.codehaus.groovy.ast.ClassNode classNode, int modifiers)

    - #### public GrailsClass newArtefactClass(@java.lang.SuppressWarnings("rawtypes") java.lang.Class artefactClass)

      Creates new GrailsClass derived object using the type supplied in constructor. May not perform optimally but is a convenience.

      Parameters:
        `artefactClass` - Creates a new artefact for the given class
      Returns:
        An instance of the GrailsClass interface representing the artefact