|
44 | 44 | import static org.codehaus.groovy.ast.tools.GeneralUtils.assignS; |
45 | 45 | import static org.codehaus.groovy.ast.tools.GeneralUtils.assignX; |
46 | 46 | import static org.codehaus.groovy.ast.tools.GeneralUtils.block; |
| 47 | +import static org.codehaus.groovy.ast.tools.GeneralUtils.callThisX; |
47 | 48 | import static org.codehaus.groovy.ast.tools.GeneralUtils.callX; |
48 | 49 | import static org.codehaus.groovy.ast.tools.GeneralUtils.classX; |
49 | 50 | import static org.codehaus.groovy.ast.tools.GeneralUtils.ctorX; |
@@ -156,8 +157,12 @@ private static void addNonThreadSafeBody(BlockStatement body, FieldNode fieldNod |
156 | 157 | private static void addMethod(FieldNode fieldNode, BlockStatement body, ClassNode type) { |
157 | 158 | int visibility = ACC_PUBLIC; |
158 | 159 | if (fieldNode.isStatic()) visibility |= ACC_STATIC; |
159 | | - final String name = "get" + MetaClassHelper.capitalize(fieldNode.getName().substring(1)); |
160 | | - fieldNode.getDeclaringClass().addMethod(name, visibility, type, Parameter.EMPTY_ARRAY, ClassNode.EMPTY_ARRAY, body); |
| 160 | + String propName = MetaClassHelper.capitalize(fieldNode.getName().substring(1)); |
| 161 | + fieldNode.getDeclaringClass().addMethod("get" + propName, visibility, type, Parameter.EMPTY_ARRAY, ClassNode.EMPTY_ARRAY, body); |
| 162 | + if (ClassHelper.boolean_TYPE.equals(type)) { |
| 163 | + fieldNode.getDeclaringClass().addMethod("is" + propName, visibility, type, |
| 164 | + Parameter.EMPTY_ARRAY, ClassNode.EMPTY_ARRAY, stmt(callThisX("get" + propName))); |
| 165 | + } |
161 | 166 | } |
162 | 167 |
|
163 | 168 | private static void createSoft(FieldNode fieldNode, Expression initExpr) { |
|
0 commit comments