Available in versions: Dev (3.21) | Latest (3.20) | 3.19 | 3.18 | 3.17 | 3.16 | 3.15 | 3.14 | 3.13 | 3.12 | 3.11
MatcherRule
Supported by ✅ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
                                                Most matchers use references to MatcherRule, which is consists of two elements:
                                            
- The regex replacement experssion to replace the matched name with.
- The transformation directive, which allows for specifying how to transform the resulting name.
Transformation directives
The following transformation directives are supported:
- 
AS_IS: Leave the database name as it is, e.g.MY_name=>MY_name
- 
LOWER: ransform the database name into lower case, e.g.MY_name=>my_name
- 
LOWER_FIRST_LETTER: Transform the first letter into lower case, e.g.MY_name=>mY_name
- 
UPPER: Transform the database name into upper case, e.g.MY_name=>MY_NAME
- 
UPPER_FIRST_LETTER: Transform the first letter into upper case, e.g.my_NAME=>My_NAME
- 
CAMEL: Transform the database name into camel case, e.g.MY_name=>myName
- 
PASCAL: Transform the database name into pascal case, e.g.MY_name=>MyName
Example: Adding a prefix / suffix to names
<configuration>
  <generator>
    <strategy>
      <matchers>
        <schemas>
          <schema>
            <!-- Without an input expression, this rule applies to all schemas -->
            <schemaClass>
              <!-- Optional transform directive -->
              <transform>CAMEL</transform>
              <!-- The mandatory expression element lets you specify a replacement expression to be used when
                   replacing the matcher's regular expression. You can use indexed variables $0, $1, $2. -->
              <expression>PREFIX_$0_SUFFIX</expression>
            </schemaClass>
          </schema>
        </schemas>
      </matchers>
    </strategy>
  </generator>
</configuration>
See the configuration XSD, standalone code generation, and maven code generation for more details.
new org.jooq.meta.jaxb.Configuration()
  .withGenerator(new Generator()
    .withStrategy(new Strategy()
      .withMatchers(new Matchers()
        .withSchemas(
          new MatchersSchemaType()
            // Without an input expression, this rule applies to all schemas
            .withSchemaClass(new MatcherRule()
              // Optional transform directive
              .withTransform(MatcherTransformType.CAMEL)
              // The mandatory expression element lets you specify a replacement expression to be used when
              // replacing the matcher's regular expression. You can use indexed variables $0, $1, $2.
              .withExpression("PREFIX_$0_SUFFIX")
            )
        )
      )
    )
  )
See the configuration XSD and programmatic code generation for more details.
// The jOOQ-codegen-gradle plugin has been introduced in version 3.19 only.
// The jOOQ-codegen-gradle plugin has been introduced in version 3.19 only.
generationTool {
  generator {
    strategy {
      matchers {
        schemas {
          schema {
            // Without an input expression, this rule applies to all schemas
            schemaClass {
              // Optional transform directive
              transform = "CAMEL"
              // The mandatory expression element lets you specify a replacement expression to be used when
              // replacing the matcher's regular expression. You can use indexed variables $0, $1, $2.
              expression = "PREFIX_$0_SUFFIX"
            }
          }
        }
      }
    }
  }
}
See the configuration XSD and gradle code generation for more details.
As always, when regular expressions are used, they are regular expressions with default flags.
Example: Removing a prefix / suffix from names
<configuration>
  <generator>
    <strategy>
      <matchers>
        <tables>
          <table>
            <!-- Provide an optional input expression to apply this rule only to certain tables.
                 We can match groups with the regex (group expression) -->
            <expression>^T_(.*)$</expression>
            <tableClass>
              <!-- Optional transform directive -->
              <transform>CAMEL</transform>
              <!-- This ignores the prefix and replaces the name by the first matched group. -->
              <expression>$1</expression>
            </tableClass>
          </table>
        </tables>
      </matchers>
    </strategy>
  </generator>
</configuration>
See the configuration XSD, standalone code generation, and maven code generation for more details.
new org.jooq.meta.jaxb.Configuration()
  .withGenerator(new Generator()
    .withStrategy(new Strategy()
      .withMatchers(new Matchers()
        .withTables(
          new MatchersTableType()
            // Provide an optional input expression to apply this rule only to certain tables.
            // We can match groups with the regex (group expression)
            .withExpression("^T_(.*)$")
            .withTableClass(new MatcherRule()
              // Optional transform directive
              .withTransform(MatcherTransformType.CAMEL)
              // This ignores the prefix and replaces the name by the first matched group.
              .withExpression("$1")
            )
        )
      )
    )
  )
See the configuration XSD and programmatic code generation for more details.
// The jOOQ-codegen-gradle plugin has been introduced in version 3.19 only.
// The jOOQ-codegen-gradle plugin has been introduced in version 3.19 only.
generationTool {
  generator {
    strategy {
      matchers {
        tables {
          table {
            // Provide an optional input expression to apply this rule only to certain tables.
            // We can match groups with the regex (group expression)
            expression = "^T_(.*)$"
            tableClass {
              // Optional transform directive
              transform = "CAMEL"
              // This ignores the prefix and replaces the name by the first matched group.
              expression = "$1"
            }
          }
        }
      }
    }
  }
}
See the configuration XSD and gradle code generation for more details.
As always, when regular expressions are used, they are regular expressions with default flags.
                                                In other words, a MatcherRule describes how a specific object type name (e.g. a class name representing a generated org.jooq.Schema) should be declared and referenced based on the object's input name.
                                            

 
        
Feedback
Do you have any feedback about this page? We'd love to hear it!