use of org.apache.groovy.contracts.generation.Configurator in project groovy by apache.
the class ConfigurationSetup method init.
/**
* Adds an instance field which allows to control whether GContract assertions
* are enabled or not. Before assertions are evaluated this field will be checked.
*
* @param type the current {@link ClassNode}
* @see Configurator
*/
public void init(final ClassNode type) {
Validate.notNull(type);
StaticMethodCallExpression checkAssertionsEnabledMethodCall = callX(ClassHelper.makeWithoutCaching(Configurator.class), "checkAssertionsEnabled", args(constX(type.getName())));
final FieldNode fieldNode = type.addField(BaseVisitor.GCONTRACTS_ENABLED_VAR, Opcodes.ACC_STATIC | Opcodes.ACC_SYNTHETIC | Opcodes.ACC_FINAL, ClassHelper.boolean_TYPE, checkAssertionsEnabledMethodCall);
fieldNode.setSynthetic(true);
}
Aggregations