[jOOQ/jOOQ#8345] Add an org.jooq.Typed<T> marker interface
This commit is contained in:
parent
f93a7beae4
commit
e86cdd1034
@ -169,40 +169,6 @@ extends
|
||||
@Override
|
||||
String getComment();
|
||||
|
||||
/**
|
||||
* The field's underlying {@link Converter}.
|
||||
* <p>
|
||||
* By default, all fields reference an identity-converter
|
||||
* <code>Converter<T, T></code>. Custom data types may be obtained by a
|
||||
* custom {@link Converter} placed on the generated {@link TableField}.
|
||||
*/
|
||||
@Override
|
||||
Converter<?, T> getConverter();
|
||||
|
||||
/**
|
||||
* The field's underlying {@link Binding}.
|
||||
*/
|
||||
@Override
|
||||
Binding<?, T> getBinding();
|
||||
|
||||
/**
|
||||
* The Java type of the field.
|
||||
*/
|
||||
@Override
|
||||
Class<T> getType();
|
||||
|
||||
/**
|
||||
* The type of this field (might not be dialect-specific).
|
||||
*/
|
||||
@Override
|
||||
DataType<T> getDataType();
|
||||
|
||||
/**
|
||||
* The dialect-specific type of this field.
|
||||
*/
|
||||
@Override
|
||||
DataType<T> getDataType(Configuration configuration);
|
||||
|
||||
/**
|
||||
* Create an alias for this field.
|
||||
* <p>
|
||||
|
||||
@ -48,36 +48,7 @@ package org.jooq;
|
||||
* @param <T> The parameter type
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
public interface Parameter<T> extends Named {
|
||||
|
||||
/**
|
||||
* The Java type of the parameter.
|
||||
*/
|
||||
Class<T> getType();
|
||||
|
||||
/**
|
||||
* The parameter's underlying {@link Converter}.
|
||||
* <p>
|
||||
* By default, all parameters reference an identity-converter
|
||||
* <code>Converter<T, T></code>. Custom data types may be obtained by a
|
||||
* custom {@link Converter} placed on the generated {@link Parameter}.
|
||||
*/
|
||||
Converter<?, T> getConverter();
|
||||
|
||||
/**
|
||||
* The parameter's underlying {@link Binding}.
|
||||
*/
|
||||
Binding<?, T> getBinding();
|
||||
|
||||
/**
|
||||
* The type of this parameter (might not be dialect-specific)
|
||||
*/
|
||||
DataType<T> getDataType();
|
||||
|
||||
/**
|
||||
* The dialect-specific type of this parameter
|
||||
*/
|
||||
DataType<T> getDataType(Configuration configuration);
|
||||
public interface Parameter<T> extends Named, Typed<T> {
|
||||
|
||||
/**
|
||||
* Whether this parameter has a default value
|
||||
|
||||
@ -115,35 +115,6 @@ package org.jooq;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -46,39 +46,6 @@ package org.jooq;
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
public interface SelectField<T> extends SelectFieldOrAsterisk, Named {
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// API
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The field's underlying {@link Converter}.
|
||||
* <p>
|
||||
* By default, all fields reference an identity-converter
|
||||
* <code>Converter<T, T></code>. Custom data types may be obtained by a
|
||||
* custom {@link Converter} placed on the generated {@link TableField}.
|
||||
*/
|
||||
Converter<?, T> getConverter();
|
||||
|
||||
/**
|
||||
* The field's underlying {@link Binding}.
|
||||
*/
|
||||
Binding<?, T> getBinding();
|
||||
|
||||
/**
|
||||
* The Java type of the field.
|
||||
*/
|
||||
Class<T> getType();
|
||||
|
||||
/**
|
||||
* The type of this field (might not be dialect-specific).
|
||||
*/
|
||||
DataType<T> getDataType();
|
||||
|
||||
/**
|
||||
* The dialect-specific type of this field.
|
||||
*/
|
||||
DataType<T> getDataType(Configuration configuration);
|
||||
public interface SelectField<T> extends SelectFieldOrAsterisk, Named, Typed<T> {
|
||||
|
||||
}
|
||||
|
||||
@ -64,7 +64,7 @@ import org.jooq.impl.DSL;
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
public interface Sequence<T extends Number> extends Named {
|
||||
public interface Sequence<T extends Number> extends Named, Typed<T> {
|
||||
|
||||
/**
|
||||
* Get the sequence catalog.
|
||||
@ -76,11 +76,6 @@ public interface Sequence<T extends Number> extends Named {
|
||||
*/
|
||||
Schema getSchema();
|
||||
|
||||
/**
|
||||
* Get the sequence data type.
|
||||
*/
|
||||
DataType<T> getDataType();
|
||||
|
||||
/**
|
||||
* Get the start value for this sequence or <code>null</code>, if no such
|
||||
* value is specified.
|
||||
|
||||
80
jOOQ/src/main/java/org/jooq/Typed.java
Normal file
80
jOOQ/src/main/java/org/jooq/Typed.java
Normal file
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* A marker interface for all query parts that have a {@link DataType}.
|
||||
* <p>
|
||||
* While there is no requirement for implementations to also implement
|
||||
* {@link Named}, a lot of implementations do.
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
public interface Typed<T> extends QueryPart {
|
||||
|
||||
/**
|
||||
* The object's underlying {@link Converter}.
|
||||
* <p>
|
||||
* By default, all typed objects reference an identity-converter
|
||||
* <code>Converter<T, T></code>. If an implementation is generated,
|
||||
* custom data types may be obtained by a custom {@link Converter} placed on
|
||||
* the generated object.
|
||||
*/
|
||||
Converter<?, T> getConverter();
|
||||
|
||||
/**
|
||||
* The object's underlying {@link Binding}.
|
||||
*/
|
||||
Binding<?, T> getBinding();
|
||||
|
||||
/**
|
||||
* The Java type of the object.
|
||||
*/
|
||||
Class<T> getType();
|
||||
|
||||
/**
|
||||
* The type of this object (might not be dialect-specific).
|
||||
*/
|
||||
DataType<T> getDataType();
|
||||
|
||||
/**
|
||||
* The dialect-specific type of this object.
|
||||
*/
|
||||
DataType<T> getDataType(Configuration configuration);
|
||||
|
||||
}
|
||||
@ -86,9 +86,7 @@ import org.jooq.Collation;
|
||||
import org.jooq.Comment;
|
||||
import org.jooq.Comparator;
|
||||
import org.jooq.Condition;
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.Context;
|
||||
import org.jooq.Converter;
|
||||
import org.jooq.DataType;
|
||||
import org.jooq.DatePart;
|
||||
import org.jooq.Field;
|
||||
@ -108,7 +106,7 @@ import org.jooq.WindowPartitionByStep;
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
abstract class AbstractField<T> extends AbstractNamed implements Field<T> {
|
||||
abstract class AbstractField<T> extends AbstractTypedNamed<T> implements Field<T> {
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
@ -116,8 +114,6 @@ abstract class AbstractField<T> extends AbstractNamed implements Field<T> {
|
||||
private static final long serialVersionUID = 2884811923648354905L;
|
||||
private static final Clause[] CLAUSES = { FIELD };
|
||||
|
||||
private final DataType<T> dataType;
|
||||
|
||||
AbstractField(Name name, DataType<T> type) {
|
||||
this(name, type, null);
|
||||
}
|
||||
@ -128,9 +124,7 @@ abstract class AbstractField<T> extends AbstractNamed implements Field<T> {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
AbstractField(Name name, DataType<T> type, Comment comment, Binding<?, T> binding) {
|
||||
super(name, comment);
|
||||
|
||||
this.dataType = type.asConvertedDataType((Binding<T, T>) binding);
|
||||
super(name, comment, type.asConvertedDataType((Binding<T, T>) binding));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@ -212,31 +206,6 @@ abstract class AbstractField<T> extends AbstractNamed implements Field<T> {
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public final Converter<?, T> getConverter() {
|
||||
return getBinding().converter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Binding<?, T> getBinding() {
|
||||
return dataType.getBinding();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final DataType<T> getDataType() {
|
||||
return dataType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final DataType<T> getDataType(Configuration configuration) {
|
||||
return dataType.getDataType(configuration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Class<T> getType() {
|
||||
return dataType.getType();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// XXX: Type casts
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
91
jOOQ/src/main/java/org/jooq/impl/AbstractTypedNamed.java
Normal file
91
jOOQ/src/main/java/org/jooq/impl/AbstractTypedNamed.java
Normal file
@ -0,0 +1,91 @@
|
||||
/*
|
||||
* 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 org.jooq.Binding;
|
||||
import org.jooq.Comment;
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.Converter;
|
||||
import org.jooq.DataType;
|
||||
import org.jooq.Name;
|
||||
import org.jooq.Typed;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
abstract class AbstractTypedNamed<T> extends AbstractNamed implements Typed<T> {
|
||||
|
||||
private static final long serialVersionUID = 4569512766643813958L;
|
||||
private final DataType<T> type;
|
||||
|
||||
AbstractTypedNamed(Name name, Comment comment, DataType<T> type) {
|
||||
super(name, comment);
|
||||
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: Typed API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final Converter<?, T> getConverter() {
|
||||
return type.getConverter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Binding<?, T> getBinding() {
|
||||
return type.getBinding();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Class<T> getType() {
|
||||
return type.getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final DataType<T> getDataType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final DataType<T> getDataType(Configuration configuration) {
|
||||
return type.getDataType(configuration);
|
||||
}
|
||||
}
|
||||
@ -39,9 +39,7 @@
|
||||
package org.jooq.impl;
|
||||
|
||||
import org.jooq.Binding;
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.Context;
|
||||
import org.jooq.Converter;
|
||||
import org.jooq.DataType;
|
||||
import org.jooq.Parameter;
|
||||
|
||||
@ -50,48 +48,21 @@ import org.jooq.Parameter;
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
final class ParameterImpl<T> extends AbstractNamed implements Parameter<T> {
|
||||
final class ParameterImpl<T> extends AbstractTypedNamed<T> implements Parameter<T> {
|
||||
|
||||
private static final long serialVersionUID = -5277225593751085577L;
|
||||
|
||||
private final DataType<T> type;
|
||||
private final boolean isDefaulted;
|
||||
private final boolean isUnnamed;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
ParameterImpl(String name, DataType<T> type, Binding<?, T> binding, boolean isDefaulted, boolean isUnnamed) {
|
||||
super(DSL.name(name), CommentImpl.NO_COMMENT);
|
||||
super(DSL.name(name), CommentImpl.NO_COMMENT, type.asConvertedDataType((Binding<T, T>) binding));
|
||||
|
||||
this.type = type.asConvertedDataType((Binding<T, T>) binding);
|
||||
this.isDefaulted = isDefaulted;
|
||||
this.isUnnamed = isUnnamed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Converter<?, T> getConverter() {
|
||||
return type.getBinding().converter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Binding<?, T> getBinding() {
|
||||
return type.getBinding();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final DataType<T> getDataType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final DataType<T> getDataType(Configuration configuration) {
|
||||
return type.getDataType(configuration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Class<T> getType() {
|
||||
return type.getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
ctx.visit(getUnqualifiedName());
|
||||
|
||||
@ -129,39 +129,6 @@ package org.jooq.impl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -76,7 +76,7 @@ import org.jooq.exception.SQLDialectNotSupportedException;
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
@org.jooq.Internal
|
||||
public class SequenceImpl<T extends Number> extends AbstractNamed implements Sequence<T> {
|
||||
public class SequenceImpl<T extends Number> extends AbstractTypedNamed<T> implements Sequence<T> {
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
@ -86,7 +86,6 @@ public class SequenceImpl<T extends Number> extends AbstractNamed implements Seq
|
||||
|
||||
private final boolean nameIsPlainSQL;
|
||||
private final Schema schema;
|
||||
private final DataType<T> type;
|
||||
private final Field<T> startWith;
|
||||
private final Field<T> incrementBy;
|
||||
private final Field<T> minvalue;
|
||||
@ -107,12 +106,21 @@ public class SequenceImpl<T extends Number> extends AbstractNamed implements Seq
|
||||
this(name, schema, type, nameIsPlainSQL, null, null, null, null, false, null);
|
||||
}
|
||||
|
||||
SequenceImpl(Name name, Schema schema, DataType<T> type, boolean nameIsPlainSQL,
|
||||
Field<T> startWith, Field<T> incrementBy, Field<T> minvalue, Field<T> maxvalue, boolean cycle, Field<T> cache) {
|
||||
super(qualify(schema, name), CommentImpl.NO_COMMENT);
|
||||
SequenceImpl(
|
||||
Name name,
|
||||
Schema schema,
|
||||
DataType<T> type,
|
||||
boolean nameIsPlainSQL,
|
||||
Field<T> startWith,
|
||||
Field<T> incrementBy,
|
||||
Field<T> minvalue,
|
||||
Field<T> maxvalue,
|
||||
boolean cycle,
|
||||
Field<T> cache
|
||||
) {
|
||||
super(qualify(schema, name), CommentImpl.NO_COMMENT, type);
|
||||
|
||||
this.schema = schema;
|
||||
this.type = type;
|
||||
this.nameIsPlainSQL = nameIsPlainSQL;
|
||||
|
||||
this.startWith = startWith;
|
||||
@ -133,11 +141,6 @@ public class SequenceImpl<T extends Number> extends AbstractNamed implements Seq
|
||||
return schema;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final DataType<T> getDataType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Field<T> getStartWith() {
|
||||
return startWith;
|
||||
@ -200,7 +203,7 @@ public class SequenceImpl<T extends Number> extends AbstractNamed implements Seq
|
||||
private final SequenceMethod method;
|
||||
|
||||
SequenceFunction(SequenceMethod method) {
|
||||
super(method.name, type);
|
||||
super(method.name, SequenceImpl.this.getDataType());
|
||||
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user