Source:
<code>public Configuration getConfiguration(GraphContext context) { return ConfigurationBuilder.begin() .addRule().when(JavaClass.references("org.jboss.windup.graph.model.resource.FileModel.setFilePath{*}").matchesSource("{*}/JavaHintsClassificationsTest.java{*}").inType("{*}").at(TypeReferenceLocation.METHOD_CALL)) .perform( Iteration.over().perform(new AbstractIterationOperation<JavaTypeReferenceModel>() { @Override public void perform(GraphRewrite event, EvaluationContext context, JavaTypeReferenceModel payload) { firstRuleMatchCount++; } }).endIteration()) .addRule() .when(JavaClass.references("org.jboss.windup.rules.java.JavaClassTestFile1.testJavaClassCondition()").matchesSource("{*}{line}{*}").inType("{*}").at(TypeReferenceLocation.METHOD)) .perform( Iteration.over().perform(new AbstractIterationOperation<JavaTypeReferenceModel>() { @Override public void perform(GraphRewrite event, EvaluationContext context, JavaTypeReferenceModel payload) { secondRuleMatchCount++; } }).endIteration()) <START> .where("line").matches("testJavaClassCondition\\(\\) throws IOException, InstantiationException") <END> .addRule() .when(JavaClass.references("org.jboss.windup.exec.configuration.WindupConfiguration.setRuleProviderFilter{*}").matchesSource("{*}{line}{*}").at(TypeReferenceLocation.METHOD_CALL)) .perform( Iteration.over().perform(new AbstractIterationOperation<JavaTypeReferenceModel>() { @Override public void perform(GraphRewrite event, EvaluationContext context, JavaTypeReferenceModel payload) { thirdRuleMatchCount++; } }).endIteration()) .where("line").matches(".setRuleProviderFilter\\(new") ; }</code><technical_language>a "\n" character beginning is throwing regex match. a brittle it? :)</technical_language>

Target:
public Configuration getConfiguration(GraphContext context) { return ConfigurationBuilder.begin() .addRule().when(JavaClass.references("org.jboss.windup.graph.model.resource.FileModel.setFilePath{*}").matchesSource("{*}/JavaHintsClassificationsTest.java{*}").inType("{*}").at(TypeReferenceLocation.METHOD_CALL)) .perform( Iteration.over().perform(new AbstractIterationOperation<JavaTypeReferenceModel>() { @Override public void perform(GraphRewrite event, EvaluationContext context, JavaTypeReferenceModel payload) { firstRuleMatchCount++; } }).endIteration()) .addRule() .when(JavaClass.references("org.jboss.windup.rules.java.JavaClassTestFile1.testJavaClassCondition()").matchesSource("{*}{line}{*}").inType("{*}").at(TypeReferenceLocation.METHOD)) .perform( Iteration.over().perform(new AbstractIterationOperation<JavaTypeReferenceModel>() { @Override public void perform(GraphRewrite event, EvaluationContext context, JavaTypeReferenceModel payload) { secondRuleMatchCount++; } }).endIteration()) .where("line").matches("testJavaClassCondition\\(\\) throws IOException, InstantiationException") .addRule() .when(JavaClass.references("org.jboss.windup.exec.configuration.WindupConfiguration.setRuleProviderFilter{*}").matchesSource("{*}{line}{*}").at(TypeReferenceLocation.METHOD_CALL)) .perform( Iteration.over().perform(new AbstractIterationOperation<JavaTypeReferenceModel>() { @Override public void perform(GraphRewrite event, EvaluationContext context, JavaTypeReferenceModel payload) { thirdRuleMatchCount++; } }).endIteration()) .where("line").matches(".setRuleProviderFilter\\(new") .addRule() .when(JavaClass.references("org.jboss.windup.rules.java.JavaClassTestFile2").matchesSource("{*}{line}{*}").at(TypeReferenceLocation.TYPE)) .perform( Iteration.over().perform(new AbstractIterationOperation<JavaTypeReferenceModel>() { @Override public void perform(GraphRewrite event, EvaluationContext context, JavaTypeReferenceModel payload) { fourthRuleMatchCount++; } }).endIteration()) .where("line").matches("public class JavaClassTestFile2") ; }