diff --git a/jOOQ/src/main/java/org/jooq/CreateTypeFinalStep.java b/jOOQ/src/main/java/org/jooq/CreateTypeFinalStep.java index 958db20a36..743d1378bc 100644 --- a/jOOQ/src/main/java/org/jooq/CreateTypeFinalStep.java +++ b/jOOQ/src/main/java/org/jooq/CreateTypeFinalStep.java @@ -37,9 +37,19 @@ */ package org.jooq; +import static org.jooq.SQLDialect.*; +import static org.jooq.impl.DSL.*; + +import java.util.*; + +import org.jooq.impl.DSL; + +import org.jetbrains.annotations.*; /** - * A {@link Query} that can create types. + * A step in the construction of the CREATE TYPE statement. + *

+ * @deprecated - [#11329] - 3.15.0 - This type will be removed in the future. Do not reference it directly *

*

Referencing XYZ*Step types directly from client code

*

@@ -58,11 +68,8 @@ package org.jooq; *

  • They're less readable
  • *
  • They might have binary incompatible changes between minor releases
  • * - * - * @deprecated - [#11329] - 3.15.0 - This type will be removed in the future. Do not reference it directly - * @author Lukas Eder */ +@SuppressWarnings({ "unused" }) @Deprecated(forRemoval = true, since = "3.15") public interface CreateTypeFinalStep extends DDLQuery { - } diff --git a/jOOQ/src/main/java/org/jooq/CreateTypeStep.java b/jOOQ/src/main/java/org/jooq/CreateTypeStep.java index dc51511fbb..b7d35b3ab6 100644 --- a/jOOQ/src/main/java/org/jooq/CreateTypeStep.java +++ b/jOOQ/src/main/java/org/jooq/CreateTypeStep.java @@ -37,17 +37,17 @@ */ package org.jooq; +import static org.jooq.SQLDialect.*; +import static org.jooq.impl.DSL.*; + +import java.util.*; + +import org.jooq.impl.DSL; + import org.jetbrains.annotations.*; -// ... -import static org.jooq.SQLDialect.H2; -import static org.jooq.SQLDialect.POSTGRES; -import static org.jooq.SQLDialect.YUGABYTEDB; - -import java.util.Collection; - /** - * A {@link Query} that can create types. + * A step in the construction of the CREATE TYPE statement. *

    *

    Referencing XYZ*Step types directly from client code

    *

    @@ -66,37 +66,35 @@ import java.util.Collection; *

  • They're less readable
  • *
  • They might have binary incompatible changes between minor releases
  • * - * - * @author Lukas Eder */ +@SuppressWarnings({ "unused" }) public interface CreateTypeStep { /** * Add the AS ENUM clause to the CREATE TYPE statement. */ - @NotNull @CheckReturnValue @Support({ H2, POSTGRES, YUGABYTEDB }) - CreateTypeFinalStep asEnum(); - - /** - * Add the AS ENUM clause to the CREATE TYPE statement. - */ @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) CreateTypeFinalStep asEnum(String... values); /** * Add the AS ENUM clause to the CREATE TYPE statement. */ - @SuppressWarnings("unchecked") - @NotNull @CheckReturnValue @Support({ H2, POSTGRES, YUGABYTEDB }) + @NotNull @CheckReturnValue CreateTypeFinalStep asEnum(Field... values); /** * Add the AS ENUM clause to the CREATE TYPE statement. */ - @NotNull @CheckReturnValue @Support({ H2, POSTGRES, YUGABYTEDB }) - CreateTypeFinalStep asEnum(Collection values); + @NotNull @CheckReturnValue + CreateTypeFinalStep asEnum(Collection> values); + + /** + * Add the AS ENUM clause to the CREATE TYPE statement. + */ + @Support({ H2, POSTGRES, YUGABYTEDB }) + @NotNull @CheckReturnValue + CreateTypeFinalStep asEnum(); } diff --git a/jOOQ/src/main/java/org/jooq/DSLContext.java b/jOOQ/src/main/java/org/jooq/DSLContext.java index 70ec69ee04..319cc2b6db 100644 --- a/jOOQ/src/main/java/org/jooq/DSLContext.java +++ b/jOOQ/src/main/java/org/jooq/DSLContext.java @@ -10273,6 +10273,33 @@ public interface DSLContext extends Scope { + + /** + * The CREATE TYPE statement. + * + * @see DSL#createType(String) + */ + @NotNull @CheckReturnValue + @Support({ H2, POSTGRES, YUGABYTEDB }) + CreateTypeStep createType(@Stringly.Name String type); + + /** + * The CREATE TYPE statement. + * + * @see DSL#createType(Name) + */ + @NotNull @CheckReturnValue + @Support({ H2, POSTGRES, YUGABYTEDB }) + CreateTypeStep createType(Name type); + + /** + * The CREATE TYPE statement. + * + * @see DSL#createType(Type) + */ + @NotNull @CheckReturnValue + @Support({ H2, POSTGRES, YUGABYTEDB }) + CreateTypeStep createType(Type type); /** * The CREATE SCHEMA statement. @@ -10891,6 +10918,132 @@ public interface DSLContext extends Scope { + + /** + * The DROP TYPE statement. + * + * @see DSL#dropType(String) + */ + @NotNull @CheckReturnValue + @Support({ H2, POSTGRES, YUGABYTEDB }) + DropTypeStep dropType(@Stringly.Name String types); + + /** + * The DROP TYPE statement. + * + * @see DSL#dropType(Name) + */ + @NotNull @CheckReturnValue + @Support({ H2, POSTGRES, YUGABYTEDB }) + DropTypeStep dropType(Name types); + + /** + * The DROP TYPE statement. + * + * @see DSL#dropType(Type) + */ + @NotNull @CheckReturnValue + @Support({ H2, POSTGRES, YUGABYTEDB }) + DropTypeStep dropType(Type types); + + /** + * The DROP TYPE statement. + * + * @see DSL#dropType(String...) + */ + @NotNull @CheckReturnValue + @Support({ H2, POSTGRES, YUGABYTEDB }) + DropTypeStep dropType(String... types); + + /** + * The DROP TYPE statement. + * + * @see DSL#dropType(Name...) + */ + @NotNull @CheckReturnValue + @Support({ H2, POSTGRES, YUGABYTEDB }) + DropTypeStep dropType(Name... types); + + /** + * The DROP TYPE statement. + * + * @see DSL#dropType(Type...) + */ + @NotNull @CheckReturnValue + @Support({ H2, POSTGRES, YUGABYTEDB }) + DropTypeStep dropType(Type... types); + + /** + * The DROP TYPE statement. + * + * @see DSL#dropType(Collection) + */ + @NotNull @CheckReturnValue + @Support({ H2, POSTGRES, YUGABYTEDB }) + DropTypeStep dropType(Collection> types); + + /** + * The DROP TYPE IF EXISTS statement. + * + * @see DSL#dropTypeIfExists(String) + */ + @NotNull @CheckReturnValue + @Support({ H2, POSTGRES, YUGABYTEDB }) + DropTypeStep dropTypeIfExists(@Stringly.Name String types); + + /** + * The DROP TYPE IF EXISTS statement. + * + * @see DSL#dropTypeIfExists(Name) + */ + @NotNull @CheckReturnValue + @Support({ H2, POSTGRES, YUGABYTEDB }) + DropTypeStep dropTypeIfExists(Name types); + + /** + * The DROP TYPE IF EXISTS statement. + * + * @see DSL#dropTypeIfExists(Type) + */ + @NotNull @CheckReturnValue + @Support({ H2, POSTGRES, YUGABYTEDB }) + DropTypeStep dropTypeIfExists(Type types); + + /** + * The DROP TYPE IF EXISTS statement. + * + * @see DSL#dropTypeIfExists(String...) + */ + @NotNull @CheckReturnValue + @Support({ H2, POSTGRES, YUGABYTEDB }) + DropTypeStep dropTypeIfExists(String... types); + + /** + * The DROP TYPE IF EXISTS statement. + * + * @see DSL#dropTypeIfExists(Name...) + */ + @NotNull @CheckReturnValue + @Support({ H2, POSTGRES, YUGABYTEDB }) + DropTypeStep dropTypeIfExists(Name... types); + + /** + * The DROP TYPE IF EXISTS statement. + * + * @see DSL#dropTypeIfExists(Type...) + */ + @NotNull @CheckReturnValue + @Support({ H2, POSTGRES, YUGABYTEDB }) + DropTypeStep dropTypeIfExists(Type... types); + + /** + * The DROP TYPE IF EXISTS statement. + * + * @see DSL#dropTypeIfExists(Collection) + */ + @NotNull @CheckReturnValue + @Support({ H2, POSTGRES, YUGABYTEDB }) + DropTypeStep dropTypeIfExists(Collection> types); /** * The DROP VIEW statement. @@ -11725,114 +11878,6 @@ public interface DSLContext extends Scope { @Support({ DUCKDB, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB }) CreateViewAsStep createViewIfNotExists(Table view, BiFunction, ? super Integer, ? extends Field> fieldNameFunction); - /** - * Create a new DSL CREATE TYPE statement. - * - * @see DSL#createType(String) - */ - @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) - CreateTypeStep createType(String type); - - /** - * Create a new DSL CREATE TYPE statement. - * - * @see DSL#createType(Name) - */ - @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) - CreateTypeStep createType(Name type); - - /** - * Create a new DSL DROP TYPE statement. - * - * @see DSL#dropType(String) - */ - @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) - DropTypeStep dropType(String type); - - /** - * Create a new DSL DROP TYPE statement. - * - * @see DSL#dropType(Name) - */ - @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) - DropTypeStep dropType(Name type); - - /** - * Create a new DSL DROP TYPE statement. - * - * @see DSL#dropType(String...) - */ - @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) - DropTypeStep dropType(String... type); - - /** - * Create a new DSL DROP TYPE statement. - * - * @see DSL#dropType(Name...) - */ - @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) - DropTypeStep dropType(Name... type); - - /** - * Create a new DSL DROP TYPE statement. - * - * @see DSL#dropType(Collection) - */ - @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) - DropTypeStep dropType(Collection type); - - /** - * Create a new DSL DROP TYPE statement. - * - * @see DSL#dropTypeIfExists(String) - */ - @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) - DropTypeStep dropTypeIfExists(String type); - - /** - * Create a new DSL DROP TYPE statement. - * - * @see DSL#dropTypeIfExists(Name) - */ - @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) - DropTypeStep dropTypeIfExists(Name type); - - /** - * Create a new DSL DROP TYPE statement. - * - * @see DSL#dropTypeIfExists(String...) - */ - @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) - DropTypeStep dropTypeIfExists(String... type); - - /** - * Create a new DSL DROP TYPE statement. - * - * @see DSL#dropTypeIfExists(Name...) - */ - @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) - DropTypeStep dropTypeIfExists(Name... type); - - /** - * Create a new DSL DROP TYPE statement. - * - * @see DSL#dropTypeIfExists(Collection) - */ - @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) - DropTypeStep dropTypeIfExists(Collection type); - /** * Create a new DSL ALTER TABLE statement. * diff --git a/jOOQ/src/main/java/org/jooq/DropTypeFinalStep.java b/jOOQ/src/main/java/org/jooq/DropTypeFinalStep.java index e40db8617a..1921327935 100644 --- a/jOOQ/src/main/java/org/jooq/DropTypeFinalStep.java +++ b/jOOQ/src/main/java/org/jooq/DropTypeFinalStep.java @@ -37,9 +37,19 @@ */ package org.jooq; +import static org.jooq.SQLDialect.*; +import static org.jooq.impl.DSL.*; + +import java.util.*; + +import org.jooq.impl.DSL; + +import org.jetbrains.annotations.*; /** - * A {@link Query} that can drop types. + * A step in the construction of the DROP TYPE statement. + *

    + * @deprecated - [#11329] - 3.15.0 - This type will be removed in the future. Do not reference it directly *

    *

    Referencing XYZ*Step types directly from client code

    *

    @@ -58,11 +68,8 @@ package org.jooq; *

  • They're less readable
  • *
  • They might have binary incompatible changes between minor releases
  • * - * - * @deprecated - [#11329] - 3.15.0 - This type will be removed in the future. Do not reference it directly - * @author Lukas Eder */ +@SuppressWarnings({ "unused" }) @Deprecated(forRemoval = true, since = "3.15") public interface DropTypeFinalStep extends DDLQuery { - } diff --git a/jOOQ/src/main/java/org/jooq/DropTypeStep.java b/jOOQ/src/main/java/org/jooq/DropTypeStep.java index 5e3f678553..bd5fb78d8e 100644 --- a/jOOQ/src/main/java/org/jooq/DropTypeStep.java +++ b/jOOQ/src/main/java/org/jooq/DropTypeStep.java @@ -37,15 +37,17 @@ */ package org.jooq; +import static org.jooq.SQLDialect.*; +import static org.jooq.impl.DSL.*; + +import java.util.*; + +import org.jooq.impl.DSL; + import org.jetbrains.annotations.*; -// ... -import static org.jooq.SQLDialect.H2; -import static org.jooq.SQLDialect.POSTGRES; -import static org.jooq.SQLDialect.YUGABYTEDB; - /** - * A {@link Query} that can drop types. + * A step in the construction of the DROP TYPE statement. *

    *

    Referencing XYZ*Step types directly from client code

    *

    @@ -64,22 +66,21 @@ import static org.jooq.SQLDialect.YUGABYTEDB; *

  • They're less readable
  • *
  • They might have binary incompatible changes between minor releases
  • * - * - * @author Lukas Eder */ +@SuppressWarnings({ "unused" }) public interface DropTypeStep extends DropTypeFinalStep { /** * Add the CASCADE clause to the DROP TYPE statement. */ - @NotNull @CheckReturnValue @Support({ H2, POSTGRES, YUGABYTEDB }) + @NotNull @CheckReturnValue DropTypeFinalStep cascade(); /** * Add the RESTRICT clause to the DROP TYPE statement. */ - @NotNull @CheckReturnValue @Support({ H2, POSTGRES, YUGABYTEDB }) + @NotNull @CheckReturnValue DropTypeFinalStep restrict(); } diff --git a/jOOQ/src/main/java/org/jooq/Type.java b/jOOQ/src/main/java/org/jooq/Type.java new file mode 100644 index 0000000000..70ee3f42ba --- /dev/null +++ b/jOOQ/src/main/java/org/jooq/Type.java @@ -0,0 +1,47 @@ +/* + * 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 + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + */ +package org.jooq; + +/** + * An object representing a user defined type. + * + * @author Lukas Eder + */ +public interface Type extends Typed { + +} diff --git a/jOOQ/src/main/java/org/jooq/impl/CreateTypeImpl.java b/jOOQ/src/main/java/org/jooq/impl/CreateTypeImpl.java index 763221b4b5..38a415a335 100644 --- a/jOOQ/src/main/java/org/jooq/impl/CreateTypeImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/CreateTypeImpl.java @@ -37,83 +37,98 @@ */ package org.jooq.impl; -import static org.jooq.impl.Keywords.K_AS; -import static org.jooq.impl.Keywords.K_CREATE; -import static org.jooq.impl.Keywords.K_ENUM; -import static org.jooq.impl.Keywords.K_TYPE; -import static org.jooq.impl.SQLDataType.VARCHAR; +import static org.jooq.impl.DSL.*; +import static org.jooq.impl.Internal.*; +import static org.jooq.impl.Keywords.*; +import static org.jooq.impl.Names.*; +import static org.jooq.impl.SQLDataType.*; +import static org.jooq.impl.Tools.*; +import static org.jooq.impl.Tools.BooleanDataKey.*; +import static org.jooq.impl.Tools.ExtendedDataKey.*; +import static org.jooq.impl.Tools.SimpleDataKey.*; +import static org.jooq.SQLDialect.*; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.function.BiFunction; -import java.util.function.Predicate; - -import org.jooq.Configuration; -import org.jooq.Context; -import org.jooq.CreateTypeFinalStep; -import org.jooq.CreateTypeStep; -import org.jooq.Field; +import org.jooq.*; import org.jooq.Function1; -import org.jooq.Name; -import org.jooq.conf.ParamType; -import org.jooq.impl.QOM.CreateType; -import org.jooq.impl.QOM.UnmodifiableList; -import org.jooq.QueryPart; -// ... -// ... +import org.jooq.Record; +import org.jooq.conf.*; +import org.jooq.impl.*; +import org.jooq.impl.QOM.*; +import org.jooq.tools.*; + +import java.util.*; +import java.util.function.*; +import java.util.stream.*; + /** - * @author Lukas Eder + * The CREATE TYPE statement. */ -final class CreateTypeImpl extends AbstractDDLQuery implements - - // Cascading interface implementations for CREATE TYPE behaviour +@SuppressWarnings({ "hiding", "rawtypes", "unused" }) +final class CreateTypeImpl +extends + AbstractDDLQuery +implements + QOM.CreateType, CreateTypeStep, - CreateTypeFinalStep, - CreateType - + CreateTypeFinalStep { - private final Name type; - private final QueryPartList> values; + final Type type; + QueryPartListView> values; - CreateTypeImpl(Configuration configuration, Name type) { + CreateTypeImpl( + Configuration configuration, + Type type + ) { + this( + configuration, + type, + null + ); + } + + CreateTypeImpl( + Configuration configuration, + Type type, + Collection> values + ) { super(configuration); this.type = type; - this.values = new QueryPartList<>(); + this.values = new QueryPartList<>(values); } - // ------------------------------------------------------------------------ + // ------------------------------------------------------------------------- // XXX: DSL API - // ------------------------------------------------------------------------ + // ------------------------------------------------------------------------- @Override - public final CreateTypeFinalStep asEnum() { - return asEnum(Collections.emptyList()); + public final CreateTypeImpl asEnum(String... values) { + return asEnum(Tools.fields(values)); } @Override - public final CreateTypeFinalStep asEnum(String... v) { - return asEnum(Tools.map(v, s -> DSL.inline(s))); - } - - @SafeVarargs - @Override - public final CreateTypeFinalStep asEnum(Field... v) { - return asEnum(Arrays.asList(v)); + public final CreateTypeImpl asEnum(Field... values) { + return asEnum(Arrays.asList(values)); } @Override - public final CreateTypeFinalStep asEnum(Collection v) { - values.addAll(Tools.fields(v, VARCHAR)); + public final CreateTypeImpl asEnum(Collection> values) { + this.values = new QueryPartList<>(values); return this; } - // ------------------------------------------------------------------------ + @Override + public final CreateTypeImpl asEnum() { + return this; + } + + // ------------------------------------------------------------------------- // XXX: QueryPart API - // ------------------------------------------------------------------------ + // ------------------------------------------------------------------------- + + @Override public final void accept(Context ctx) { @@ -124,12 +139,14 @@ final class CreateTypeImpl extends AbstractDDLQuery implements .sql(')'); } + + // ------------------------------------------------------------------------- // XXX: Query Object Model // ------------------------------------------------------------------------- @Override - public final Name $name() { + public final Type $type() { return type; } @@ -138,6 +155,29 @@ final class CreateTypeImpl extends AbstractDDLQuery implements return QOM.unmodifiable(values); } + @Override + public final QOM.CreateType $type(Type newValue) { + return $constructor().apply(newValue, $values()); + } + + @Override + public final QOM.CreateType $values(Collection> newValue) { + return $constructor().apply($type(), newValue); + } + + public final Function2, ? super Collection>, ? extends QOM.CreateType> $constructor() { + return (a1, a2) -> new CreateTypeImpl(configuration(), a1, (Collection>) a2); + } + + + + + + + + + + diff --git a/jOOQ/src/main/java/org/jooq/impl/DSL.java b/jOOQ/src/main/java/org/jooq/impl/DSL.java index 9d9a5bb1de..a957324530 100644 --- a/jOOQ/src/main/java/org/jooq/impl/DSL.java +++ b/jOOQ/src/main/java/org/jooq/impl/DSL.java @@ -389,6 +389,7 @@ import org.jooq.Support; import org.jooq.Table; import org.jooq.TableLike; import org.jooq.True; +import org.jooq.Type; import org.jooq.Update; import org.jooq.UpdateSetFirstStep; import org.jooq.User; @@ -8767,6 +8768,51 @@ public class DSL { + + /** + * The CREATE TYPE statement. + *

    + * Unlike statement construction methods in the {@link DSLContext} API, this + * creates an unattached, and thus not directly renderable or executable + * statement. It can be used as a subquery or nested in procedural logic. + * + * @see DSLContext#createType(String) + */ + @NotNull @CheckReturnValue + @Support({ H2, POSTGRES, YUGABYTEDB }) + public static org.jooq.CreateTypeStep createType(@Stringly.Name String type) { + return dsl().createType(type); + } + + /** + * The CREATE TYPE statement. + *

    + * Unlike statement construction methods in the {@link DSLContext} API, this + * creates an unattached, and thus not directly renderable or executable + * statement. It can be used as a subquery or nested in procedural logic. + * + * @see DSLContext#createType(Name) + */ + @NotNull @CheckReturnValue + @Support({ H2, POSTGRES, YUGABYTEDB }) + public static org.jooq.CreateTypeStep createType(Name type) { + return dsl().createType(type); + } + + /** + * The CREATE TYPE statement. + *

    + * Unlike statement construction methods in the {@link DSLContext} API, this + * creates an unattached, and thus not directly renderable or executable + * statement. It can be used as a subquery or nested in procedural logic. + * + * @see DSLContext#createType(Type) + */ + @NotNull @CheckReturnValue + @Support({ H2, POSTGRES, YUGABYTEDB }) + public static org.jooq.CreateTypeStep createType(Type type) { + return dsl().createType(type); + } /** * The CREATE SCHEMA statement. @@ -9781,6 +9827,216 @@ public class DSL { + + /** + * The DROP TYPE statement. + *

    + * Unlike statement construction methods in the {@link DSLContext} API, this + * creates an unattached, and thus not directly renderable or executable + * statement. It can be used as a subquery or nested in procedural logic. + * + * @see DSLContext#dropType(String) + */ + @NotNull @CheckReturnValue + @Support({ H2, POSTGRES, YUGABYTEDB }) + public static org.jooq.DropTypeStep dropType(@Stringly.Name String types) { + return dsl().dropType(types); + } + + /** + * The DROP TYPE statement. + *

    + * Unlike statement construction methods in the {@link DSLContext} API, this + * creates an unattached, and thus not directly renderable or executable + * statement. It can be used as a subquery or nested in procedural logic. + * + * @see DSLContext#dropType(Name) + */ + @NotNull @CheckReturnValue + @Support({ H2, POSTGRES, YUGABYTEDB }) + public static org.jooq.DropTypeStep dropType(Name types) { + return dsl().dropType(types); + } + + /** + * The DROP TYPE statement. + *

    + * Unlike statement construction methods in the {@link DSLContext} API, this + * creates an unattached, and thus not directly renderable or executable + * statement. It can be used as a subquery or nested in procedural logic. + * + * @see DSLContext#dropType(Type) + */ + @NotNull @CheckReturnValue + @Support({ H2, POSTGRES, YUGABYTEDB }) + public static org.jooq.DropTypeStep dropType(Type types) { + return dsl().dropType(types); + } + + /** + * The DROP TYPE statement. + *

    + * Unlike statement construction methods in the {@link DSLContext} API, this + * creates an unattached, and thus not directly renderable or executable + * statement. It can be used as a subquery or nested in procedural logic. + * + * @see DSLContext#dropType(String...) + */ + @NotNull @CheckReturnValue + @Support({ H2, POSTGRES, YUGABYTEDB }) + public static org.jooq.DropTypeStep dropType(String... types) { + return dsl().dropType(types); + } + + /** + * The DROP TYPE statement. + *

    + * Unlike statement construction methods in the {@link DSLContext} API, this + * creates an unattached, and thus not directly renderable or executable + * statement. It can be used as a subquery or nested in procedural logic. + * + * @see DSLContext#dropType(Name...) + */ + @NotNull @CheckReturnValue + @Support({ H2, POSTGRES, YUGABYTEDB }) + public static org.jooq.DropTypeStep dropType(Name... types) { + return dsl().dropType(types); + } + + /** + * The DROP TYPE statement. + *

    + * Unlike statement construction methods in the {@link DSLContext} API, this + * creates an unattached, and thus not directly renderable or executable + * statement. It can be used as a subquery or nested in procedural logic. + * + * @see DSLContext#dropType(Type...) + */ + @NotNull @CheckReturnValue + @Support({ H2, POSTGRES, YUGABYTEDB }) + public static org.jooq.DropTypeStep dropType(Type... types) { + return dsl().dropType(types); + } + + /** + * The DROP TYPE statement. + *

    + * Unlike statement construction methods in the {@link DSLContext} API, this + * creates an unattached, and thus not directly renderable or executable + * statement. It can be used as a subquery or nested in procedural logic. + * + * @see DSLContext#dropType(Collection) + */ + @NotNull @CheckReturnValue + @Support({ H2, POSTGRES, YUGABYTEDB }) + public static org.jooq.DropTypeStep dropType(Collection> types) { + return dsl().dropType(types); + } + + /** + * The DROP TYPE IF EXISTS statement. + *

    + * Unlike statement construction methods in the {@link DSLContext} API, this + * creates an unattached, and thus not directly renderable or executable + * statement. It can be used as a subquery or nested in procedural logic. + * + * @see DSLContext#dropTypeIfExists(String) + */ + @NotNull @CheckReturnValue + @Support({ H2, POSTGRES, YUGABYTEDB }) + public static org.jooq.DropTypeStep dropTypeIfExists(@Stringly.Name String types) { + return dsl().dropTypeIfExists(types); + } + + /** + * The DROP TYPE IF EXISTS statement. + *

    + * Unlike statement construction methods in the {@link DSLContext} API, this + * creates an unattached, and thus not directly renderable or executable + * statement. It can be used as a subquery or nested in procedural logic. + * + * @see DSLContext#dropTypeIfExists(Name) + */ + @NotNull @CheckReturnValue + @Support({ H2, POSTGRES, YUGABYTEDB }) + public static org.jooq.DropTypeStep dropTypeIfExists(Name types) { + return dsl().dropTypeIfExists(types); + } + + /** + * The DROP TYPE IF EXISTS statement. + *

    + * Unlike statement construction methods in the {@link DSLContext} API, this + * creates an unattached, and thus not directly renderable or executable + * statement. It can be used as a subquery or nested in procedural logic. + * + * @see DSLContext#dropTypeIfExists(Type) + */ + @NotNull @CheckReturnValue + @Support({ H2, POSTGRES, YUGABYTEDB }) + public static org.jooq.DropTypeStep dropTypeIfExists(Type types) { + return dsl().dropTypeIfExists(types); + } + + /** + * The DROP TYPE IF EXISTS statement. + *

    + * Unlike statement construction methods in the {@link DSLContext} API, this + * creates an unattached, and thus not directly renderable or executable + * statement. It can be used as a subquery or nested in procedural logic. + * + * @see DSLContext#dropTypeIfExists(String...) + */ + @NotNull @CheckReturnValue + @Support({ H2, POSTGRES, YUGABYTEDB }) + public static org.jooq.DropTypeStep dropTypeIfExists(String... types) { + return dsl().dropTypeIfExists(types); + } + + /** + * The DROP TYPE IF EXISTS statement. + *

    + * Unlike statement construction methods in the {@link DSLContext} API, this + * creates an unattached, and thus not directly renderable or executable + * statement. It can be used as a subquery or nested in procedural logic. + * + * @see DSLContext#dropTypeIfExists(Name...) + */ + @NotNull @CheckReturnValue + @Support({ H2, POSTGRES, YUGABYTEDB }) + public static org.jooq.DropTypeStep dropTypeIfExists(Name... types) { + return dsl().dropTypeIfExists(types); + } + + /** + * The DROP TYPE IF EXISTS statement. + *

    + * Unlike statement construction methods in the {@link DSLContext} API, this + * creates an unattached, and thus not directly renderable or executable + * statement. It can be used as a subquery or nested in procedural logic. + * + * @see DSLContext#dropTypeIfExists(Type...) + */ + @NotNull @CheckReturnValue + @Support({ H2, POSTGRES, YUGABYTEDB }) + public static org.jooq.DropTypeStep dropTypeIfExists(Type... types) { + return dsl().dropTypeIfExists(types); + } + + /** + * The DROP TYPE IF EXISTS statement. + *

    + * Unlike statement construction methods in the {@link DSLContext} API, this + * creates an unattached, and thus not directly renderable or executable + * statement. It can be used as a subquery or nested in procedural logic. + * + * @see DSLContext#dropTypeIfExists(Collection) + */ + @NotNull @CheckReturnValue + @Support({ H2, POSTGRES, YUGABYTEDB }) + public static org.jooq.DropTypeStep dropTypeIfExists(Collection> types) { + return dsl().dropTypeIfExists(types); + } /** * The DROP VIEW statement. @@ -10720,138 +10976,6 @@ public class DSL { return dsl().createViewIfNotExists(view, fieldNameFunction); } - /** - * Create a new DSL CREATE TYPE statement. - * - * @see DSLContext#createType(String) - */ - @NotNull - @Support({ H2, POSTGRES, YUGABYTEDB }) - public static CreateTypeStep createType(String type) { - return dsl().createType(type); - } - - /** - * Create a new DSL CREATE TYPE statement. - * - * @see DSLContext#createType(Name) - */ - @NotNull - @Support({ H2, POSTGRES, YUGABYTEDB }) - public static CreateTypeStep createType(Name type) { - return dsl().createType(type); - } - - /** - * Create a new DSL DROP TYPE statement. - * - * @see DSL#dropType(String) - */ - @NotNull - @Support({ H2, POSTGRES, YUGABYTEDB }) - public static DropTypeStep dropType(String type) { - return dsl().dropType(type); - } - - /** - * Create a new DSL DROP TYPE statement. - * - * @see DSL#dropType(Name) - */ - @NotNull - @Support({ H2, POSTGRES, YUGABYTEDB }) - public static DropTypeStep dropType(Name type) { - return dsl().dropType(type); - } - - /** - * Create a new DSL DROP TYPE statement. - * - * @see DSL#dropType(String...) - */ - @NotNull - @Support({ H2, POSTGRES, YUGABYTEDB }) - public static DropTypeStep dropType(String... type) { - return dsl().dropType(type); - } - - /** - * Create a new DSL DROP TYPE statement. - * - * @see DSL#dropType(Name...) - */ - @NotNull - @Support({ H2, POSTGRES, YUGABYTEDB }) - public static DropTypeStep dropType(Name... type) { - return dsl().dropType(type); - } - - /** - * Create a new DSL DROP TYPE statement. - * - * @see DSL#dropType(Collection) - */ - @NotNull - @Support({ H2, POSTGRES, YUGABYTEDB }) - public static DropTypeStep dropType(Collection type) { - return dsl().dropType(type); - } - - /** - * Create a new DSL DROP TYPE statement. - * - * @see DSL#dropTypeIfExists(String) - */ - @NotNull - @Support({ H2, POSTGRES, YUGABYTEDB }) - public static DropTypeStep dropTypeIfExists(String type) { - return dsl().dropTypeIfExists(type); - } - - /** - * Create a new DSL DROP TYPE statement. - * - * @see DSL#dropTypeIfExists(Name) - */ - @NotNull - @Support({ H2, POSTGRES, YUGABYTEDB }) - public static DropTypeStep dropTypeIfExists(Name type) { - return dsl().dropTypeIfExists(type); - } - - /** - * Create a new DSL DROP TYPE statement. - * - * @see DSL#dropTypeIfExists(String...) - */ - @NotNull - @Support({ H2, POSTGRES, YUGABYTEDB }) - public static DropTypeStep dropTypeIfExists(String... type) { - return dsl().dropTypeIfExists(type); - } - - /** - * Create a new DSL DROP TYPE statement. - * - * @see DSL#dropTypeIfExists(Name...) - */ - @NotNull - @Support({ H2, POSTGRES, YUGABYTEDB }) - public static DropTypeStep dropTypeIfExists(Name... type) { - return dsl().dropTypeIfExists(type); - } - - /** - * Create a new DSL DROP TYPE statement. - * - * @see DSL#dropTypeIfExists(Collection) - */ - @NotNull - @Support({ H2, POSTGRES, YUGABYTEDB }) - public static DropTypeStep dropTypeIfExists(Collection type) { - return dsl().dropTypeIfExists(type); - } - /** * Create a new DSL ALTER TABLE statement. * @@ -12606,6 +12730,42 @@ public class DSL { ); } + /** + * Create a qualified type, given its type name. + */ + @NotNull + @Support({ H2, POSTGRES, YUGABYTEDB }) + public static Type type(@Stringly.Name String name) { + return type(name(name)); + } + + /** + * Create a qualified type, given its type name. + */ + @NotNull + @Support({ H2, POSTGRES, YUGABYTEDB }) + public static Type type(Name name) { + return type(name, SQLDataType.OTHER); + } + + /** + * Create a qualified type, given its type name. + */ + @NotNull + @Support({ H2, POSTGRES, YUGABYTEDB }) + public static Type type(@Stringly.Name String name, DataType type) { + return type(name(name), type); + } + + /** + * Create a qualified type, given its type name. + */ + @NotNull + @Support({ H2, POSTGRES, YUGABYTEDB }) + public static Type type(Name name, DataType type) { + return new TypeImpl<>(name, CommentImpl.NO_COMMENT, type); + } + /** * Create a qualified table, given its table name. *

    diff --git a/jOOQ/src/main/java/org/jooq/impl/DefaultDSLContext.java b/jOOQ/src/main/java/org/jooq/impl/DefaultDSLContext.java index 86a28b55e2..fead41128d 100644 --- a/jOOQ/src/main/java/org/jooq/impl/DefaultDSLContext.java +++ b/jOOQ/src/main/java/org/jooq/impl/DefaultDSLContext.java @@ -108,7 +108,6 @@ import org.jooq.ConnectionProvider; import org.jooq.ConnectionRunnable; import org.jooq.ContextTransactionalCallable; import org.jooq.ContextTransactionalRunnable; -import org.jooq.CreateTypeStep; import org.jooq.CreateViewAsStep; import org.jooq.Cursor; import org.jooq.DDLExportConfiguration; @@ -118,7 +117,6 @@ import org.jooq.DataType; import org.jooq.DeleteQuery; import org.jooq.DeleteUsingStep; import org.jooq.Domain; -import org.jooq.DropTypeStep; import org.jooq.ExecuteContext; import org.jooq.ExecuteListener; import org.jooq.Explain; @@ -234,6 +232,7 @@ import org.jooq.TransactionProvider; import org.jooq.TransactionalCallable; import org.jooq.TransactionalPublishable; import org.jooq.TransactionalRunnable; +import org.jooq.Type; import org.jooq.UDT; import org.jooq.UDTRecord; import org.jooq.UpdatableRecord; @@ -3418,6 +3417,21 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri + + @Override + public org.jooq.CreateTypeStep createType(@Stringly.Name String type) { + return new CreateTypeImpl(configuration(), DSL.type(DSL.name(type))); + } + + @Override + public org.jooq.CreateTypeStep createType(Name type) { + return new CreateTypeImpl(configuration(), DSL.type(type)); + } + + @Override + public org.jooq.CreateTypeStep createType(Type type) { + return new CreateTypeImpl(configuration(), type); + } @Override public org.jooq.CreateSchemaFinalStep createSchema(@Stringly.Name String schema) { @@ -3772,6 +3786,76 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri + + @Override + public org.jooq.DropTypeStep dropType(@Stringly.Name String types) { + return new DropTypeImpl(configuration(), Arrays.asList(DSL.type(types)), false); + } + + @Override + public org.jooq.DropTypeStep dropType(Name types) { + return new DropTypeImpl(configuration(), Arrays.asList(DSL.type(types)), false); + } + + @Override + public org.jooq.DropTypeStep dropType(Type types) { + return new DropTypeImpl(configuration(), Arrays.asList(types), false); + } + + @Override + public org.jooq.DropTypeStep dropType(String... types) { + return new DropTypeImpl(configuration(), Tools.map(types, e -> DSL.type(e)), false); + } + + @Override + public org.jooq.DropTypeStep dropType(Name... types) { + return new DropTypeImpl(configuration(), Tools.map(types, e -> DSL.type(e)), false); + } + + @Override + public org.jooq.DropTypeStep dropType(Type... types) { + return new DropTypeImpl(configuration(), Arrays.asList(types), false); + } + + @Override + public org.jooq.DropTypeStep dropType(Collection> types) { + return new DropTypeImpl(configuration(), new QueryPartList<>(types), false); + } + + @Override + public org.jooq.DropTypeStep dropTypeIfExists(@Stringly.Name String types) { + return new DropTypeImpl(configuration(), Arrays.asList(DSL.type(types)), true); + } + + @Override + public org.jooq.DropTypeStep dropTypeIfExists(Name types) { + return new DropTypeImpl(configuration(), Arrays.asList(DSL.type(types)), true); + } + + @Override + public org.jooq.DropTypeStep dropTypeIfExists(Type types) { + return new DropTypeImpl(configuration(), Arrays.asList(types), true); + } + + @Override + public org.jooq.DropTypeStep dropTypeIfExists(String... types) { + return new DropTypeImpl(configuration(), Tools.map(types, e -> DSL.type(e)), true); + } + + @Override + public org.jooq.DropTypeStep dropTypeIfExists(Name... types) { + return new DropTypeImpl(configuration(), Tools.map(types, e -> DSL.type(e)), true); + } + + @Override + public org.jooq.DropTypeStep dropTypeIfExists(Type... types) { + return new DropTypeImpl(configuration(), Arrays.asList(types), true); + } + + @Override + public org.jooq.DropTypeStep dropTypeIfExists(Collection> types) { + return new DropTypeImpl(configuration(), new QueryPartList<>(types), true); + } @Override public org.jooq.DropViewFinalStep dropView(@Stringly.Name String view) { @@ -4199,66 +4283,6 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri return new CreateViewImpl<>(configuration(), view, fieldNameFunction, true, false); } - @Override - public CreateTypeStep createType(String type) { - return createType(name(type)); - } - - @Override - public CreateTypeStep createType(Name type) { - return new CreateTypeImpl(configuration(), type); - } - - @Override - public DropTypeStep dropType(String type) { - return dropType(name(type)); - } - - @Override - public DropTypeStep dropType(Name type) { - return dropType(Arrays.asList(type)); - } - - @Override - public DropTypeStep dropType(String... type) { - return dropType(Tools.names(type)); - } - - @Override - public DropTypeStep dropType(Name... type) { - return dropType(Arrays.asList(type)); - } - - @Override - public DropTypeStep dropType(Collection type) { - return new DropTypeImpl(configuration(), type, false); - } - - @Override - public DropTypeStep dropTypeIfExists(String type) { - return dropTypeIfExists(name(type)); - } - - @Override - public DropTypeStep dropTypeIfExists(Name type) { - return dropTypeIfExists(Arrays.asList(type)); - } - - @Override - public DropTypeStep dropTypeIfExists(String... type) { - return dropTypeIfExists(Tools.names(type)); - } - - @Override - public DropTypeStep dropTypeIfExists(Name... type) { - return dropTypeIfExists(Arrays.asList(type)); - } - - @Override - public DropTypeStep dropTypeIfExists(Collection type) { - return new DropTypeImpl(configuration(), type, true); - } - @Override public AlterTableStep alterTable(String table) { return alterTable(name(table)); diff --git a/jOOQ/src/main/java/org/jooq/impl/DropTypeImpl.java b/jOOQ/src/main/java/org/jooq/impl/DropTypeImpl.java index f26df788d3..67237843ca 100644 --- a/jOOQ/src/main/java/org/jooq/impl/DropTypeImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/DropTypeImpl.java @@ -37,71 +37,94 @@ */ package org.jooq.impl; -import static org.jooq.impl.Keywords.K_CASCADE; -import static org.jooq.impl.Keywords.K_DROP; -import static org.jooq.impl.Keywords.K_IF_EXISTS; -import static org.jooq.impl.Keywords.K_RESTRICT; -import static org.jooq.impl.Keywords.K_TYPE; +import static org.jooq.impl.DSL.*; +import static org.jooq.impl.Internal.*; +import static org.jooq.impl.Keywords.*; +import static org.jooq.impl.Names.*; +import static org.jooq.impl.SQLDataType.*; +import static org.jooq.impl.Tools.*; +import static org.jooq.impl.Tools.BooleanDataKey.*; +import static org.jooq.impl.Tools.ExtendedDataKey.*; +import static org.jooq.impl.Tools.SimpleDataKey.*; +import static org.jooq.SQLDialect.*; -import java.util.Collection; -import java.util.function.BiFunction; -import java.util.function.Predicate; - -import org.jooq.Configuration; -import org.jooq.Context; -import org.jooq.DropTypeFinalStep; -import org.jooq.DropTypeStep; -import org.jooq.Field; +import org.jooq.*; import org.jooq.Function1; -import org.jooq.Name; -import org.jooq.impl.QOM.Cascade; -import org.jooq.impl.QOM.DropType; -import org.jooq.impl.QOM.UnmodifiableList; -import org.jooq.QueryPart; -// ... -// ... +import org.jooq.Record; +import org.jooq.conf.*; +import org.jooq.impl.*; +import org.jooq.impl.QOM.*; +import org.jooq.tools.*; + +import java.util.*; +import java.util.function.*; +import java.util.stream.*; + /** - * @author Lukas Eder + * The DROP TYPE statement. */ +@SuppressWarnings({ "rawtypes", "unused" }) final class DropTypeImpl extends AbstractDDLQuery implements + QOM.DropType, DropTypeStep, - DropType + DropTypeFinalStep { - private final QueryPartList type; - private final boolean ifExists; - private Cascade cascade; + final QueryPartListView> types; + final boolean ifExists; + Cascade cascade; - DropTypeImpl(Configuration configuration, Collection type, boolean ifExists) { - super(configuration); - - this.type = new QueryPartList<>(Tools.names(type)); - this.ifExists = ifExists; + DropTypeImpl( + Configuration configuration, + Collection> types, + boolean ifExists + ) { + this( + configuration, + types, + ifExists, + null + ); } - // ------------------------------------------------------------------------ + DropTypeImpl( + Configuration configuration, + Collection> types, + boolean ifExists, + Cascade cascade + ) { + super(configuration); + + this.types = new QueryPartList<>(types); + this.ifExists = ifExists; + this.cascade = cascade; + } + + // ------------------------------------------------------------------------- // XXX: DSL API - // ------------------------------------------------------------------------ + // ------------------------------------------------------------------------- @Override - public final DropTypeFinalStep cascade() { + public final DropTypeImpl cascade() { this.cascade = Cascade.CASCADE; return this; } @Override - public final DropTypeFinalStep restrict() { + public final DropTypeImpl restrict() { this.cascade = Cascade.RESTRICT; return this; } - // ------------------------------------------------------------------------ + // ------------------------------------------------------------------------- // XXX: QueryPart API - // ------------------------------------------------------------------------ + // ------------------------------------------------------------------------- + + @Override public final void accept(Context ctx) { @@ -110,20 +133,23 @@ implements if (ifExists) ctx.sql(' ').visit(K_IF_EXISTS); - ctx.sql(' ').visit(type); + ctx.sql(' ').visit(types); if (cascade == Cascade.CASCADE) ctx.sql(' ').visit(K_CASCADE); else if (cascade == Cascade.RESTRICT) ctx.sql(' ').visit(K_RESTRICT); } + + + // ------------------------------------------------------------------------- // XXX: Query Object Model // ------------------------------------------------------------------------- @Override - public final UnmodifiableList $names() { - return QOM.unmodifiable(type); + public final UnmodifiableList> $types() { + return QOM.unmodifiable(types); } @Override @@ -136,6 +162,30 @@ implements return cascade; } + @Override + public final QOM.DropType $types(Collection> newValue) { + return $constructor().apply(newValue, $ifExists(), $cascade()); + } + + @Override + public final QOM.DropType $ifExists(boolean newValue) { + return $constructor().apply($types(), newValue, $cascade()); + } + + @Override + public final QOM.DropType $cascade(Cascade newValue) { + return $constructor().apply($types(), $ifExists(), newValue); + } + + public final Function3>, ? super Boolean, ? super Cascade, ? extends QOM.DropType> $constructor() { + return (a1, a2, a3) -> new DropTypeImpl(configuration(), (Collection>) a1, a2, a3); + } + + + + + + diff --git a/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java b/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java index d7d0575757..03cec9c17b 100644 --- a/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java @@ -3148,7 +3148,10 @@ final class DefaultParseContext extends AbstractScope implements ParseContext { ; else if (parseKeywordIf("TYPE")) return parseCascadeRestrictIf( - parseIfExists(this::parseIdentifiers, dsl::dropTypeIfExists, dsl::dropType), + parseIfExists(this::parseIdentifiers, + n -> dsl.dropTypeIfExists(n.toArray(EMPTY_NAME)), + n -> dsl.dropType(n.toArray(EMPTY_NAME)) + ), DropTypeStep::cascade, DropTypeStep::restrict ); @@ -5123,7 +5126,7 @@ final class DefaultParseContext extends AbstractScope implements ParseContext { else values = new ArrayList<>(); - return dsl.createType(name).asEnum(values); + return dsl.createType(name).asEnum(values.toArray(EMPTY_STRING)); } private final Index parseIndexSpecification(Table table) { diff --git a/jOOQ/src/main/java/org/jooq/impl/QOM.java b/jOOQ/src/main/java/org/jooq/impl/QOM.java index b9f9c41a78..eee63e3235 100644 --- a/jOOQ/src/main/java/org/jooq/impl/QOM.java +++ b/jOOQ/src/main/java/org/jooq/impl/QOM.java @@ -47,14 +47,12 @@ import java.math.BigDecimal; import java.sql.Date; import java.sql.Timestamp; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.UUID; import java.util.function.BiPredicate; -import java.util.function.Function; import java.util.function.Predicate; import java.util.stream.Collector; @@ -113,7 +111,6 @@ import org.jooq.Param; import org.jooq.Parameter; import org.jooq.Privilege; // ... -import org.jooq.QuantifiedSelect; import org.jooq.Query; import org.jooq.QueryPart; import org.jooq.Record; @@ -138,14 +135,13 @@ import org.jooq.Table; import org.jooq.TableElement; import org.jooq.TableLike; // ... -import org.jooq.UniqueKey; +import org.jooq.Type; // ... import org.jooq.WindowDefinition; import org.jooq.WindowSpecification; import org.jooq.XML; import org.jooq.XMLAttributes; import org.jooq.conf.Settings; -import org.jooq.impl.QOM.UCommutativeOperator; import org.jooq.types.DayToSecond; // ... @@ -630,33 +626,6 @@ public final class QOM { @NotNull DeleteReturning $returning(Collection returning); } - /** - * The CREATE TYPE statement. - */ - public /*sealed*/ interface CreateType - extends - DDLQuery - /*permits - CreateTypeImpl*/ - { - @NotNull Name $name(); - @NotNull UnmodifiableList> $values(); - } - - /** - * The DROP TYPE statement. - */ - public /*sealed*/ interface DropType - extends - DDLQuery - /*permits - DropTypeImpl*/ - { - @NotNull UnmodifiableList $names(); - boolean $ifExists(); - @Nullable Cascade $cascade(); - } - /** * The CREATE VIEW statement. */ @@ -2288,6 +2257,23 @@ public final class QOM { + + /** + * The CREATE TYPE statement. + */ + public /*sealed*/ interface CreateType + extends + DDLQuery + //permits + // CreateTypeImpl + { + @NotNull Type $type(); + @NotNull UnmodifiableList> $values(); + @CheckReturnValue + @NotNull CreateType $type(Type type); + @CheckReturnValue + @NotNull CreateType $values(Collection> values); + } /** * The CREATE SCHEMA statement. @@ -2529,6 +2515,26 @@ public final class QOM { + + /** + * The DROP TYPE statement. + */ + public /*sealed*/ interface DropType + extends + DDLQuery + //permits + // DropTypeImpl + { + @NotNull UnmodifiableList> $types(); + boolean $ifExists(); + @Nullable Cascade $cascade(); + @CheckReturnValue + @NotNull DropType $types(Collection> types); + @CheckReturnValue + @NotNull DropType $ifExists(boolean ifExists); + @CheckReturnValue + @NotNull DropType $cascade(Cascade cascade); + } /** * The DROP VIEW statement. diff --git a/jOOQ/src/main/java/org/jooq/impl/TypeImpl.java b/jOOQ/src/main/java/org/jooq/impl/TypeImpl.java new file mode 100644 index 0000000000..4871972306 --- /dev/null +++ b/jOOQ/src/main/java/org/jooq/impl/TypeImpl.java @@ -0,0 +1,64 @@ +/* + * 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 + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + */ +package org.jooq.impl; + +import org.jooq.Comment; +import org.jooq.Context; +import org.jooq.DataType; +import org.jooq.Name; +import org.jooq.Type; +import org.jooq.impl.QOM.UNotYetImplemented; + +/** + * @author Lukas Eder + */ +class TypeImpl extends AbstractTypedNamed implements Type, UNotYetImplemented { + + TypeImpl(Name name, Comment comment, DataType type) { + super(name, comment, type); + } + + // ------------------------------------------------------------------------ + // QueryPart API + // ------------------------------------------------------------------------ + + @Override + public final void accept(Context ctx) { + ctx.visit(getQualifiedName()); + } +}