可用版本:Dev3.21)| 最新版(3.20) | 3.19

匹配 UDT

适用于 ✅ 开源版   ✅ 专业版   ✅ 企业版

以下示例展示了如何为生成的 org.jooq.UDTorg.jooq.UDTRecord 类型及相关对象定义 MatcherStrategy

XML(独立和 Maven)
编程方式
Gradle (Kotlin)
Gradle (Groovy)
Gradle(第三方)
<configuration>
  <!-- These properties can be added directly to the generator element: -->
  <generator>
    <strategy>
      <matchers>

        <!-- Specify 0..n table matchers to provide a strategy for naming objects created from UDTs. -->
        <udts>
          <udt>

            <!-- Match unqualified or qualified UDT names. If left empty, this matcher applies to all UDTs. -->
            <expression>MY_UDT</expression>

            <!-- These elements influence the naming of a generated org.jooq.UDT object. -->
            <udtClass> a MatcherRule specification </udtClass>
            <udtIdentifier> a MatcherRule specification </udtIdentifier>
            <udtExtends>com.example.MyOptionalTableBaseType</udtExtends>
            <udtImplements>com.example.MyOptionalCustomInterface</udtImplements>

            <!-- These elements influence the naming of a generated org.jooq.UDTPathField object. -->
            <pathClass> a MatcherRule specification </pathClass>
            <pathExtends>com.example.MyOptionalTableBaseType</pathExtends>
            <pathImplements>com.example.MyOptionalCustomInterface</pathImplements>

            <!-- These elements influence the naming of a generated org.jooq.UDTRecord object. -->
            <recordClass> a MatcherRule specification </recordClass>
            <recordExtends>com.example.MyOptionalRecordBaseType</recordExtends>
            <recordImplements>com.example.MyOptionalCustomInterface</recordImplements>

            <!-- These elements influence the naming of a generated record types for hierarchical org.jooq.UDTRecord object. -->
            <recordTypeClass> a MatcherRule specification </recordTypeClass>
            <recordTypeImplements>com.example.MyOptionalCustomInterface</recordTypeImplements>

            <!-- These elements influence the naming of a generated interface, implemented by
                 generated org.jooq.UDTRecord objects and by generated POJOs. -->
            <interfaceClass> a MatcherRule specification </interfaceClass>
            <interfaceImplements>com.example.MyOptionalCustomInterface</interfaceImplements>

            <!-- These elements influence the naming of a generated POJO object.  -->
            <pojoClass> a MatcherRule specification </pojoClass>
            <pojoExtends>com.example.MyOptionalPojoBaseClass</pojoExtends>
            <pojoImplements>com.example.MyOptionalCustomInterface</pojoImplements>
          </udt>
        </udts>
      </matchers>
    </strategy>
  </generator>
</configuration>

有关更多详细信息,请参见 配置 XSD独立代码生成maven 代码生成

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 table matchers to provide a strategy for naming objects created from UDTs.
        .withUdts(
          new MatchersUDTType()

            // Match unqualified or qualified UDT names. If left empty, this matcher applies to all UDTs.
            .withExpression("MY_UDT")

            // These elements influence the naming of a generated org.jooq.UDT object.
            .withUdtClass(MatcherRule. a MatcherRule specification )
            .withUdtIdentifier(MatcherRule. a MatcherRule specification )
            .withUdtExtends("com.example.MyOptionalTableBaseType")
            .withUdtImplements("com.example.MyOptionalCustomInterface")

            // These elements influence the naming of a generated org.jooq.UDTPathField object.
            .withPathClass(MatcherRule. a MatcherRule specification )
            .withPathExtends("com.example.MyOptionalTableBaseType")
            .withPathImplements("com.example.MyOptionalCustomInterface")

            // These elements influence the naming of a generated org.jooq.UDTRecord object.
            .withRecordClass(MatcherRule. a MatcherRule specification )
            .withRecordExtends("com.example.MyOptionalRecordBaseType")
            .withRecordImplements("com.example.MyOptionalCustomInterface")

            // These elements influence the naming of a generated record types for hierarchical org.jooq.UDTRecord object.
            .withRecordTypeClass(MatcherRule. a MatcherRule specification )
            .withRecordTypeImplements("com.example.MyOptionalCustomInterface")

            // These elements influence the naming of a generated interface, implemented by
            // generated org.jooq.UDTRecord objects and by generated POJOs.
            .withInterfaceClass(MatcherRule. a MatcherRule specification )
            .withInterfaceImplements("com.example.MyOptionalCustomInterface")

            // These elements influence the naming of a generated POJO object.
            .withPojoClass(MatcherRule. a MatcherRule specification )
            .withPojoExtends("com.example.MyOptionalPojoBaseClass")
            .withPojoImplements("com.example.MyOptionalCustomInterface")
        )
      )
    )
  )

