@Override public UniqueKey<R> getPrimaryKey() { return super.getPrimaryKey(); }
@Override public final boolean declaresFields() { return super.declaresFields(); }
@Override public final boolean declaresTables() { return super.declaresTables(); } }
@Override public boolean equals(Object that) { if (this == that) { return true; } // [#2144] TableImpl equality can be decided without executing the // rather expensive implementation of AbstractQueryPart.equals() if (that instanceof TableImpl) { TableImpl<?> other = (TableImpl<?>) that; return StringUtils.equals(getSchema(), other.getSchema()) && StringUtils.equals(getName(), other.getName()) && Arrays.equals(parameters, other.parameters); } return super.equals(that); } }
static final <R extends Record> Table<R> aliased(Table<R> table) { if (table instanceof TableImpl) return ((TableImpl<R>) table).getAliasedTable(); else if (table instanceof TableAlias) return ((TableAlias<R>) table).getAliasedTable(); else return null; }
@Override public Identity<R, ? extends Number> getIdentity() { return super.getIdentity(); }
@Override public List<UniqueKey<R>> getKeys() { return super.getKeys(); }
@Override public List<ForeignKey<R, ?>> getReferences() { return super.getReferences(); }
/** * Subclasses may call this method to create {@link TableField} objects that * are linked to this table. * * @param name The name of the field (case-sensitive!) * @param type The data type of the field */ protected static final <R extends Record, T> TableField<R, T> createField(String name, DataType<T> type, Table<R> table, String comment) { final TableFieldImpl<R, T> tableField = new TableFieldImpl<R, T>(name, type, table, comment); // [#1199] The public API of Table returns immutable field lists if (table instanceof TableImpl) { ((TableImpl<?>) table).fields0().add(tableField); } return tableField; }
private void accept0(Context<?> ctx) { if (ctx.declareTables()) ctx.scopeMarkStart(this); if (ctx.qualify() && (!NO_SUPPORT_QUALIFIED_TVF_CALLS.contains(ctx.family()) || parameters == null || ctx.declareTables())) { Schema mappedSchema = Tools.getMappedSchema(ctx.configuration(), getSchema()); if (mappedSchema != null && !"".equals(mappedSchema.getName())) { ctx.visit(mappedSchema); ctx.sql('.'); } } ctx.visit(Tools.getMappedTable(ctx.configuration(), this).getUnqualifiedName()); if (parameters != null && ctx.declareTables()) { // [#2925] Some dialects don't like empty parameter lists if (ctx.family() == FIREBIRD && parameters.length == 0) ctx.visit(new QueryPartList<Field<?>>(parameters)); else ctx.sql('(') .visit(new QueryPartList<Field<?>>(parameters)) .sql(')'); } if (ctx.declareTables()) ctx.scopeMarkEnd(this); }
@Override public boolean equals(Object that) { if (this == that) { return true; } // [#2144] TableImpl equality can be decided without executing the // rather expensive implementation of AbstractQueryPart.equals() if (that instanceof TableImpl) { TableImpl<?> other = (TableImpl<?>) that; return StringUtils.equals(getSchema(), other.getSchema()) && StringUtils.equals(getName(), other.getName()) && Arrays.equals(parameters, other.parameters); } return super.equals(that); } }
/** * {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public final <O extends Record> List<ForeignKey<R, O>> getReferencesTo(Table<O> other) { List<ForeignKey<R, O>> result = new ArrayList<ForeignKey<R, O>>(); for (ForeignKey<R, ?> reference : getReferences()) { if (other.equals(reference.getKey().getTable())) { result.add((ForeignKey<R, O>) reference); } // TODO: Refactor the following two blocks and make things more OO // [#1460] In case the other table was aliased using else if (other instanceof TableImpl) { Table<O> aliased = ((TableImpl<O>) other).getAliasedTable(); if (aliased != null && aliased.equals(reference.getKey().getTable())) { result.add((ForeignKey<R, O>) reference); } } // [#1460] In case the other table was aliased using else if (other instanceof TableAlias) { Table<O> aliased = ((TableAlias<O>) other).getAliasedTable(); if (aliased != null && aliased.equals(reference.getKey().getTable())) { result.add((ForeignKey<R, O>) reference); } } } return Collections.unmodifiableList(result); }
@Override public Identity<R, ?> getIdentity() { return super.getIdentity(); }
@Override public List<UniqueKey<R>> getKeys() { return super.getKeys(); }
@Override public List<ForeignKey<R, ?>> getReferences() { return super.getReferences(); }
/** * Subclasses may call this method to create {@link TableField} objects that * are linked to this table. * * @param name The name of the field (case-sensitive!) * @param type The data type of the field */ @SuppressWarnings("unchecked") protected static final <R extends Record, T, X, U> TableField<R, U> createField(String name, DataType<T> type, Table<R> table, String comment, Converter<X, U> converter, Binding<T, X> binding) { final Binding<T, U> actualBinding = DefaultBinding.newBinding(converter, type, binding); final DataType<U> actualType = converter == null && binding == null ? (DataType<U>) type : type.asConvertedDataType(actualBinding); // [#5999] TODO: Allow for user-defined Names final TableFieldImpl<R, U> tableField = new TableFieldImpl<R, U>(DSL.name(name), actualType, table, DSL.comment(comment), actualBinding); // [#1199] The public API of Table returns immutable field lists if (table instanceof TableImpl) { ((TableImpl<?>) table).fields0().add(tableField); } return tableField; }
@Override public final void toSQL(RenderContext context) { if (alias != null) { alias.toSQL(context); } else { if (context.qualify()) { Schema mappedSchema = Utils.getMappedSchema(context.configuration(), getSchema()); if (mappedSchema != null) { context.visit(mappedSchema); context.sql("."); } } context.literal(Utils.getMappedTable(context.configuration(), this).getName()); if (parameters != null && context.declareTables()) { context.sql("(") .visit(new QueryPartList<Field<?>>(parameters)) .sql(")"); } } }
@Override public UniqueKey<R> getPrimaryKey() { return super.getPrimaryKey(); }