@groovy.transform.CompileStatic @org.codehaus.groovy.transform.GroovyASTTransformation(phase: CompilePhase.CANONICALIZATION) class GormEntityTransformation extends org.codehaus.groovy.transform.AbstractASTTransformation implements groovy.transform.CompilationUnitAware, org.codehaus.groovy.transform.ASTTransformation
An AST transformation that adds the following features:
- An id and version (if not already present)
- A toString() method (if not already present)
- Associations and association methods (addTo*, removeFrom*) etc.
- Association id getter methods ('userId' for 'user' association)
- Adds the GormEntity and GormValidateable traits
- Named query methods
Modifiers | Name | Description |
---|---|---|
private static org.codehaus.groovy.ast.MethodNode |
ADD_TO_METHOD_NODE |
|
static org.codehaus.groovy.ast.Parameter[] |
ADD_TO_PARAMETERS |
|
private static java.lang.Object |
APPLIED_MARKER |
|
private static java.lang.String |
CREATE_NAMED_QUERY |
|
private static org.codehaus.groovy.ast.MethodNode |
GET_ASSOCIATION_ID_METHOD_NODE |
|
private static org.codehaus.groovy.ast.ClassNode |
GORM_ENTITY_CLASS_NODE |
|
private static org.codehaus.groovy.ast.expr.ListExpression |
IGNORED_PROPERTIES |
|
static org.codehaus.groovy.ast.AnnotationNode |
JPA_ENTITY_ANNOTATION_NODE |
|
protected static org.codehaus.groovy.ast.ClassNode |
JPA_ENTITY_CLASS_NODE |
|
static org.codehaus.groovy.ast.AnnotationNode |
JPA_ID_ANNOTATION_NODE |
|
static org.codehaus.groovy.ast.AnnotationNode |
JPA_TRANSIENT_ANNOTATION_NODE |
|
static org.codehaus.groovy.ast.AnnotationNode |
JPA_VERSION_ANNOTATION_NODE |
|
private static org.codehaus.groovy.ast.ClassNode |
MY_TYPE |
|
private static org.codehaus.groovy.ast.MethodNode |
REMOVE_FROM_METHOD_NODE |
|
static org.codehaus.groovy.ast.ClassNode |
SERIALIZABLE_CLASS_NODE |
|
protected org.codehaus.groovy.control.CompilationUnit |
compilationUnit |
Fields inherited from class | Fields |
---|---|
class org.codehaus.groovy.transform.AbstractASTTransformation |
RETENTION_CLASSNODE, ASM4, ASM5, ASM6, ASM7, ASM8, ASM9, ASM10_EXPERIMENTAL, SOURCE_DEPRECATED, SOURCE_MASK, V1_1, V1_2, V1_3, V1_4, V1_5, V1_6, V1_7, V1_8, V9, V10, V11, V12, V13, V14, V15, V16, V17, V18, V19, V20, V21, V22, V_PREVIEW, ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC, ACC_FINAL, ACC_SUPER, ACC_SYNCHRONIZED, ACC_OPEN, ACC_TRANSITIVE, ACC_VOLATILE, ACC_BRIDGE, ACC_STATIC_PHASE, ACC_VARARGS, ACC_TRANSIENT, ACC_NATIVE, ACC_INTERFACE, ACC_ABSTRACT, ACC_STRICT, ACC_SYNTHETIC, ACC_ANNOTATION, ACC_ENUM, ACC_MANDATED, ACC_MODULE, ACC_RECORD, ACC_DEPRECATED, T_BOOLEAN, T_CHAR, T_FLOAT, T_DOUBLE, T_BYTE, T_SHORT, T_INT, T_LONG, H_GETFIELD, H_GETSTATIC, H_PUTFIELD, H_PUTSTATIC, H_INVOKEVIRTUAL, H_INVOKESTATIC, H_INVOKESPECIAL, H_NEWINVOKESPECIAL, H_INVOKEINTERFACE, F_NEW, F_FULL, F_APPEND, F_CHOP, F_SAME, F_SAME1, TOP, INTEGER, FLOAT, DOUBLE, LONG, NULL, UNINITIALIZED_THIS, NOP, ACONST_NULL, ICONST_M1, ICONST_0, ICONST_1, ICONST_2, ICONST_3, ICONST_4, ICONST_5, LCONST_0, LCONST_1, FCONST_0, FCONST_1, FCONST_2, DCONST_0, DCONST_1, BIPUSH, SIPUSH, LDC, ILOAD, LLOAD, FLOAD, DLOAD, ALOAD, IALOAD, LALOAD, FALOAD, DALOAD, AALOAD, BALOAD, CALOAD, SALOAD, ISTORE, LSTORE, FSTORE, DSTORE, ASTORE, IASTORE, LASTORE, FASTORE, DASTORE, AASTORE, BASTORE, CASTORE, SASTORE, POP, POP2, DUP, DUP_X1, DUP_X2, DUP2, DUP2_X1, DUP2_X2, SWAP, IADD, LADD, FADD, DADD, ISUB, LSUB, FSUB, DSUB, IMUL, LMUL, FMUL, DMUL, IDIV, LDIV, FDIV, DDIV, IREM, LREM, FREM, DREM, INEG, LNEG, FNEG, DNEG, ISHL, LSHL, ISHR, LSHR, IUSHR, LUSHR, IAND, LAND, IOR, LOR, IXOR, LXOR, IINC, I2L, I2F, I2D, L2I, L2F, L2D, F2I, F2L, F2D, D2I, D2L, D2F, I2B, I2C, I2S, LCMP, FCMPL, FCMPG, DCMPL, DCMPG, IFEQ, IFNE, IFLT, IFGE, IFGT, IFLE, IF_ICMPEQ, IF_ICMPNE, IF_ICMPLT, IF_ICMPGE, IF_ICMPGT, IF_ICMPLE, IF_ACMPEQ, IF_ACMPNE, GOTO, JSR, RET, TABLESWITCH, LOOKUPSWITCH, IRETURN, LRETURN, FRETURN, DRETURN, ARETURN, RETURN, GETSTATIC, PUTSTATIC, GETFIELD, PUTFIELD, INVOKEVIRTUAL, INVOKESPECIAL, INVOKESTATIC, INVOKEINTERFACE, INVOKEDYNAMIC, NEW, NEWARRAY, ANEWARRAY, ARRAYLENGTH, ATHROW, CHECKCAST, INSTANCEOF, MONITORENTER, MONITOREXIT, MULTIANEWARRAY, IFNULL, IFNONNULL |
Constructor and description |
---|
GormEntityTransformation
() |
Type Params | Return Type | Name and description |
---|---|---|
|
static void |
|
|
private void |
addAssociationForKey(java.lang.String key, java.util.List<org.codehaus.groovy.ast.PropertyNode> properties, org.codehaus.groovy.ast.ClassNode declaringType, org.codehaus.groovy.ast.ClassNode propertyType) |
|
private void |
addRelationshipManagementMethods(java.lang.String propertyName, org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.MethodNode addToMethodNode, org.codehaus.groovy.ast.MethodNode removeFromMethodNode) |
|
private void |
addToOneIdProperty(java.lang.String propertyName, org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.expr.ListExpression listExpression, org.codehaus.groovy.ast.MethodNode getAssociationMethodNode) |
|
private java.util.Collection<org.codehaus.groovy.ast.PropertyNode> |
createPropertiesForBelongsToOrHasOneExpression(org.codehaus.groovy.ast.expr.Expression e, org.codehaus.groovy.ast.ClassNode classNode) |
|
private java.util.List<org.codehaus.groovy.ast.PropertyNode> |
createPropertiesForHasManyExpression(org.codehaus.groovy.ast.expr.Expression e, org.codehaus.groovy.ast.ClassNode classNode) |
|
private org.codehaus.groovy.ast.ClassNode |
findPropertyType(org.codehaus.groovy.ast.expr.Expression expression) Finds the type of the generated property. |
|
private java.util.List<GormEntityTraitProvider> |
findTraitProviders(java.lang.Class<GormEntityTraitProvider> traitProviderInterface, java.lang.ClassLoader classLoader) |
|
org.codehaus.groovy.ast.expr.ListExpression |
getOrCreateListProperty(org.codehaus.groovy.ast.ClassNode classNode, java.lang.String name) |
|
private void |
injectAssociationProperties(org.codehaus.groovy.ast.ClassNode classNode, java.util.List<org.codehaus.groovy.ast.PropertyNode> propertiesToAdd) |
|
private void |
injectAssociations(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.MethodNode addToMethodNode, org.codehaus.groovy.ast.MethodNode removeFromMethodNode, org.codehaus.groovy.ast.MethodNode getAssociationMethodNode) |
|
private void |
injectAssociationsForJpaEntity(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.MethodNode addToMethodNode, org.codehaus.groovy.ast.MethodNode removeFromMethodNode, org.codehaus.groovy.ast.MethodNode getAssociationMethodNode) |
|
protected void |
injectIdProperty(org.codehaus.groovy.ast.ClassNode classNode) |
|
private void |
injectToStringMethod(org.codehaus.groovy.ast.ClassNode classNode) |
|
protected void |
injectVersionProperty(org.codehaus.groovy.ast.ClassNode classNode) |
|
private boolean |
isHibernatePresent(java.lang.ClassLoader classLoader) |
|
protected java.lang.Class |
pickGormEntityTrait(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.control.SourceUnit source) |
|
void |
setCompilationUnit(org.codehaus.groovy.control.CompilationUnit compilationUnit) |
|
void |
visit(org.codehaus.groovy.ast.ASTNode[] astNodes, org.codehaus.groovy.control.SourceUnit sourceUnit) |
|
void |
visit(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.control.SourceUnit sourceUnit) |
Methods inherited from class | Name |
---|---|
class org.codehaus.groovy.transform.AbstractASTTransformation |
org.codehaus.groovy.transform.AbstractASTTransformation#tokenize(java.lang.String), org.codehaus.groovy.transform.AbstractASTTransformation#addError(java.lang.String, org.codehaus.groovy.ast.ASTNode), org.codehaus.groovy.transform.AbstractASTTransformation#getAnnotationName(), org.codehaus.groovy.transform.AbstractASTTransformation#memberHasValue(org.codehaus.groovy.ast.AnnotationNode, java.lang.String, java.lang.Object), org.codehaus.groovy.transform.AbstractASTTransformation#getMemberValue(org.codehaus.groovy.ast.AnnotationNode, java.lang.String), org.codehaus.groovy.transform.AbstractASTTransformation#getMemberStringValue(org.codehaus.groovy.ast.AnnotationNode, java.lang.String, java.lang.String), org.codehaus.groovy.transform.AbstractASTTransformation#getMemberStringValue(org.codehaus.groovy.ast.AnnotationNode, java.lang.String), org.codehaus.groovy.transform.AbstractASTTransformation#getMemberIntValue(org.codehaus.groovy.ast.AnnotationNode, java.lang.String), org.codehaus.groovy.transform.AbstractASTTransformation#getMemberClassValue(org.codehaus.groovy.ast.AnnotationNode, java.lang.String), org.codehaus.groovy.transform.AbstractASTTransformation#getMemberClassValue(org.codehaus.groovy.ast.AnnotationNode, java.lang.String, org.codehaus.groovy.ast.ClassNode), org.codehaus.groovy.transform.AbstractASTTransformation#getMemberStringList(org.codehaus.groovy.ast.AnnotationNode, java.lang.String), org.codehaus.groovy.transform.AbstractASTTransformation#getMemberList(org.codehaus.groovy.ast.AnnotationNode, java.lang.String), org.codehaus.groovy.transform.AbstractASTTransformation#getClassList(org.codehaus.groovy.ast.AnnotationNode, java.lang.String), org.codehaus.groovy.transform.AbstractASTTransformation#getMemberClassList(org.codehaus.groovy.ast.AnnotationNode, java.lang.String), org.codehaus.groovy.transform.AbstractASTTransformation#deemedInternalName(java.lang.String), org.codehaus.groovy.transform.AbstractASTTransformation#shouldSkipUndefinedAware(java.lang.String, java.util.List, java.util.List), org.codehaus.groovy.transform.AbstractASTTransformation#shouldSkipUndefinedAware(java.lang.String, java.util.List, java.util.List, boolean), org.codehaus.groovy.transform.AbstractASTTransformation#shouldSkipOnDescriptor(boolean, java.util.Map, org.codehaus.groovy.ast.MethodNode, java.util.List, java.util.List), org.codehaus.groovy.transform.AbstractASTTransformation#shouldSkipOnDescriptorUndefinedAware(boolean, java.util.Map, org.codehaus.groovy.ast.MethodNode, java.util.List, java.util.List), org.codehaus.groovy.transform.AbstractASTTransformation#checkPropertyList(org.codehaus.groovy.ast.ClassNode, java.util.List, java.lang.String, org.codehaus.groovy.ast.AnnotationNode, java.lang.String, boolean, boolean, boolean, boolean, boolean), org.codehaus.groovy.transform.AbstractASTTransformation#checkPropertyList(org.codehaus.groovy.ast.ClassNode, java.util.List, java.lang.String, org.codehaus.groovy.ast.AnnotationNode, java.lang.String, boolean, boolean, boolean), org.codehaus.groovy.transform.AbstractASTTransformation#checkPropertyList(org.codehaus.groovy.ast.ClassNode, java.util.List, java.lang.String, org.codehaus.groovy.ast.AnnotationNode, java.lang.String, boolean), org.codehaus.groovy.transform.AbstractASTTransformation#nonGeneric(org.codehaus.groovy.ast.ClassNode), org.codehaus.groovy.transform.AbstractASTTransformation#shouldSkip(java.lang.String, java.util.List, java.util.List), org.codehaus.groovy.transform.AbstractASTTransformation#shouldSkip(java.lang.String, java.util.List, java.util.List, boolean), org.codehaus.groovy.transform.AbstractASTTransformation#hasAnnotation(org.codehaus.groovy.ast.ClassNode, org.codehaus.groovy.ast.ClassNode), org.codehaus.groovy.transform.AbstractASTTransformation#wait(long), org.codehaus.groovy.transform.AbstractASTTransformation#wait(long, int), org.codehaus.groovy.transform.AbstractASTTransformation#wait(), org.codehaus.groovy.transform.AbstractASTTransformation#equals(java.lang.Object), org.codehaus.groovy.transform.AbstractASTTransformation#toString(), org.codehaus.groovy.transform.AbstractASTTransformation#hashCode(), org.codehaus.groovy.transform.AbstractASTTransformation#getClass(), org.codehaus.groovy.transform.AbstractASTTransformation#notify(), org.codehaus.groovy.transform.AbstractASTTransformation#notifyAll(), org.codehaus.groovy.transform.AbstractASTTransformation#visit([Lorg.codehaus.groovy.ast.ASTNode;, org.codehaus.groovy.control.SourceUnit) |
Finds the type of the generated property. The type will be a java.util.Set that is parameterized by the type of the expression passed in.
expression
- the expression used to parameterize the java.util.Set. Only used if a org.codehaus.groovy.ast.expr.ClassExpression. Otherwise ignored.