From 03df0cefc8d1c2670fbaba9e8dc3723f990dea85 Mon Sep 17 00:00:00 2001 From: Lukas Eder Date: Thu, 13 Jul 2023 16:11:03 +0200 Subject: [PATCH] [jOOQ/jOOQ#15400] Add a jOOQ-meta-kotlin module for kotlin extensions to the jOOQ-meta module --- jOOQ-meta-kotlin/.gitignore | 6 + jOOQ-meta-kotlin/LICENSE.txt | 19 + jOOQ-meta-kotlin/NOTICE.txt | 10 + jOOQ-meta-kotlin/pom.xml | 80 ++++ .../kotlin/org/jooq/meta/kotlin/Extensions.kt | 415 ++++++++++++++++++ .../src/main/resources/META-INF/LICENSE.txt | 19 + .../src/main/resources/META-INF/README.txt | 2 + 7 files changed, 551 insertions(+) create mode 100644 jOOQ-meta-kotlin/.gitignore create mode 100644 jOOQ-meta-kotlin/LICENSE.txt create mode 100644 jOOQ-meta-kotlin/NOTICE.txt create mode 100644 jOOQ-meta-kotlin/pom.xml create mode 100644 jOOQ-meta-kotlin/src/main/kotlin/org/jooq/meta/kotlin/Extensions.kt create mode 100644 jOOQ-meta-kotlin/src/main/resources/META-INF/LICENSE.txt create mode 100644 jOOQ-meta-kotlin/src/main/resources/META-INF/README.txt diff --git a/jOOQ-meta-kotlin/.gitignore b/jOOQ-meta-kotlin/.gitignore new file mode 100644 index 0000000000..41b88d42d8 --- /dev/null +++ b/jOOQ-meta-kotlin/.gitignore @@ -0,0 +1,6 @@ +/target + +/.cache + +/.idea +/*.iml \ No newline at end of file diff --git a/jOOQ-meta-kotlin/LICENSE.txt b/jOOQ-meta-kotlin/LICENSE.txt new file mode 100644 index 0000000000..84f48a6df9 --- /dev/null +++ b/jOOQ-meta-kotlin/LICENSE.txt @@ -0,0 +1,19 @@ +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +Other licenses: +----------------------------------------------------------------------------- +Commercial licenses for this work are available. These replace the above +ASL 2.0 and offer limited warranties, support, maintenance, and commercial +database integrations. + +For more information, please visit: https://www.jooq.org/legal/licensing \ No newline at end of file diff --git a/jOOQ-meta-kotlin/NOTICE.txt b/jOOQ-meta-kotlin/NOTICE.txt new file mode 100644 index 0000000000..698edf47ee --- /dev/null +++ b/jOOQ-meta-kotlin/NOTICE.txt @@ -0,0 +1,10 @@ +Third party NOTICE.txt contents +=============================== + +Contents of https://github.com/apache/commons-lang/blob/master/NOTICE.txt +------------------------------------------------------------------------- +Apache Commons Lang +Copyright 2001-2019 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). \ No newline at end of file diff --git a/jOOQ-meta-kotlin/pom.xml b/jOOQ-meta-kotlin/pom.xml new file mode 100644 index 0000000000..79a7928dd5 --- /dev/null +++ b/jOOQ-meta-kotlin/pom.xml @@ -0,0 +1,80 @@ + + + + 4.0.0 + + + org.jooq + jooq-parent + 3.19.0-SNAPSHOT + + + jooq-meta-kotlin + jOOQ Meta Kotlin + + + src/main/kotlin + src/test/kotlin + + + kotlin-maven-plugin + org.jetbrains.kotlin + + + + + org.apache.maven.plugins + maven-jar-plugin + + + empty-javadoc-jar + package + + jar + + + javadoc + ${basedir}/javadoc + + + org.jooq.meta.kotlin + + + + + + + + + + + + org.jooq + jooq-meta + + + + org.jetbrains.kotlin + kotlin-stdlib + + + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + + + + + org.jetbrains.kotlin + kotlin-reflect + + + + + + + + + + + \ No newline at end of file diff --git a/jOOQ-meta-kotlin/src/main/kotlin/org/jooq/meta/kotlin/Extensions.kt b/jOOQ-meta-kotlin/src/main/kotlin/org/jooq/meta/kotlin/Extensions.kt new file mode 100644 index 0000000000..ec3ebf4104 --- /dev/null +++ b/jOOQ-meta-kotlin/src/main/kotlin/org/jooq/meta/kotlin/Extensions.kt @@ -0,0 +1,415 @@ +package org.jooq.meta.kotlin + +import org.jooq.meta.jaxb.* +import org.jooq.meta.jaxb.Target + +// ---------------------------------------------------------------------------- +// Extensions to the jOOQ-meta Configuration object hierarchy +// ---------------------------------------------------------------------------- + +fun configuration(block: Configuration.() -> Unit): Configuration { + val c = Configuration() + block(c) + return c +} + +// [jooq-tools] START [jooq-meta] + +fun Configuration.jdbc(block: Jdbc.() -> Unit) { + if (jdbc == null) + jdbc = Jdbc() + + block(jdbc) +} + +fun Jdbc.properties(block: MutableList.() -> Unit) { + block(properties) +} + +@JvmName("mutableListProperty") +fun MutableList.property(block: Property.() -> Unit) { + val e = Property() + block(e) + add(e) +} + +fun Configuration.generator(block: Generator.() -> Unit) { + if (generator == null) + generator = Generator() + + block(generator) +} + +fun Generator.strategy(block: Strategy.() -> Unit) { + if (strategy == null) + strategy = Strategy() + + block(strategy) +} + +fun Strategy.matchers(block: Matchers.() -> Unit) { + if (matchers == null) + matchers = Matchers() + + block(matchers) +} + +fun Matchers.catalogs(block: MutableList.() -> Unit) { + block(catalogs) +} + +@JvmName("mutableListMatchersCatalogType") +fun MutableList.catalog(block: MatchersCatalogType.() -> Unit) { + val e = MatchersCatalogType() + block(e) + add(e) +} + +fun MatchersCatalogType.catalogClass(block: MatcherRule.() -> Unit) { + if (catalogClass == null) + catalogClass = MatcherRule() + + block(catalogClass) +} + +fun Matchers.schemas(block: MutableList.() -> Unit) { + block(schemas) +} + +@JvmName("mutableListMatchersSchemaType") +fun MutableList.schema(block: MatchersSchemaType.() -> Unit) { + val e = MatchersSchemaType() + block(e) + add(e) +} + +fun Matchers.tables(block: MutableList.() -> Unit) { + block(tables) +} + +@JvmName("mutableListMatchersTableType") +fun MutableList.table(block: MatchersTableType.() -> Unit) { + val e = MatchersTableType() + block(e) + add(e) +} + +fun Matchers.foreignKeys(block: MutableList.() -> Unit) { + block(foreignKeys) +} + +@JvmName("mutableListMatchersForeignKeyType") +fun MutableList.foreignKey(block: MatchersForeignKeyType.() -> Unit) { + val e = MatchersForeignKeyType() + block(e) + add(e) +} + +fun Matchers.fields(block: MutableList.() -> Unit) { + block(fields) +} + +@JvmName("mutableListMatchersFieldType") +fun MutableList.field(block: MatchersFieldType.() -> Unit) { + val e = MatchersFieldType() + block(e) + add(e) +} + +fun Matchers.routines(block: MutableList.() -> Unit) { + block(routines) +} + +@JvmName("mutableListMatchersRoutineType") +fun MutableList.routine(block: MatchersRoutineType.() -> Unit) { + val e = MatchersRoutineType() + block(e) + add(e) +} + +fun Matchers.sequences(block: MutableList.() -> Unit) { + block(sequences) +} + +@JvmName("mutableListMatchersSequenceType") +fun MutableList.sequence(block: MatchersSequenceType.() -> Unit) { + val e = MatchersSequenceType() + block(e) + add(e) +} + +fun Matchers.enums(block: MutableList.() -> Unit) { + block(enums) +} + +@JvmName("mutableListMatchersEnumType") +fun MutableList.enum(block: MatchersEnumType.() -> Unit) { + val e = MatchersEnumType() + block(e) + add(e) +} + +fun Matchers.embeddables(block: MutableList.() -> Unit) { + block(embeddables) +} + +@JvmName("mutableListMatchersEmbeddableType") +fun MutableList.embeddable(block: MatchersEmbeddableType.() -> Unit) { + val e = MatchersEmbeddableType() + block(e) + add(e) +} + +fun Generator.database(block: Database.() -> Unit) { + if (database == null) + database = Database() + + block(database) +} + +fun Database.syntheticObjects(block: SyntheticObjectsType.() -> Unit) { + if (syntheticObjects == null) + syntheticObjects = SyntheticObjectsType() + + block(syntheticObjects) +} + +fun SyntheticObjectsType.readonlyColumns(block: MutableList.() -> Unit) { + block(readonlyColumns) +} + +@JvmName("mutableListSyntheticReadonlyColumnType") +fun MutableList.readonlyColumn(block: SyntheticReadonlyColumnType.() -> Unit) { + val e = SyntheticReadonlyColumnType() + block(e) + add(e) +} + +fun SyntheticObjectsType.readonlyRowids(block: MutableList.() -> Unit) { + block(readonlyRowids) +} + +@JvmName("mutableListSyntheticReadonlyRowidType") +fun MutableList.readonlyRowid(block: SyntheticReadonlyRowidType.() -> Unit) { + val e = SyntheticReadonlyRowidType() + block(e) + add(e) +} + +fun SyntheticObjectsType.columns(block: MutableList.() -> Unit) { + block(columns) +} + +@JvmName("mutableListSyntheticColumnType") +fun MutableList.column(block: SyntheticColumnType.() -> Unit) { + val e = SyntheticColumnType() + block(e) + add(e) +} + +fun SyntheticObjectsType.identities(block: MutableList.() -> Unit) { + block(identities) +} + +@JvmName("mutableListSyntheticIdentityType") +fun MutableList.identity(block: SyntheticIdentityType.() -> Unit) { + val e = SyntheticIdentityType() + block(e) + add(e) +} + +fun SyntheticObjectsType.enums(block: MutableList.() -> Unit) { + block(enums) +} + +@JvmName("mutableListSyntheticEnumType") +fun MutableList.enum(block: SyntheticEnumType.() -> Unit) { + val e = SyntheticEnumType() + block(e) + add(e) +} + +fun SyntheticObjectsType.primaryKeys(block: MutableList.() -> Unit) { + block(primaryKeys) +} + +@JvmName("mutableListSyntheticPrimaryKeyType") +fun MutableList.primaryKey(block: SyntheticPrimaryKeyType.() -> Unit) { + val e = SyntheticPrimaryKeyType() + block(e) + add(e) +} + +fun SyntheticObjectsType.uniqueKeys(block: MutableList.() -> Unit) { + block(uniqueKeys) +} + +@JvmName("mutableListSyntheticUniqueKeyType") +fun MutableList.uniqueKey(block: SyntheticUniqueKeyType.() -> Unit) { + val e = SyntheticUniqueKeyType() + block(e) + add(e) +} + +fun SyntheticObjectsType.foreignKeys(block: MutableList.() -> Unit) { + block(foreignKeys) +} + +@JvmName("mutableListSyntheticForeignKeyType") +fun MutableList.foreignKey(block: SyntheticForeignKeyType.() -> Unit) { + val e = SyntheticForeignKeyType() + block(e) + add(e) +} + +fun SyntheticObjectsType.views(block: MutableList.() -> Unit) { + block(views) +} + +@JvmName("mutableListSyntheticViewType") +fun MutableList.view(block: SyntheticViewType.() -> Unit) { + val e = SyntheticViewType() + block(e) + add(e) +} + +fun SyntheticObjectsType.daos(block: MutableList.() -> Unit) { + block(daos) +} + +@JvmName("mutableListSyntheticDaoType") +fun MutableList.dao(block: SyntheticDaoType.() -> Unit) { + val e = SyntheticDaoType() + block(e) + add(e) +} + +fun SyntheticDaoType.methods(block: MutableList.() -> Unit) { + block(methods) +} + +@JvmName("mutableListSyntheticDaoMethodType") +fun MutableList.method(block: SyntheticDaoMethodType.() -> Unit) { + val e = SyntheticDaoMethodType() + block(e) + add(e) +} + +fun Database.properties(block: MutableList.() -> Unit) { + block(properties) +} + +fun Database.comments(block: MutableList.() -> Unit) { + block(comments) +} + +@JvmName("mutableListCommentType") +fun MutableList.comment(block: CommentType.() -> Unit) { + val e = CommentType() + block(e) + add(e) +} + +fun Database.catalogs(block: MutableList.() -> Unit) { + block(catalogs) +} + +@JvmName("mutableListCatalogMappingType") +fun MutableList.catalog(block: CatalogMappingType.() -> Unit) { + val e = CatalogMappingType() + block(e) + add(e) +} + +fun CatalogMappingType.schemata(block: MutableList.() -> Unit) { + block(schemata) +} + +@JvmName("mutableListSchemaMappingType") +fun MutableList.schema(block: SchemaMappingType.() -> Unit) { + val e = SchemaMappingType() + block(e) + add(e) +} + +fun Database.schemata(block: MutableList.() -> Unit) { + block(schemata) +} + +fun Database.embeddables(block: MutableList.() -> Unit) { + block(embeddables) +} + +@JvmName("mutableListEmbeddableDefinitionType") +fun MutableList.embeddable(block: EmbeddableDefinitionType.() -> Unit) { + val e = EmbeddableDefinitionType() + block(e) + add(e) +} + +fun EmbeddableDefinitionType.fields(block: MutableList.() -> Unit) { + block(fields) +} + +@JvmName("mutableListEmbeddableField") +fun MutableList.field(block: EmbeddableField.() -> Unit) { + val e = EmbeddableField() + block(e) + add(e) +} + +fun Database.customTypes(block: MutableList.() -> Unit) { + block(customTypes) +} + +@JvmName("mutableListCustomType") +fun MutableList.customType(block: CustomType.() -> Unit) { + val e = CustomType() + block(e) + add(e) +} + +fun CustomType.lambdaConverter(block: LambdaConverter.() -> Unit) { + if (lambdaConverter == null) + lambdaConverter = LambdaConverter() + + block(lambdaConverter) +} + +fun Database.enumTypes(block: MutableList.() -> Unit) { + block(enumTypes) +} + +@JvmName("mutableListEnumType") +fun MutableList.enumType(block: EnumType.() -> Unit) { + val e = EnumType() + block(e) + add(e) +} + +fun Database.forcedTypes(block: MutableList.() -> Unit) { + block(forcedTypes) +} + +@JvmName("mutableListForcedType") +fun MutableList.forcedType(block: ForcedType.() -> Unit) { + val e = ForcedType() + block(e) + add(e) +} + +fun Generator.generate(block: Generate.() -> Unit) { + if (generate == null) + generate = Generate() + + block(generate) +} + +fun Generator.target(block: Target.() -> Unit) { + if (target == null) + target = Target() + + block(target) +} + +// [jooq-tools] END [jooq-meta] diff --git a/jOOQ-meta-kotlin/src/main/resources/META-INF/LICENSE.txt b/jOOQ-meta-kotlin/src/main/resources/META-INF/LICENSE.txt new file mode 100644 index 0000000000..84f48a6df9 --- /dev/null +++ b/jOOQ-meta-kotlin/src/main/resources/META-INF/LICENSE.txt @@ -0,0 +1,19 @@ +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +Other licenses: +----------------------------------------------------------------------------- +Commercial licenses for this work are available. These replace the above +ASL 2.0 and offer limited warranties, support, maintenance, and commercial +database integrations. + +For more information, please visit: https://www.jooq.org/legal/licensing \ No newline at end of file diff --git a/jOOQ-meta-kotlin/src/main/resources/META-INF/README.txt b/jOOQ-meta-kotlin/src/main/resources/META-INF/README.txt new file mode 100644 index 0000000000..3e6e227e05 --- /dev/null +++ b/jOOQ-meta-kotlin/src/main/resources/META-INF/README.txt @@ -0,0 +1,2 @@ +Thanks for downloading jOOQ. +Please visit http://www.jooq.org for more information. \ No newline at end of file