[jOOQ/jOOQ#12465] [jOOQ/jOOQ#12432] Extract more CompareConditions

Including:
- LIKE_IGNORE_CASE
- NOT_LIKE_IGNORE_CASE
- NOT_SIMILAR_TO
- SIMILAR_TO
This commit is contained in:
Lukas Eder 2021-09-24 15:57:47 +02:00
parent e6f3232710
commit 2e061133ea
9 changed files with 791 additions and 241 deletions

View File

@ -959,6 +959,36 @@ extends
@Support
LikeEscapeStep like(Field<String> pattern);
/**
* The <code>LIKE_IGNORE_CASE</code> operator.
* <p>
* Create a condition to case-insensitively pattern-check this field against
* a value.
* <p>
* This translates to <code>this not ilike value</code> in
* {@link SQLDialect#POSTGRES}, or to
* <code>lower(this) not like lower(value)</code> in all other dialects.
*
* @param pattern is wrapped as {@link #val(Object)}.
*/
@NotNull
@Support
LikeEscapeStep likeIgnoreCase(@Stringly.Param String pattern);
/**
* The <code>LIKE_IGNORE_CASE</code> operator.
* <p>
* Create a condition to case-insensitively pattern-check this field against
* a value.
* <p>
* This translates to <code>this not ilike value</code> in
* {@link SQLDialect#POSTGRES}, or to
* <code>lower(this) not like lower(value)</code> in all other dialects.
*/
@NotNull
@Support
LikeEscapeStep likeIgnoreCase(Field<String> pattern);
/**
* The <code>LT</code> operator.
*/
@ -1038,6 +1068,68 @@ extends
@Support
LikeEscapeStep notLike(Field<String> pattern);
/**
* The <code>NOT_LIKE_IGNORE_CASE</code> operator.
* <p>
* Create a condition to case-insensitively pattern-check this field against
* a value.
* <p>
* This translates to <code>this not ilike value</code> in
* {@link SQLDialect#POSTGRES}, or to
* <code>lower(this) not like lower(value)</code> in all other dialects.
*
* @param pattern is wrapped as {@link #val(Object)}.
*/
@NotNull
@Support
LikeEscapeStep notLikeIgnoreCase(@Stringly.Param String pattern);
/**
* The <code>NOT_LIKE_IGNORE_CASE</code> operator.
* <p>
* Create a condition to case-insensitively pattern-check this field against
* a value.
* <p>
* This translates to <code>this not ilike value</code> in
* {@link SQLDialect#POSTGRES}, or to
* <code>lower(this) not like lower(value)</code> in all other dialects.
*/
@NotNull
@Support
LikeEscapeStep notLikeIgnoreCase(Field<String> pattern);
/**
* The <code>NOT_SIMILAR_TO</code> operator.
*
* @param pattern is wrapped as {@link #val(Object)}.
*/
@NotNull
@Support
LikeEscapeStep notSimilarTo(@Stringly.Param String pattern);
/**
* The <code>NOT_SIMILAR_TO</code> operator.
*/
@NotNull
@Support
LikeEscapeStep notSimilarTo(Field<String> pattern);
/**
* The <code>SIMILAR_TO</code> operator.
*
* @param pattern is wrapped as {@link #val(Object)}.
*/
@NotNull
@Support
LikeEscapeStep similarTo(@Stringly.Param String pattern);
/**
* The <code>SIMILAR_TO</code> operator.
*/
@NotNull
@Support
LikeEscapeStep similarTo(Field<String> pattern);
// -------------------------------------------------------------------------
// XML predicates
// -------------------------------------------------------------------------
@ -1336,7 +1428,7 @@ extends
* also to express the "ARRAY contains" operator. For example: <code><pre>
* // Use this expression
* val(new Integer[] { 1, 2, 3 }).contains(new Integer[] { 1, 2 })
*
*
* // ... to render this SQL
* ARRAY[1, 2, 3] @&gt; ARRAY[1, 2]
* </pre></code>
@ -1365,7 +1457,7 @@ extends
* also to express the "ARRAY contains" operator. For example: <code><pre>
* // Use this expression
* val(new Integer[] { 1, 2, 3 }).contains(new Integer[] { 1, 2 })
*
*
* // ... to render this SQL
* ARRAY[1, 2, 3] @&gt; ARRAY[1, 2]
* </pre></code>
@ -2027,15 +2119,6 @@ extends
// SIMILAR TO predicates
// ------------------------------------------------------------------------
/**
* Create a condition to pattern-check this field against a value.
* <p>
* SQL: <code>this similar to value</code>
*/
@NotNull
@Support({ FIREBIRD, POSTGRES, YUGABYTE })
LikeEscapeStep similarTo(Field<String> value);
/**
* Create a condition to pattern-check this field against a value.
* <p>
@ -2047,15 +2130,6 @@ extends
@Support({ FIREBIRD, POSTGRES, YUGABYTE })
Condition similarTo(Field<String> value, char escape);
/**
* Create a condition to pattern-check this field against a value.
* <p>
* SQL: <code>this similar to value</code>
*/
@NotNull
@Support({ FIREBIRD, POSTGRES, YUGABYTE })
LikeEscapeStep similarTo(String value);
/**
* Create a condition to pattern-check this field against a value.
* <p>
@ -2067,15 +2141,6 @@ extends
@Support({ FIREBIRD, POSTGRES, YUGABYTE })
Condition similarTo(String value, char escape);
/**
* Create a condition to pattern-check this field against a field.
* <p>
* SQL: <code>this not similar to field</code>
*/
@NotNull
@Support({ FIREBIRD, POSTGRES, YUGABYTE })
LikeEscapeStep notSimilarTo(Field<String> field);
/**
* Create a condition to pattern-check this field against a field.
* <p>
@ -2087,15 +2152,6 @@ extends
@Support({ FIREBIRD, POSTGRES, YUGABYTE })
Condition notSimilarTo(Field<String> field, char escape);
/**
* Create a condition to pattern-check this field against a value.
* <p>
* SQL: <code>this not similar to value</code>
*/
@NotNull
@Support({ FIREBIRD, POSTGRES, YUGABYTE })
LikeEscapeStep notSimilarTo(String value);
/**
* Create a condition to pattern-check this field against a value.
* <p>
@ -2153,18 +2209,6 @@ extends
@Support
LikeEscapeStep like(QuantifiedSelect<Record1<String>> query);
/**
* Create a condition to case-insensitively pattern-check this field against
* a field.
* <p>
* This translates to <code>this ilike field</code> in
* {@link SQLDialect#POSTGRES}, or to
* <code>lower(this) like lower(field)</code> in all other dialects.
*/
@NotNull
@Support
LikeEscapeStep likeIgnoreCase(Field<String> field);
/**
* Create a condition to case-insensitively pattern-check this field against
* a field.
@ -2179,18 +2223,6 @@ extends
@Support
Condition likeIgnoreCase(Field<String> field, char escape);
/**
* Create a condition to case-insensitively pattern-check this field against
* a value.
* <p>
* This translates to <code>this ilike value</code> in
* {@link SQLDialect#POSTGRES}, or to
* <code>lower(this) like lower(value)</code> in all other dialects.
*/
@NotNull
@Support
LikeEscapeStep likeIgnoreCase(String value);
/**
* Create a condition to case-insensitively pattern-check this field against
* a value.
@ -2247,18 +2279,6 @@ extends
@Support
LikeEscapeStep notLike(QuantifiedSelect<Record1<String>> query);
/**
* Create a condition to case-insensitively pattern-check this field against
* a field.
* <p>
* This translates to <code>this not ilike field</code> in
* {@link SQLDialect#POSTGRES}, or to
* <code>lower(this) not like lower(field)</code> in all other dialects.
*/
@NotNull
@Support
LikeEscapeStep notLikeIgnoreCase(Field<String> field);
/**
* Create a condition to case-insensitively pattern-check this field against
* a field.
@ -2273,18 +2293,6 @@ extends
@Support
Condition notLikeIgnoreCase(Field<String> field, char escape);
/**
* Create a condition to case-insensitively pattern-check this field against
* a value.
* <p>
* This translates to <code>this not ilike value</code> in
* {@link SQLDialect#POSTGRES}, or to
* <code>lower(this) not like lower(value)</code> in all other dialects.
*/
@NotNull
@Support
LikeEscapeStep notLikeIgnoreCase(String value);
/**
* Create a condition to case-insensitively pattern-check this field against
* a value.

View File

@ -44,7 +44,7 @@ import java.util.*;
import org.jetbrains.annotations.*;
/**
* A step in the construction of the <code>NOT LIKE</code> function.
* A step in the construction of the <code>LIKE</code> function.
* <p>
* <h3>Referencing <code>XYZ*Step</code> types directly from client code</h3>
* <p>
@ -68,7 +68,7 @@ import org.jetbrains.annotations.*;
public interface LikeEscapeStep extends Condition {
/**
* Add the <code>ESCAPE</code> clause to the <code>NOT LIKE</code> function.
* Add the <code>ESCAPE</code> clause to the <code>LIKE</code> function.
* <p>
* For example:
*

View File

@ -544,6 +544,18 @@ abstract class AbstractField<T> extends AbstractTypedNamed<T> implements Field<T
return new Like(this, nullSafe(pattern, getDataType()));
}
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public final LikeEscapeStep likeIgnoreCase(String pattern) {
return new LikeIgnoreCase(this, Tools.field(pattern));
}
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public final LikeEscapeStep likeIgnoreCase(Field<String> pattern) {
return new LikeIgnoreCase(this, nullSafe(pattern, getDataType()));
}
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public final Condition lt(T arg2) {
@ -607,6 +619,42 @@ abstract class AbstractField<T> extends AbstractTypedNamed<T> implements Field<T
return new NotLike(this, nullSafe(pattern, getDataType()));
}
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public final LikeEscapeStep notLikeIgnoreCase(String pattern) {
return new NotLikeIgnoreCase(this, Tools.field(pattern));
}
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public final LikeEscapeStep notLikeIgnoreCase(Field<String> pattern) {
return new NotLikeIgnoreCase(this, nullSafe(pattern, getDataType()));
}
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public final LikeEscapeStep notSimilarTo(String pattern) {
return new NotSimilarTo(this, Tools.field(pattern));
}
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public final LikeEscapeStep notSimilarTo(Field<String> pattern) {
return new NotSimilarTo(this, nullSafe(pattern, getDataType()));
}
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public final LikeEscapeStep similarTo(String pattern) {
return new SimilarTo(this, Tools.field(pattern));
}
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public final LikeEscapeStep similarTo(Field<String> pattern) {
return new SimilarTo(this, nullSafe(pattern, getDataType()));
}
// -------------------------------------------------------------------------
// XML predicates
// -------------------------------------------------------------------------
@ -1051,41 +1099,21 @@ abstract class AbstractField<T> extends AbstractTypedNamed<T> implements Field<T
return castIfNeeded(this, String.class).in(BooleanValues.FALSE_VALUES);
}
@Override
public final LikeEscapeStep similarTo(String value) {
return similarTo(Tools.field(value));
}
@Override
public final Condition similarTo(String value, char escape) {
return similarTo(Tools.field(value), escape);
}
@Override
public final LikeEscapeStep similarTo(Field<String> field) {
return new CompareCondition(this, nullSafe(field, getDataType()), SIMILAR_TO);
}
@Override
public final Condition similarTo(Field<String> field, char escape) {
return similarTo(field).escape(escape);
}
@Override
public final LikeEscapeStep notSimilarTo(String value) {
return notSimilarTo(Tools.field(value));
}
@Override
public final Condition notSimilarTo(String value, char escape) {
return notSimilarTo(Tools.field(value), escape);
}
@Override
public final LikeEscapeStep notSimilarTo(Field<String> field) {
return new CompareCondition(this, nullSafe(field, getDataType()), NOT_SIMILAR_TO);
}
@Override
public final Condition notSimilarTo(Field<String> field, char escape) {
return notSimilarTo(field).escape(escape);
@ -1106,21 +1134,11 @@ abstract class AbstractField<T> extends AbstractTypedNamed<T> implements Field<T
return new QuantifiedComparisonCondition(query, this, LIKE);
}
@Override
public final LikeEscapeStep likeIgnoreCase(String value) {
return likeIgnoreCase(Tools.field(value));
}
@Override
public final Condition likeIgnoreCase(String value, char escape) {
return likeIgnoreCase(Tools.field(value), escape);
}
@Override
public final LikeEscapeStep likeIgnoreCase(Field<String> field) {
return new CompareCondition(this, nullSafe(field, getDataType()), LIKE_IGNORE_CASE);
}
@Override
public final Condition likeIgnoreCase(Field<String> field, char escape) {
return likeIgnoreCase(field).escape(escape);
@ -1151,21 +1169,11 @@ abstract class AbstractField<T> extends AbstractTypedNamed<T> implements Field<T
return new QuantifiedComparisonCondition(query, this, NOT_LIKE);
}
@Override
public final LikeEscapeStep notLikeIgnoreCase(String value) {
return notLikeIgnoreCase(Tools.field(value));
}
@Override
public final Condition notLikeIgnoreCase(String value, char escape) {
return notLikeIgnoreCase(Tools.field(value), escape);
}
@Override
public final LikeEscapeStep notLikeIgnoreCase(Field<String> field) {
return new CompareCondition(this, nullSafe(field, getDataType()), NOT_LIKE_IGNORE_CASE);
}
@Override
public final Condition notLikeIgnoreCase(Field<String> field, char escape) {
return notLikeIgnoreCase(field).escape(escape);
@ -1444,6 +1452,7 @@ abstract class AbstractField<T> extends AbstractTypedNamed<T> implements Field<T
return compare(comparator, Tools.field(value, this));
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public final Condition compare(Comparator comparator, Field<T> field) {
switch (comparator) {
@ -1462,8 +1471,16 @@ abstract class AbstractField<T> extends AbstractTypedNamed<T> implements Field<T
case LIKE:
return new Like(this, (Field) nullSafe(field, getDataType()));
case LIKE_IGNORE_CASE:
return new LikeIgnoreCase(this, (Field) nullSafe(field, getDataType()));
case SIMILAR_TO:
return new SimilarTo(this, (Field) nullSafe(field, getDataType()));
case NOT_LIKE:
return new NotLike(this, (Field) nullSafe(field, getDataType()));
case NOT_LIKE_IGNORE_CASE:
return new NotLikeIgnoreCase(this, (Field) nullSafe(field, getDataType()));
case NOT_SIMILAR_TO:
return new NotSimilarTo(this, (Field) nullSafe(field, getDataType()));
case IS_DISTINCT_FROM:
return new IsDistinctFrom<>(this, nullSafe(field, getDataType()));

View File

@ -42,85 +42,35 @@ import static java.lang.Boolean.TRUE;
import static org.jooq.Clause.CONDITION;
import static org.jooq.Clause.CONDITION_COMPARISON;
import static org.jooq.Comparator.IN;
import static org.jooq.Comparator.LIKE;
import static org.jooq.Comparator.LIKE_IGNORE_CASE;
import static org.jooq.Comparator.NOT_IN;
import static org.jooq.Comparator.NOT_LIKE;
import static org.jooq.Comparator.NOT_LIKE_IGNORE_CASE;
import static org.jooq.Comparator.NOT_SIMILAR_TO;
import static org.jooq.Comparator.SIMILAR_TO;
// ...
// ...
// ...
// ...
// ...
// ...
import static org.jooq.SQLDialect.CUBRID;
// ...
import static org.jooq.SQLDialect.DERBY;
import static org.jooq.SQLDialect.FIREBIRD;
// ...
import static org.jooq.SQLDialect.HSQLDB;
// ...
// ...
// ...
import static org.jooq.SQLDialect.MARIADB;
// ...
import static org.jooq.SQLDialect.MYSQL;
// ...
import static org.jooq.SQLDialect.POSTGRES;
// ...
// ...
import static org.jooq.SQLDialect.SQLITE;
// ...
// ...
// ...
// ...
import static org.jooq.SQLDialect.YUGABYTE;
import static org.jooq.conf.ParamType.INLINED;
import static org.jooq.impl.DSL.asterisk;
import static org.jooq.impl.DSL.inline;
import static org.jooq.impl.DSL.row;
import static org.jooq.impl.DSL.select;
import static org.jooq.impl.Keywords.K_AS;
import static org.jooq.impl.Keywords.K_CAST;
import static org.jooq.impl.Keywords.K_ESCAPE;
import static org.jooq.impl.Keywords.K_VARCHAR;
import static org.jooq.impl.Tools.castIfNeeded;
import static org.jooq.impl.Tools.characterLiteral;
import static org.jooq.impl.Tools.embeddedFields;
import static org.jooq.impl.Tools.nullSafe;
import static org.jooq.impl.Tools.nullableIf;
import static org.jooq.impl.Tools.BooleanDataKey.DATA_MULTISET_CONDITION;
import static org.jooq.impl.Transformations.transformInConditionSubqueryWithLimitToDerivedTable;
import static org.jooq.impl.Transformations.subqueryWithLimit;
import java.util.Set;
import static org.jooq.impl.Transformations.transformInConditionSubqueryWithLimitToDerivedTable;
import org.jooq.Clause;
import org.jooq.Comparator;
import org.jooq.Condition;
import org.jooq.Context;
import org.jooq.Field;
import org.jooq.LikeEscapeStep;
// ...
import org.jooq.SQLDialect;
import org.jooq.Select;
import org.jooq.conf.ParamType;
/**
* @author Lukas Eder
*/
final class CompareCondition extends AbstractCondition implements LikeEscapeStep {
final class CompareCondition extends AbstractCondition {
private static final Clause[] CLAUSES = { CONDITION, CONDITION_COMPARISON };
private static final Set<SQLDialect> REQUIRES_CAST_ON_LIKE = SQLDialect.supportedBy(DERBY, POSTGRES, YUGABYTE);
private static final Set<SQLDialect> NO_SUPPORT_ILIKE = SQLDialect.supportedBy(CUBRID, DERBY, FIREBIRD, HSQLDB, MARIADB, MYSQL, SQLITE);
final Field<?> field1;
final Field<?> field2;
final Comparator comparator;
private Character escape;
CompareCondition(Field<?> field1, Field<?> field2, Comparator comparator) {
this.field1 = nullableIf(comparator.supportsNulls(), nullSafe(field1, field2.getDataType()));
@ -128,12 +78,6 @@ final class CompareCondition extends AbstractCondition implements LikeEscapeStep
this.comparator = comparator;
}
@Override
public final Condition escape(char c) {
this.escape = c;
return this;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public final void accept(Context<?> ctx) {
@ -167,57 +111,7 @@ final class CompareCondition extends AbstractCondition implements LikeEscapeStep
SQLDialect family = ctx.family();
Field<?> lhs = field1;
Field<?> rhs = field2;
Comparator op = comparator;
// [#1159] [#1725] Some dialects cannot auto-convert the LHS operand to a
// VARCHAR when applying a LIKE predicate
if ((op == LIKE || op == NOT_LIKE || op == SIMILAR_TO || op == NOT_SIMILAR_TO)
&& field1.getType() != String.class
&& REQUIRES_CAST_ON_LIKE.contains(ctx.dialect())) {
lhs = castIfNeeded(lhs, String.class);
}
// [#1423] [#9889] PostgreSQL and H2 support ILIKE natively. Other dialects
// need to emulate this as LOWER(lhs) LIKE LOWER(rhs)
else if ((op == LIKE_IGNORE_CASE || op == NOT_LIKE_IGNORE_CASE) && NO_SUPPORT_ILIKE.contains(ctx.dialect())) {
lhs = lhs.lower();
rhs = rhs.lower();
op = (op == LIKE_IGNORE_CASE ? LIKE : NOT_LIKE);
}
ctx.visit(lhs)
.sql(' ');
boolean castRhs = false;
ParamType previousParamType = ctx.paramType();
ParamType forcedParamType = previousParamType;
ctx.visit(op.toKeyword()).sql(' ');
if (castRhs) ctx.visit(K_CAST).sql('(');
ctx.visit(rhs, forcedParamType);
if (castRhs) ctx.sql(' ').visit(K_AS).sql(' ').visit(K_VARCHAR).sql("(4000))");
if (escape != null) {
ctx.sql(' ').visit(K_ESCAPE).sql(' ')
.visit(inline(escape));
}
ctx.visit(field1).sql(' ').visit(comparator.toKeyword()).sql(' ').visit(field2);
}
@ -248,9 +142,6 @@ final class CompareCondition extends AbstractCondition implements LikeEscapeStep

View File

@ -46,6 +46,12 @@ 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.Comparator.LIKE;
import static org.jooq.Comparator.LIKE_IGNORE_CASE;
import static org.jooq.Comparator.NOT_LIKE;
import static org.jooq.Comparator.NOT_LIKE_IGNORE_CASE;
import static org.jooq.Comparator.NOT_SIMILAR_TO;
import static org.jooq.Comparator.SIMILAR_TO;
import static org.jooq.SQLDialect.*;
import org.jooq.*;
@ -113,6 +119,7 @@ implements
private static final Set<SQLDialect> REQUIRES_CAST_ON_LIKE = SQLDialect.supportedBy(DERBY, POSTGRES, YUGABYTE);
private static final Set<SQLDialect> NO_SUPPORT_ILIKE = SQLDialect.supportedBy(CUBRID, DERBY, FIREBIRD, HSQLDB, MARIADB, MYSQL, SQLITE);
@Override
public final void accept(Context<?> ctx) {
@ -158,8 +165,19 @@ implements
// [#1159] [#1725] Some dialects cannot auto-convert the LHS operand to a
// VARCHAR when applying a LIKE predicate
if (arg1.getType() != String.class && REQUIRES_CAST_ON_LIKE.contains(ctx.dialect()))
if ((op == LIKE || op == NOT_LIKE || op == SIMILAR_TO || op == NOT_SIMILAR_TO)
&& arg1.getType() != String.class
&& REQUIRES_CAST_ON_LIKE.contains(ctx.dialect())) {
arg1 = castIfNeeded(arg1, String.class);
}
// [#1423] [#9889] PostgreSQL and H2 support ILIKE natively. Other dialects
// need to emulate this as LOWER(lhs) LIKE LOWER(rhs)
else if ((op == LIKE_IGNORE_CASE || op == NOT_LIKE_IGNORE_CASE) && NO_SUPPORT_ILIKE.contains(ctx.dialect())) {
arg1 = DSL.lower((Field) arg1);
arg2 = DSL.lower((Field) arg2);
op = (op == LIKE_IGNORE_CASE ? LIKE : NOT_LIKE);
}
boolean castRhs = castRhs(ctx, arg2);

View File

@ -0,0 +1,154 @@
/*
* 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
*
* http://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: http://www.jooq.org/licenses
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package org.jooq.impl;
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 java.util.function.*;
import java.util.stream.*;
/**
* The <code>LIKE IGNORE CASE</code> statement.
*/
@SuppressWarnings({ "hiding", "rawtypes", "unchecked", "unused" })
final class LikeIgnoreCase
extends
AbstractCondition
implements
LikeEscapeStep
{
final Field<?> value;
final Field<String> pattern;
Character escape;
LikeIgnoreCase(
Field<?> value,
Field<String> pattern
) {
this(
value,
pattern,
null
);
}
LikeIgnoreCase(
Field<?> value,
Field<String> pattern,
Character escape
) {
this.value = nullSafeNotNull(value, OTHER);
this.pattern = nullSafeNotNull(pattern, VARCHAR);
this.escape = escape;
}
// -------------------------------------------------------------------------
// XXX: DSL API
// -------------------------------------------------------------------------
@Override
public final LikeIgnoreCase escape(char escape) {
this.escape = escape;
return this;
}
// -------------------------------------------------------------------------
// XXX: QueryPart API
// -------------------------------------------------------------------------
@Override
public final void accept(Context<?> ctx) {
Like.accept0(ctx, value, org.jooq.Comparator.LIKE_IGNORE_CASE, pattern, escape);
}
// -------------------------------------------------------------------------
// The Object API
// -------------------------------------------------------------------------
@Override
public boolean equals(Object that) {
if (that instanceof LikeIgnoreCase) {
return
StringUtils.equals(value, ((LikeIgnoreCase) that).value) &&
StringUtils.equals(pattern, ((LikeIgnoreCase) that).pattern) &&
StringUtils.equals(escape, ((LikeIgnoreCase) that).escape)
;
}
else
return super.equals(that);
}
}

View File

@ -0,0 +1,154 @@
/*
* 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
*
* http://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: http://www.jooq.org/licenses
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package org.jooq.impl;
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 java.util.function.*;
import java.util.stream.*;
/**
* The <code>NOT LIKE IGNORE CASE</code> statement.
*/
@SuppressWarnings({ "hiding", "rawtypes", "unchecked", "unused" })
final class NotLikeIgnoreCase
extends
AbstractCondition
implements
LikeEscapeStep
{
final Field<?> value;
final Field<String> pattern;
Character escape;
NotLikeIgnoreCase(
Field<?> value,
Field<String> pattern
) {
this(
value,
pattern,
null
);
}
NotLikeIgnoreCase(
Field<?> value,
Field<String> pattern,
Character escape
) {
this.value = nullSafeNotNull(value, OTHER);
this.pattern = nullSafeNotNull(pattern, VARCHAR);
this.escape = escape;
}
// -------------------------------------------------------------------------
// XXX: DSL API
// -------------------------------------------------------------------------
@Override
public final NotLikeIgnoreCase escape(char escape) {
this.escape = escape;
return this;
}
// -------------------------------------------------------------------------
// XXX: QueryPart API
// -------------------------------------------------------------------------
@Override
public final void accept(Context<?> ctx) {
Like.accept0(ctx, value, org.jooq.Comparator.NOT_LIKE_IGNORE_CASE, pattern, escape);
}
// -------------------------------------------------------------------------
// The Object API
// -------------------------------------------------------------------------
@Override
public boolean equals(Object that) {
if (that instanceof NotLikeIgnoreCase) {
return
StringUtils.equals(value, ((NotLikeIgnoreCase) that).value) &&
StringUtils.equals(pattern, ((NotLikeIgnoreCase) that).pattern) &&
StringUtils.equals(escape, ((NotLikeIgnoreCase) that).escape)
;
}
else
return super.equals(that);
}
}

View File

@ -0,0 +1,154 @@
/*
* 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
*
* http://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: http://www.jooq.org/licenses
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package org.jooq.impl;
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 java.util.function.*;
import java.util.stream.*;
/**
* The <code>NOT SIMILAR TO</code> statement.
*/
@SuppressWarnings({ "hiding", "rawtypes", "unchecked", "unused" })
final class NotSimilarTo
extends
AbstractCondition
implements
LikeEscapeStep
{
final Field<?> value;
final Field<String> pattern;
Character escape;
NotSimilarTo(
Field<?> value,
Field<String> pattern
) {
this(
value,
pattern,
null
);
}
NotSimilarTo(
Field<?> value,
Field<String> pattern,
Character escape
) {
this.value = nullSafeNotNull(value, OTHER);
this.pattern = nullSafeNotNull(pattern, VARCHAR);
this.escape = escape;
}
// -------------------------------------------------------------------------
// XXX: DSL API
// -------------------------------------------------------------------------
@Override
public final NotSimilarTo escape(char escape) {
this.escape = escape;
return this;
}
// -------------------------------------------------------------------------
// XXX: QueryPart API
// -------------------------------------------------------------------------
@Override
public final void accept(Context<?> ctx) {
Like.accept0(ctx, value, org.jooq.Comparator.NOT_SIMILAR_TO, pattern, escape);
}
// -------------------------------------------------------------------------
// The Object API
// -------------------------------------------------------------------------
@Override
public boolean equals(Object that) {
if (that instanceof NotSimilarTo) {
return
StringUtils.equals(value, ((NotSimilarTo) that).value) &&
StringUtils.equals(pattern, ((NotSimilarTo) that).pattern) &&
StringUtils.equals(escape, ((NotSimilarTo) that).escape)
;
}
else
return super.equals(that);
}
}

View File

@ -0,0 +1,154 @@
/*
* 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
*
* http://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: http://www.jooq.org/licenses
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package org.jooq.impl;
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 java.util.function.*;
import java.util.stream.*;
/**
* The <code>SIMILAR TO</code> statement.
*/
@SuppressWarnings({ "hiding", "rawtypes", "unchecked", "unused" })
final class SimilarTo
extends
AbstractCondition
implements
LikeEscapeStep
{
final Field<?> value;
final Field<String> pattern;
Character escape;
SimilarTo(
Field<?> value,
Field<String> pattern
) {
this(
value,
pattern,
null
);
}
SimilarTo(
Field<?> value,
Field<String> pattern,
Character escape
) {
this.value = nullSafeNotNull(value, OTHER);
this.pattern = nullSafeNotNull(pattern, VARCHAR);
this.escape = escape;
}
// -------------------------------------------------------------------------
// XXX: DSL API
// -------------------------------------------------------------------------
@Override
public final SimilarTo escape(char escape) {
this.escape = escape;
return this;
}
// -------------------------------------------------------------------------
// XXX: QueryPart API
// -------------------------------------------------------------------------
@Override
public final void accept(Context<?> ctx) {
Like.accept0(ctx, value, org.jooq.Comparator.SIMILAR_TO, pattern, escape);
}
// -------------------------------------------------------------------------
// The Object API
// -------------------------------------------------------------------------
@Override
public boolean equals(Object that) {
if (that instanceof SimilarTo) {
return
StringUtils.equals(value, ((SimilarTo) that).value) &&
StringUtils.equals(pattern, ((SimilarTo) that).pattern) &&
StringUtils.equals(escape, ((SimilarTo) that).escape)
;
}
else
return super.equals(that);
}
}