Available in versions: Dev (3.20) | Latest (3.19) | 3.18 | 3.17 | 3.16 | 3.15 | 3.14 | 3.13 | 3.12 | 3.11 | 3.10

This documentation is for the unreleased development version of jOOQ. Click on the above version links to get this documentation for a supported version of jOOQ.

Matching fields

Applies to ✅ Open Source Edition   ✅ Express Edition   ✅ Professional Edition   ✅ Enterprise Edition

The following example shows how to define a MatcherStrategy for generated org.jooq.Field types and related objects:

XML (standalone and maven)
Programmatic
Gradle (Kotlin)
Gradle (Groovy)
Gradle (third party)
<configuration>
  <!-- These properties can be added directly to the generator element: -->
  <generator>
    <strategy>
      <matchers>

        <!-- Specify 0..n field matchers to provide a strategy for naming objects created from fields. -->
        <fields>
          <field>

            <!-- Match unqualified or qualified field names. If left empty, this matcher applies to all fields. -->
            <expression>MY_FIELD</expression>

            <!-- These elements influence the naming of a generated org.jooq.Field object. -->
            <fieldIdentifier> a MatcherRule specification </fieldIdentifier>
            <fieldMember> a MatcherRule specification </fieldMember>
            <fieldSetter> a MatcherRule specification </fieldSetter>
            <fieldGetter> a MatcherRule specification </fieldGetter>

            <!-- These elements influence the naming of generated DAO methods. -->
            <daoMember> a MatcherRule specification </daoMember>

            <!-- Whether a method should have an override modifier, e.g. because of an implemented interface -->
            <recordSetterOverride>false</recordSetterOverride>
            <recordGetterOverride>false</recordGetterOverride>
            <recordMemberOverride>false</recordMemberOverride>
            <interfaceSetterOverride>false</interfaceSetterOverride>
            <interfaceGetterOverride>false</interfaceGetterOverride>
            <interfaceMemberOverride>false</interfaceMemberOverride>
            <pojoSetterOverride>false</pojoSetterOverride>
            <pojoGetterOverride>false</pojoGetterOverride>
            <pojoMemberOverride>false</pojoMemberOverride>
          </field>
        </fields>
      </matchers>
    </strategy>
  </generator>
</configuration>

See the configuration XSD, standalone code generation, and maven code generation for more details.

new org.jooq.meta.jaxb.Configuration()

  // These properties can be added directly to the generator element:
  .withGenerator(new Generator()
    .withStrategy(new Strategy()
      .withMatchers(new Matchers()

        // Specify 0..n field matchers to provide a strategy for naming objects created from fields.
        .withFields(
          new MatchersFieldType()

            // Match unqualified or qualified field names. If left empty, this matcher applies to all fields.
            .withExpression("MY_FIELD")

            // These elements influence the naming of a generated org.jooq.Field object.
            .withFieldIdentifier(MatcherRule. a MatcherRule specification )
            .withFieldMember(MatcherRule. a MatcherRule specification )
            .withFieldSetter(MatcherRule. a MatcherRule specification )
            .withFieldGetter(MatcherRule. a MatcherRule specification )

            // These elements influence the naming of generated DAO methods.
            .withDaoMember(" a MatcherRule specification ")

            // Whether a method should have an override modifier, e.g. because of an implemented interface
            .withRecordSetterOverride(false)
            .withRecordGetterOverride(false)
            .withRecordMemberOverride(false)
            .withInterfaceSetterOverride(false)
            .withInterfaceGetterOverride(false)
            .withInterfaceMemberOverride(false)
            .withPojoSetterOverride(false)
            .withPojoGetterOverride(false)
            .withPojoMemberOverride(false)
        )
      )
    )
  )

See the configuration XSD and programmatic code generation for more details.

import org.jooq.meta.jaxb.*


configuration {

  // These properties can be added directly to the generator element:
  generator {
    strategy {
      matchers {

        // Specify 0..n field matchers to provide a strategy for naming objects created from fields.
        fields {
          field {

            // Match unqualified or qualified field names. If left empty, this matcher applies to all fields.
            expression = "MY_FIELD"

            // These elements influence the naming of a generated org.jooq.Field object.
            fieldIdentifier = MatcherRule. a MatcherRule specification 
            fieldMember = MatcherRule. a MatcherRule specification 
            fieldSetter = MatcherRule. a MatcherRule specification 
            fieldGetter = MatcherRule. a MatcherRule specification 

            // These elements influence the naming of generated DAO methods.
            daoMember = " a MatcherRule specification "

            // Whether a method should have an override modifier, e.g. because of an implemented interface
            isRecordSetterOverride = false
            isRecordGetterOverride = false
            isRecordMemberOverride = false
            isInterfaceSetterOverride = false
            isInterfaceGetterOverride = false
            isInterfaceMemberOverride = false
            isPojoSetterOverride = false
            isPojoGetterOverride = false
            isPojoMemberOverride = false
          }
        }
      }
    }
  }
}

See the configuration XSD and gradle code generation for more details.

configuration {

  // These properties can be added directly to the generator element:
  generator {
    strategy {
      matchers {

        // Specify 0..n field matchers to provide a strategy for naming objects created from fields.
        fields {
          field {

            // Match unqualified or qualified field names. If left empty, this matcher applies to all fields.
            expression = "MY_FIELD"

            // These elements influence the naming of a generated org.jooq.Field object.
            fieldIdentifier = " a MatcherRule specification "
            fieldMember = " a MatcherRule specification "
            fieldSetter = " a MatcherRule specification "
            fieldGetter = " a MatcherRule specification "

            // These elements influence the naming of generated DAO methods.
            daoMember = " a MatcherRule specification "

            // Whether a method should have an override modifier, e.g. because of an implemented interface
            recordSetterOverride = false
            recordGetterOverride = false
            recordMemberOverride = false
            interfaceSetterOverride = false
            interfaceGetterOverride = false
            interfaceMemberOverride = false
            pojoSetterOverride = false
            pojoGetterOverride = false
            pojoMemberOverride = false
          }
        }
      }
    }
  }
}

See the configuration XSD and gradle code generation for more details.

generationTool {

  // These properties can be added directly to the generator element:
  generator {
    strategy {
      matchers {

        // Specify 0..n field matchers to provide a strategy for naming objects created from fields.
        fields {
          field {

            // Match unqualified or qualified field names. If left empty, this matcher applies to all fields.
            expression = "MY_FIELD"

            // These elements influence the naming of a generated org.jooq.Field object.
            fieldIdentifier = " a MatcherRule specification "
            fieldMember = " a MatcherRule specification "
            fieldSetter = " a MatcherRule specification "
            fieldGetter = " a MatcherRule specification "

            // These elements influence the naming of generated DAO methods.
            daoMember = " a MatcherRule specification "

            // Whether a method should have an override modifier, e.g. because of an implemented interface
            recordSetterOverride = false
            recordGetterOverride = false
            recordMemberOverride = false
            interfaceSetterOverride = false
            interfaceGetterOverride = false
            interfaceMemberOverride = false
            pojoSetterOverride = false
            pojoGetterOverride = false
            pojoMemberOverride = false
          }
        }
      }
    }
  }
}

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.

See MatcherRule for more information about MatcherRule specifications.

References to this page

Feedback

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

The jOOQ Logo