有关更多详细信息,请参见 配置 XSD编程式代码生成

import org.jooq.meta.jaxb.*


configuration {

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

        // Specify 0..n table matchers to provide a strategy for naming objects created from UDTs.
        udts {
          udt {

            // Match unqualified or qualified UDT names. If left empty, this matcher applies to all UDTs.
            expression = "MY_UDT"

            // These elements influence the naming of a generated org.jooq.UDT object.
            udtClass = MatcherRule. a MatcherRule specification 
            udtIdentifier = MatcherRule. a MatcherRule specification 
            udtExtends = "com.example.MyOptionalTableBaseType"
            udtImplements = "com.example.MyOptionalCustomInterface"

            // These elements influence the naming of a generated org.jooq.UDTPathField object.
            pathClass = MatcherRule. a MatcherRule specification 
            pathExtends = "com.example.MyOptionalTableBaseType"
            pathImplements = "com.example.MyOptionalCustomInterface"

            // These elements influence the naming of a generated org.jooq.UDTRecord object.
            recordClass = MatcherRule. a MatcherRule specification 
            recordExtends = "com.example.MyOptionalRecordBaseType"
            recordImplements = "com.example.MyOptionalCustomInterface"

            // These elements influence the naming of a generated record types for hierarchical org.jooq.UDTRecord object.
            recordTypeClass = MatcherRule. a MatcherRule specification 
            recordTypeImplements = "com.example.MyOptionalCustomInterface"

            // These elements influence the naming of a generated interface, implemented by
            // generated org.jooq.UDTRecord objects and by generated POJOs.
            interfaceClass = MatcherRule. a MatcherRule specification 
            interfaceImplements = "com.example.MyOptionalCustomInterface"

            // These elements influence the naming of a generated POJO object.
            pojoClass = MatcherRule. a MatcherRule specification 
            pojoExtends = "com.example.MyOptionalPojoBaseClass"
            pojoImplements = "com.example.MyOptionalCustomInterface"
          }
        }
      }
    }
  }
}

有关更多详细信息,请参见 配置 XSDgradle 代码生成

configuration {

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

        // Specify 0..n table matchers to provide a strategy for naming objects created from UDTs.
        udts {
          udt {

            // Match unqualified or qualified UDT names. If left empty, this matcher applies to all UDTs.
            expression = "MY_UDT"

            // These elements influence the naming of a generated org.jooq.UDT object.
            udtClass = " a MatcherRule specification "
            udtIdentifier = " a MatcherRule specification "
            udtExtends = "com.example.MyOptionalTableBaseType"
            udtImplements = "com.example.MyOptionalCustomInterface"

            // These elements influence the naming of a generated org.jooq.UDTPathField object.
            pathClass = " a MatcherRule specification "
            pathExtends = "com.example.MyOptionalTableBaseType"
            pathImplements = "com.example.MyOptionalCustomInterface"

            // These elements influence the naming of a generated org.jooq.UDTRecord object.
            recordClass = " a MatcherRule specification "
            recordExtends = "com.example.MyOptionalRecordBaseType"
            recordImplements = "com.example.MyOptionalCustomInterface"

            // These elements influence the naming of a generated record types for hierarchical org.jooq.UDTRecord object.
            recordTypeClass = " a MatcherRule specification "
            recordTypeImplements = "com.example.MyOptionalCustomInterface"

            // These elements influence the naming of a generated interface, implemented by
            // generated org.jooq.UDTRecord objects and by generated POJOs.
            interfaceClass = " a MatcherRule specification "
            interfaceImplements = "com.example.MyOptionalCustomInterface"

            // These elements influence the naming of a generated POJO object.
            pojoClass = " a MatcherRule specification "
            pojoExtends = "com.example.MyOptionalPojoBaseClass"
            pojoImplements = "com.example.MyOptionalCustomInterface"
          }
        }
      }
    }
  }
}

有关更多详细信息,请参见 配置 XSDgradle 代码生成

// The jOOQ-codegen-gradle plugin has been introduced in version 3.19.
// Please use the official plugin instead of the third party plugin that was recommended before.

一如既往,当使用正则表达式时,它们是具有默认标志的正则表达式

当使用任何 udtEtendsrecordExtends 等设置时,您必须确保正确实现内部 jOOQ API,这些 API 在此处未记录,因为它们是内部的。 特别是,如果您扩展了 org.jooq.impl.TableImpl,例如,您的自定义基类可能会在 jOOQ 的小版本之间中断,因为添加了新的构造函数。
如果您的 UDTRecord、POJO 类或接口扩展或实现了其他类型,您可以为相应的 属性指定 override 修饰符。

有关 MatcherRule 规范的更多信息,请参见MatcherRule

反馈

您对此页面有任何反馈吗? 我们很乐意听到!

The jOOQ Logo