diff --git a/jOOQ/src/main/java/org/jooq/Field.java b/jOOQ/src/main/java/org/jooq/Field.java index 5842072363..c720fa1608 100644 --- a/jOOQ/src/main/java/org/jooq/Field.java +++ b/jOOQ/src/main/java/org/jooq/Field.java @@ -710,6 +710,13 @@ extends @Support Condition isDistinctFrom(Field arg2); + /** + * The IS_NULL operator. + */ + @NotNull + @Support + Condition isNull(); + /** * The IS_NOT_DISTINCT_FROM operator. *

@@ -740,6 +747,13 @@ extends @Support Condition isNotDistinctFrom(Field arg2); + /** + * The IS_NOT_NULL operator. + */ + @NotNull + @Support + Condition isNotNull(); + // ------------------------------------------------------------------------- // XML predicates // ------------------------------------------------------------------------- @@ -1347,28 +1361,6 @@ extends @Support Field divide(Field value); - // ------------------------------------------------------------------------ - // NULL predicates - // ------------------------------------------------------------------------ - - /** - * Create a condition to check this field against null. - *

- * SQL: this is null - */ - @NotNull - @Support - Condition isNull(); - - /** - * Create a condition to check this field against null. - *

- * SQL: this is not null - */ - @NotNull - @Support - Condition isNotNull(); - // ------------------------------------------------------------------------ // LIKE_REGEX predicates // ------------------------------------------------------------------------ diff --git a/jOOQ/src/main/java/org/jooq/impl/AbstractField.java b/jOOQ/src/main/java/org/jooq/impl/AbstractField.java index cbaac6c6fe..4851718482 100644 --- a/jOOQ/src/main/java/org/jooq/impl/AbstractField.java +++ b/jOOQ/src/main/java/org/jooq/impl/AbstractField.java @@ -357,6 +357,12 @@ abstract class AbstractField extends AbstractTypedNamed implements Field extends AbstractTypedNamed implements Field extends AbstractTypedNamed implements FieldIS NOT NULL statement. + */ +@SuppressWarnings({ "rawtypes", "unused" }) +final class IsNotNull +extends + AbstractCondition +{ + + final Field arg1; + + IsNotNull( + Field arg1 + ) { + + this.arg1 = nullSafeNotNull(arg1, OTHER); + } + + // ------------------------------------------------------------------------- + // XXX: QueryPart API + // ------------------------------------------------------------------------- + + + + private static final Clause[] CLAUSES = { Clause.CONDITION, Clause.CONDITION_IS_NOT_NULL }; + + @Override + final boolean isNullable() { + return false; + } + + @Override + public final void accept(Context ctx) { + + + + + + if (arg1.getDataType().isEmbeddable()) + ctx.visit(row(embeddedFields(arg1)).isNotNull()); + else + ctx.visit(arg1).sql(' ').visit(K_IS_NOT_NULL); + } + + @Override + public final Clause[] clauses(Context ctx) { + return CLAUSES; + } + + + + + + + + + + + + + // ------------------------------------------------------------------------- + // The Object API + // ------------------------------------------------------------------------- + + @Override + public boolean equals(Object that) { + if (that instanceof IsNotNull) { + return + StringUtils.equals(arg1, ((IsNotNull) that).arg1) + ; + } + else + return super.equals(that); + } +} diff --git a/jOOQ/src/main/java/org/jooq/impl/IsNull.java b/jOOQ/src/main/java/org/jooq/impl/IsNull.java index bf8489cfcd..0da2070fd8 100644 --- a/jOOQ/src/main/java/org/jooq/impl/IsNull.java +++ b/jOOQ/src/main/java/org/jooq/impl/IsNull.java @@ -35,38 +35,54 @@ * * */ - package org.jooq.impl; -import static org.jooq.Clause.CONDITION; -import static org.jooq.Clause.CONDITION_IS_NOT_NULL; -import static org.jooq.Clause.CONDITION_IS_NULL; -// ... -import static org.jooq.impl.DSL.row; -import static org.jooq.impl.Keywords.K_IS_NOT_NULL; -import static org.jooq.impl.Keywords.K_IS_NULL; -import static org.jooq.impl.Tools.embeddedFields; +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.DataExtendedKey.*; +import static org.jooq.impl.Tools.DataKey.*; +import static org.jooq.SQLDialect.*; + +import org.jooq.*; +import org.jooq.Record; +import org.jooq.conf.*; +import org.jooq.impl.*; +import org.jooq.tools.*; + +import java.util.*; -import org.jooq.Clause; -import org.jooq.Context; -import org.jooq.Field; /** - * @author Lukas Eder + * The IS NULL statement. */ -final class IsNull extends AbstractCondition { +@SuppressWarnings({ "rawtypes", "unused" }) +final class IsNull +extends + AbstractCondition +{ - private static final Clause[] CLAUSES_NULL = { CONDITION, CONDITION_IS_NULL }; - private static final Clause[] CLAUSES_NULL_NOT = { CONDITION, CONDITION_IS_NOT_NULL }; + final Field arg1; - private final Field field; - private final boolean isNull; + IsNull( + Field arg1 + ) { - IsNull(Field field, boolean isNull) { - this.field = field; - this.isNull = isNull; + this.arg1 = nullSafeNotNull(arg1, OTHER); } + // ------------------------------------------------------------------------- + // XXX: QueryPart API + // ------------------------------------------------------------------------- + + + + private static final Clause[] CLAUSES = { Clause.CONDITION, Clause.CONDITION_IS_NULL }; + @Override final boolean isNullable() { return false; @@ -74,21 +90,45 @@ final class IsNull extends AbstractCondition { @Override public final void accept(Context ctx) { - if (field.getDataType().isEmbeddable()) - if (isNull) - ctx.visit(row(embeddedFields(field)).isNull()); - else - ctx.visit(row(embeddedFields(field)).isNotNull()); + + if (arg1.getDataType().isEmbeddable()) + ctx.visit(row(embeddedFields(arg1)).isNull()); else - ctx.visit(field).sql(' ').visit(isNull ? K_IS_NULL : K_IS_NOT_NULL); + ctx.visit(arg1).sql(' ').visit(K_IS_NULL); } @Override public final Clause[] clauses(Context ctx) { - return isNull ? CLAUSES_NULL : CLAUSES_NULL_NOT; + return CLAUSES; + } + + + + + + + + + + + + + // ------------------------------------------------------------------------- + // The Object API + // ------------------------------------------------------------------------- + + @Override + public boolean equals(Object that) { + if (that instanceof IsNull) { + return + StringUtils.equals(arg1, ((IsNull) that).arg1) + ; + } + else + return super.equals(that); } }