org.jooq.impl.ConstraintImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of payment-retries-plugin Show documentation
Show all versions of payment-retries-plugin Show documentation
Kill Bill Payment Retries plugin
The newest version!
/*
* Copyright (c) 2009-2016, Data Geekery GmbH (http://www.datageekery.com)
* All rights reserved.
*
* 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.Clause.CONSTRAINT;
import static org.jooq.impl.ConstraintImpl.Action.CASCADE;
import static org.jooq.impl.ConstraintImpl.Action.NO_ACTION;
import static org.jooq.impl.ConstraintImpl.Action.RESTRICT;
import static org.jooq.impl.ConstraintImpl.Action.SET_DEFAULT;
import static org.jooq.impl.ConstraintImpl.Action.SET_NULL;
import static org.jooq.impl.DSL.name;
import static org.jooq.impl.DSL.table;
import static org.jooq.impl.Tools.fieldsByName;
import static org.jooq.impl.Tools.DataKey.DATA_CONSTRAINT_REFERENCE;
import javax.annotation.Generated;
import org.jooq.Clause;
import org.jooq.Condition;
import org.jooq.ConstraintForeignKeyOnStep;
import org.jooq.ConstraintForeignKeyReferencesStep1;
import org.jooq.ConstraintForeignKeyReferencesStep10;
import org.jooq.ConstraintForeignKeyReferencesStep11;
import org.jooq.ConstraintForeignKeyReferencesStep12;
import org.jooq.ConstraintForeignKeyReferencesStep13;
import org.jooq.ConstraintForeignKeyReferencesStep14;
import org.jooq.ConstraintForeignKeyReferencesStep15;
import org.jooq.ConstraintForeignKeyReferencesStep16;
import org.jooq.ConstraintForeignKeyReferencesStep17;
import org.jooq.ConstraintForeignKeyReferencesStep18;
import org.jooq.ConstraintForeignKeyReferencesStep19;
import org.jooq.ConstraintForeignKeyReferencesStep2;
import org.jooq.ConstraintForeignKeyReferencesStep20;
import org.jooq.ConstraintForeignKeyReferencesStep21;
import org.jooq.ConstraintForeignKeyReferencesStep22;
import org.jooq.ConstraintForeignKeyReferencesStep3;
import org.jooq.ConstraintForeignKeyReferencesStep4;
import org.jooq.ConstraintForeignKeyReferencesStep5;
import org.jooq.ConstraintForeignKeyReferencesStep6;
import org.jooq.ConstraintForeignKeyReferencesStep7;
import org.jooq.ConstraintForeignKeyReferencesStep8;
import org.jooq.ConstraintForeignKeyReferencesStep9;
import org.jooq.ConstraintForeignKeyReferencesStepN;
import org.jooq.ConstraintTypeStep;
import org.jooq.Context;
import org.jooq.Field;
import org.jooq.Name;
import org.jooq.Table;
import org.jooq.exception.DataAccessException;
/**
* @author Lukas Eder
*/
@SuppressWarnings("rawtypes")
final class ConstraintImpl extends AbstractQueryPart
implements
ConstraintTypeStep
, ConstraintForeignKeyOnStep
, ConstraintForeignKeyReferencesStepN
// [jooq-tools] START [implements]
, ConstraintForeignKeyReferencesStep1
, ConstraintForeignKeyReferencesStep2
, ConstraintForeignKeyReferencesStep3
, ConstraintForeignKeyReferencesStep4
, ConstraintForeignKeyReferencesStep5
, ConstraintForeignKeyReferencesStep6
, ConstraintForeignKeyReferencesStep7
, ConstraintForeignKeyReferencesStep8
, ConstraintForeignKeyReferencesStep9
, ConstraintForeignKeyReferencesStep10
, ConstraintForeignKeyReferencesStep11
, ConstraintForeignKeyReferencesStep12
, ConstraintForeignKeyReferencesStep13
, ConstraintForeignKeyReferencesStep14
, ConstraintForeignKeyReferencesStep15
, ConstraintForeignKeyReferencesStep16
, ConstraintForeignKeyReferencesStep17
, ConstraintForeignKeyReferencesStep18
, ConstraintForeignKeyReferencesStep19
, ConstraintForeignKeyReferencesStep20
, ConstraintForeignKeyReferencesStep21
, ConstraintForeignKeyReferencesStep22
// [jooq-tools] END [implements]
{
/**
* Generated UID
*/
private static final long serialVersionUID = 1018023703769802616L;
private static final Clause[] CLAUSES = { CONSTRAINT };
private final Name name;
private Field>[] unique;
private Field>[] primaryKey;
private Field>[] foreignKey;
private Table> referencesTable;
private Field>[] references;
private Action onDelete;
private Action onUpdate;
private Condition check;
ConstraintImpl() {
this(null);
}
ConstraintImpl(Name name) {
this.name = name;
}
@Override
public final Clause[] clauses(Context> ctx) {
return CLAUSES;
}
@Override
public final void accept(Context> ctx) {
if (ctx.data(DATA_CONSTRAINT_REFERENCE) != null) {
if (name == null)
throw new DataAccessException("Cannot ALTER or DROP CONSTRAINT without name");
ctx.visit(name);
}
else {
boolean qualify = ctx.qualify();
if (name != null)
ctx.keyword("constraint")
.sql(' ')
.visit(name)
.formatIndentStart()
.formatSeparator();
if (unique != null) {
ctx.keyword("unique")
.sql(" (")
.qualify(false)
.visit(new QueryPartList>(unique))
.qualify(qualify)
.sql(')');
}
else if (primaryKey != null) {
ctx.keyword("primary key")
.sql(" (")
.qualify(false)
.visit(new QueryPartList>(primaryKey))
.qualify(qualify)
.sql(')');
}
else if (foreignKey != null) {
ctx.keyword("foreign key")
.sql(" (")
.qualify(false)
.visit(new QueryPartList>(foreignKey))
.qualify(qualify)
.sql(')')
.formatSeparator()
.keyword("references")
.sql(' ')
.visit(referencesTable)
.sql(" (")
.qualify(false)
.visit(new QueryPartList>(references))
.qualify(qualify)
.sql(')');
if (onDelete != null)
ctx.sql(' ').keyword("on delete")
.sql(' ').keyword(onDelete.sql);
if (onUpdate != null)
ctx.sql(' ').keyword("on update")
.sql(' ').keyword(onUpdate.sql);
}
else if (check != null) {
ctx.keyword("check")
.sql(" (")
.qualify(false)
.visit(check)
.qualify(qualify)
.sql(')');
}
ctx.formatIndentEnd();
}
}
@Override
public final ConstraintImpl unique(String... fields) {
return unique(fieldsByName(fields));
}
@Override
public final ConstraintImpl unique(Field>... fields) {
unique = fields;
return this;
}
@Override
public final ConstraintImpl check(Condition condition) {
check = condition;
return this;
}
@Override
public final ConstraintImpl primaryKey(String... fields) {
return primaryKey(fieldsByName(fields));
}
@Override
public final ConstraintImpl primaryKey(Field>... fields) {
primaryKey = fields;
return this;
}
@Override
public final ConstraintImpl foreignKey(String... fields) {
return foreignKey(fieldsByName(fields));
}
@Override
public final ConstraintImpl foreignKey(Field>... fields) {
foreignKey = fields;
return this;
}
@Override
public final ConstraintImpl references(String table, String... fields) {
return references(table(name(table)), fieldsByName(fields));
}
@Override
public final ConstraintImpl references(Table> table, Field>... fields) {
referencesTable = table;
references = fields;
return this;
}
@Override
public final ConstraintImpl onDeleteNoAction() {
onDelete = NO_ACTION;
return this;
}
@Override
public final ConstraintImpl onDeleteRestrict() {
onDelete = RESTRICT;
return this;
}
@Override
public final ConstraintImpl onDeleteCascade() {
onDelete = CASCADE;
return this;
}
@Override
public final ConstraintImpl onDeleteSetNull() {
onDelete = SET_NULL;
return this;
}
@Override
public final ConstraintImpl onDeleteSetDefault() {
onDelete = SET_DEFAULT;
return this;
}
@Override
public final ConstraintImpl onUpdateNoAction() {
onUpdate = NO_ACTION;
return this;
}
@Override
public final ConstraintImpl onUpdateRestrict() {
onUpdate = RESTRICT;
return this;
}
@Override
public final ConstraintImpl onUpdateCascade() {
onUpdate = CASCADE;
return this;
}
@Override
public final ConstraintImpl onUpdateSetNull() {
onUpdate = SET_NULL;
return this;
}
@Override
public final ConstraintImpl onUpdateSetDefault() {
onUpdate = SET_DEFAULT;
return this;
}
// [jooq-tools] START [foreignKey]
@Generated("This method was generated using jOOQ-tools")
@Override
public final ConstraintImpl foreignKey(Field field1) {
return foreignKey(new Field[] { field1 });
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final ConstraintImpl foreignKey(Field field1, Field field2) {
return foreignKey(new Field[] { field1, field2 });
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final ConstraintImpl foreignKey(Field field1, Field field2, Field field3) {
return foreignKey(new Field[] { field1, field2, field3 });
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final ConstraintImpl foreignKey(Field field1, Field field2, Field field3, Field field4) {
return foreignKey(new Field[] { field1, field2, field3, field4 });
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final ConstraintImpl foreignKey(Field field1, Field field2, Field field3, Field field4, Field field5) {
return foreignKey(new Field[] { field1, field2, field3, field4, field5 });
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final ConstraintImpl foreignKey(Field field1, Field field2, Field field3, Field field4, Field field5, Field field6) {
return foreignKey(new Field[] { field1, field2, field3, field4, field5, field6 });
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final ConstraintImpl foreignKey(Field field1, Field field2, Field field3, Field field4, Field field5, Field field6, Field field7) {
return foreignKey(new Field[] { field1, field2, field3, field4, field5, field6, field7 });
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final ConstraintImpl foreignKey(Field field1, Field field2, Field field3, Field field4, Field field5, Field field6, Field field7, Field field8) {
return foreignKey(new Field[] { field1, field2, field3, field4, field5, field6, field7, field8 });
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final ConstraintImpl foreignKey(Field field1, Field field2, Field field3, Field field4, Field field5, Field field6, Field field7, Field field8, Field field9) {
return foreignKey(new Field[] { field1, field2, field3, field4, field5, field6, field7, field8, field9 });
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final ConstraintImpl foreignKey(Field field1, Field field2, Field field3, Field field4, Field field5, Field field6, Field field7, Field field8, Field field9, Field field10) {
return foreignKey(new Field[] { field1, field2, field3, field4, field5, field6, field7, field8, field9, field10 });
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final ConstraintImpl foreignKey(Field field1, Field field2, Field field3, Field field4, Field field5, Field field6, Field field7, Field field8, Field field9, Field field10, Field field11) {
return foreignKey(new Field[] { field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11 });
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final ConstraintImpl foreignKey(Field field1, Field field2, Field field3, Field field4, Field field5, Field field6, Field field7, Field field8, Field field9, Field field10, Field field11, Field field12) {
return foreignKey(new Field[] { field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12 });
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final ConstraintImpl foreignKey(Field field1, Field field2, Field field3, Field field4, Field field5, Field field6, Field field7, Field field8, Field field9, Field field10, Field field11, Field field12, Field field13) {
return foreignKey(new Field[] { field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13 });
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final ConstraintImpl foreignKey(Field field1, Field field2, Field field3, Field field4, Field field5, Field field6, Field field7, Field field8, Field field9, Field field10, Field field11, Field field12, Field field13, Field field14) {
return foreignKey(new Field[] { field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14 });
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final ConstraintImpl foreignKey(Field field1, Field field2, Field field3, Field field4, Field field5, Field field6, Field field7, Field field8, Field field9, Field field10, Field field11, Field field12, Field field13, Field field14, Field field15) {
return foreignKey(new Field[] { field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15 });
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final ConstraintImpl foreignKey(Field field1, Field field2, Field field3, Field field4, Field field5, Field field6, Field field7, Field field8, Field field9, Field field10, Field field11, Field field12, Field field13, Field field14, Field field15, Field field16) {
return foreignKey(new Field[] { field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16 });
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final ConstraintImpl foreignKey(Field field1, Field field2, Field field3, Field field4, Field field5, Field field6, Field field7, Field field8, Field field9, Field field10, Field field11, Field field12, Field field13, Field field14, Field field15, Field field16, Field field17) {
return foreignKey(new Field[] { field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, field17 });
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final ConstraintImpl foreignKey(Field field1, Field field2, Field field3, Field field4, Field field5, Field field6, Field field7, Field field8, Field field9, Field field10, Field field11, Field field12, Field field13, Field field14, Field field15, Field field16, Field field17, Field field18) {
return foreignKey(new Field[] { field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, field17, field18 });
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final ConstraintImpl foreignKey(Field field1, Field field2, Field field3, Field field4, Field field5, Field field6, Field field7, Field field8, Field field9, Field field10, Field field11, Field field12, Field field13, Field field14, Field field15, Field field16, Field field17, Field field18, Field field19) {
return foreignKey(new Field[] { field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, field17, field18, field19 });
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final ConstraintImpl foreignKey(Field field1, Field field2, Field field3, Field field4, Field field5, Field field6, Field field7, Field field8, Field field9, Field field10, Field field11, Field field12, Field field13, Field field14, Field field15, Field field16, Field field17, Field field18, Field field19, Field field20) {
return foreignKey(new Field[] { field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, field17, field18, field19, field20 });
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final ConstraintImpl foreignKey(Field field1, Field field2, Field field3, Field field4, Field field5, Field field6, Field field7, Field field8, Field field9, Field field10, Field field11, Field field12, Field field13, Field field14, Field field15, Field field16, Field