[jOOQ/jOOQ#10085] Add DataType.isJSON()

This commit is contained in:
Lukas Eder 2020-04-17 17:57:43 +02:00
parent 705ad32b76
commit 2f28c8e304
3 changed files with 23 additions and 2 deletions

View File

@ -705,4 +705,14 @@ public interface DataType<T> extends Serializable {
* Whether this data type is an enum type.
*/
boolean isEnum();
/**
* Whether this data type is a JSON type.
*/
boolean isJSON();
/**
* Whether this data type is an XML type.
*/
boolean isXML();
}

View File

@ -74,12 +74,15 @@ import org.jooq.Converter;
import org.jooq.DataType;
import org.jooq.EnumType;
import org.jooq.Field;
import org.jooq.JSON;
import org.jooq.JSONB;
import org.jooq.Nullability;
// ...
import org.jooq.Result;
import org.jooq.SQLDialect;
import org.jooq.TableRecord;
import org.jooq.UDTRecord;
import org.jooq.XML;
import org.jooq.exception.MappingException;
import org.jooq.exception.SQLDialectNotSupportedException;
import org.jooq.tools.Convert;
@ -1090,6 +1093,16 @@ public class DefaultDataType<T> implements DataType<T> {
return EnumType.class.isAssignableFrom(tType);
}
@Override
public final boolean isJSON() {
return tType == JSON.class || tType == JSONB.class;
}
@Override
public final boolean isXML() {
return tType == XML.class;
}
// ------------------------------------------------------------------------
// The Object API
// ------------------------------------------------------------------------

View File

@ -44,7 +44,6 @@ import static org.jooq.impl.Keywords.K_VALUE;
import org.jooq.Context;
import org.jooq.Field;
import org.jooq.JSON;
import org.jooq.JSONEntry;
@ -93,7 +92,6 @@ final class JSONEntryImpl<T> extends AbstractQueryPart implements JSONEntry<T> {
case MARIADB:
case MYSQL:
case POSTGRES: