[jOOQ/jOOQ#12430] Make Java 17 the baseline for the jOOQ Open Source Edition

This commit is contained in:
Lukas Eder 2022-05-23 16:45:35 +02:00
parent 5371c335dd
commit e63719fad0
323 changed files with 904 additions and 904 deletions

View File

@ -274,7 +274,7 @@ public class DefaultGeneratorStrategy extends AbstractGeneratorStrategy {
public String getJavaMethodName(Definition definition, Mode mode) {
// [#7148] If table A references table B only once, then B is the ideal name
// for the implicit JOIN path. Otherwise, fall back to the foreign key name
if (getUseTableNameForUnambiguousFKs() && definition instanceof ForeignKeyDefinition) { ForeignKeyDefinition fk = (ForeignKeyDefinition) definition;
if (getUseTableNameForUnambiguousFKs() && definition instanceof ForeignKeyDefinition fk) {
TableDefinition referenced = fk.getReferencedTable();
if (fk.getKeyTable().getForeignKeys(referenced).size() == 1)
@ -489,7 +489,7 @@ public class DefaultGeneratorStrategy extends AbstractGeneratorStrategy {
return "embeddables";
// [#799] UDT's are also packages
else if (definition instanceof UDTDefinition) { UDTDefinition u = (UDTDefinition) definition;
else if (definition instanceof UDTDefinition u) {
// [#330] [#6529] A UDT inside of a package is a PL/SQL RECORD type
if (u.getPackage() != null)
@ -499,7 +499,7 @@ public class DefaultGeneratorStrategy extends AbstractGeneratorStrategy {
}
else if (definition instanceof PackageDefinition)
return "packages";
else if (definition instanceof RoutineDefinition) { RoutineDefinition r = (RoutineDefinition) definition;
else if (definition instanceof RoutineDefinition r) {
if (r.getPackage() instanceof UDTDefinition)
return "udt." + getJavaIdentifier(r.getPackage()).toLowerCase(targetLocale);
else if (r.getPackage() != null)
@ -511,7 +511,7 @@ public class DefaultGeneratorStrategy extends AbstractGeneratorStrategy {
return "enums";
else if (definition instanceof DomainDefinition)
return "domains";
else if (definition instanceof ArrayDefinition) { ArrayDefinition a = (ArrayDefinition) definition;
else if (definition instanceof ArrayDefinition a) {
// [#7125] An array inside of a package is a PL/SQL TABLE type
if (a.getPackage() != null)

View File

@ -618,8 +618,8 @@ public class GenerationTool {
if (d.getRegexFlags() != null) {
database.setRegexFlags(d.getRegexFlags());
if (strategy instanceof MatcherStrategy)
((MatcherStrategy) strategy).getPatterns().setRegexFlags(d.getRegexFlags());
if (strategy instanceof MatcherStrategy s)
s.getPatterns().setRegexFlags(d.getRegexFlags());
}
database.setRegexMatchesPartialQualification(!FALSE.equals(d.isRegexMatchesPartialQualification()));

View File

@ -70,14 +70,14 @@ public abstract class GeneratorWriter<W extends GeneratorWriter<W>> {
* A pattern to be used with "list" expressions
*/
private static final Pattern PATTERN_LIST = Pattern.compile(
("" +
"\\[\n" +
" (?:\\[before=([^]]+)])?\n" +
" (?:\\[separator=([^]]+)])?\n" +
" (?:\\[after=([^]]+)])?\n" +
" (?:\\[(.*)])\n" +
"]\n" +
""),
"""
\\[
(?:\\[before=([^]]+)])?
(?:\\[separator=([^]]+)])?
(?:\\[after=([^]]+)])?
(?:\\[(.*)])
]
""",
Pattern.DOTALL | Pattern.COMMENTS
);

View File

@ -4246,7 +4246,7 @@ public class JavaGenerator extends AbstractGenerator {
Query query = parser.parseQuery(method.getSql());
// TODO: ResultQuery (e.g. RETURNING clause)
if (query instanceof Select) { Select<?> select = (Select<?>) query;
if (query instanceof Select<?> select) {
final String namespace = StringUtils.toUC(method.getName(), getTargetLocale());
final List<Field<?>> fields = select.getSelect();
final TableDefinition table = new DefaultMetaTableDefinition(dao.getSchema(), new TableImpl<Record>("t") {{
@ -7530,8 +7530,8 @@ public class JavaGenerator extends AbstractGenerator {
return false;
default:
if (true)
return true;
return false;
}
@ -7557,20 +7557,20 @@ public class JavaGenerator extends AbstractGenerator {
String result = string.replace("\"\"\"", "\\\"\\\"\\\"");
// Only Java has incidental whitespace support (?)
// The first line may be ill-indented, because we read it from XML.
// Depending on the reader, the content may have been trimmed.
if (!result.startsWith(" ")) {
Matcher matcher = P_LEADING_WHITESPACE.matcher(result);
int indent = Integer.MAX_VALUE;
while (matcher.find())
indent = Math.min(indent, matcher.group(1).length());
result = (indent != Integer.MAX_VALUE ? " ".repeat(indent) : "") + result;
}
result = result.stripIndent();
return "\"\"\"\n" + result + "\n\"\"\"";
@ -8700,8 +8700,8 @@ public class JavaGenerator extends AbstractGenerator {
if (routine.getOverload() != null)
out.println("setOverloaded(true)%s", semicolon);
if (routine instanceof PostgresRoutineDefinition)
if (((PostgresRoutineDefinition) routine).isProcedure())
if (routine instanceof PostgresRoutineDefinition p)
if (p.isProcedure())
out.println("setSQLUsable(false)%s", semicolon);

View File

@ -70,8 +70,8 @@ public class PrefixSuffixGeneratorStrategy extends AbstractDelegatingGeneratorSt
GeneratorStrategy delegate,
Function<? super PrefixSuffixGeneratorStrategy, ? extends PrefixSuffixGeneratorStrategy> configuration
) {
return delegate instanceof GeneratorStrategyWrapper
? new GeneratorStrategyWrapper(((GeneratorStrategyWrapper) delegate).generator, configuration.apply(new PrefixSuffixGeneratorStrategy(((GeneratorStrategyWrapper) delegate).delegate)))
return delegate instanceof GeneratorStrategyWrapper w
? new GeneratorStrategyWrapper(w.generator, configuration.apply(new PrefixSuffixGeneratorStrategy(w.delegate)))
: configuration.apply(new PrefixSuffixGeneratorStrategy(delegate));
}

View File

@ -82,12 +82,12 @@
<meminitial>256m</meminitial>
<encoding>UTF-8</encoding>
<release>11</release>
<release>16</release>
<!-- IntelliJ needs these https://youtrack.jetbrains.com/issue/IDEA-195472 -->
<source>11</source>
<target>11</target>
<source>16</source>
<target>16</target>
<debug>true</debug>
<debuglevel>lines,vars,source</debuglevel>

View File

@ -87,8 +87,8 @@
<compilerId>javac-with-errorprone</compilerId>
<forceJavacCompilerUse>true</forceJavacCompilerUse>
<fork>false</fork>
<source>11</source>
<target>11</target>
<source>16</source>
<target>16</target>
<annotationProcessorPaths>
<path>
<groupId>org.jooq</groupId>

View File

@ -85,12 +85,12 @@
<meminitial>256m</meminitial>
<encoding>UTF-8</encoding>
<release>11</release>
<release>16</release>
<!-- IntelliJ needs these https://youtrack.jetbrains.com/issue/IDEA-195472 -->
<source>11</source>
<target>11</target>
<source>16</source>
<target>16</target>
<debug>true</debug>
<debuglevel>lines,vars,source</debuglevel>

View File

@ -41,12 +41,12 @@
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<release>11</release>
<release>16</release>
<!-- IntelliJ needs these https://youtrack.jetbrains.com/issue/IDEA-195472 -->
<source>11</source>
<target>11</target>
<source>16</source>
<target>16</target>
<!-- How to properly set things up in JDK 9+
https://stackoverflow.com/a/51409471/521799 -->

View File

@ -81,12 +81,12 @@
<meminitial>256m</meminitial>
<encoding>UTF-8</encoding>
<release>11</release>
<release>16</release>
<!-- IntelliJ needs these https://youtrack.jetbrains.com/issue/IDEA-195472 -->
<source>11</source>
<target>11</target>
<source>16</source>
<target>16</target>
<debug>true</debug>
<debuglevel>lines,vars,source</debuglevel>

View File

@ -184,12 +184,12 @@
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<release>11</release>
<release>16</release>
<!-- IntelliJ needs these https://youtrack.jetbrains.com/issue/IDEA-195472 -->
<source>11</source>
<target>11</target>
<source>16</source>
<target>16</target>
</configuration>
</plugin>

View File

@ -64,12 +64,12 @@
<meminitial>256m</meminitial>
<encoding>UTF-8</encoding>
<release>11</release>
<release>16</release>
<!-- IntelliJ needs these https://youtrack.jetbrains.com/issue/IDEA-195472 -->
<source>11</source>
<target>11</target>
<source>16</source>
<target>16</target>
<debug>true</debug>
<debuglevel>lines,vars,source</debuglevel>

View File

@ -20,12 +20,12 @@
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<release>11</release>
<release>16</release>
<!-- IntelliJ needs these https://youtrack.jetbrains.com/issue/IDEA-195472 -->
<source>11</source>
<target>11</target>
<source>16</source>
<target>16</target>
</configuration>
</plugin>

View File

@ -41,12 +41,12 @@
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<release>11</release>
<release>16</release>
<!-- IntelliJ needs these https://youtrack.jetbrains.com/issue/IDEA-195472 -->
<source>11</source>
<target>11</target>
<source>16</source>
<target>16</target>
</configuration>
</plugin>

View File

@ -96,12 +96,12 @@
<meminitial>256m</meminitial>
<encoding>UTF-8</encoding>
<release>11</release>
<release>16</release>
<!-- IntelliJ needs these https://youtrack.jetbrains.com/issue/IDEA-195472 -->
<source>11</source>
<target>11</target>
<source>16</source>
<target>16</target>
<debug>true</debug>
<debuglevel>lines,vars,source</debuglevel>

View File

@ -96,12 +96,12 @@
<meminitial>256m</meminitial>
<encoding>UTF-8</encoding>
<release>11</release>
<release>16</release>
<!-- IntelliJ needs these https://youtrack.jetbrains.com/issue/IDEA-195472 -->
<source>11</source>
<target>11</target>
<source>16</source>
<target>16</target>
<debug>true</debug>
<debuglevel>lines,vars,source</debuglevel>

View File

@ -67,12 +67,12 @@
<meminitial>256m</meminitial>
<encoding>UTF-8</encoding>
<release>11</release>
<release>16</release>
<!-- IntelliJ needs these https://youtrack.jetbrains.com/issue/IDEA-195472 -->
<source>11</source>
<target>11</target>
<source>16</source>
<target>16</target>
<debug>true</debug>
<debuglevel>lines,vars,source</debuglevel>

View File

@ -64,9 +64,9 @@ public class TestContainersTest {
}
}
static final /* record */ class Film { private final String title; public Film(String title) { this.title = title; } public String title() { return title; } @Override public boolean equals(Object o) { if (!(o instanceof Film)) return false; Film other = (Film) o; if (!java.util.Objects.equals(this.title, other.title)) return false; return true; } @Override public int hashCode() { return java.util.Objects.hash(this.title); } @Override public String toString() { return new StringBuilder("Film[").append("title=").append(this.title).append("]").toString(); } }
static final /* record */ class Actor { private final String firstName; private final String lastName; public Actor(String firstName, String lastName) { this.firstName = firstName; this.lastName = lastName; } public String firstName() { return firstName; } public String lastName() { return lastName; } @Override public boolean equals(Object o) { if (!(o instanceof Actor)) return false; Actor other = (Actor) o; if (!java.util.Objects.equals(this.firstName, other.firstName)) return false; if (!java.util.Objects.equals(this.lastName, other.lastName)) return false; return true; } @Override public int hashCode() { return java.util.Objects.hash(this.firstName, this.lastName); } @Override public String toString() { return new StringBuilder("Actor[").append("firstName=").append(this.firstName).append(", lastName=").append(this.lastName).append("]").toString(); } }
static final /* record */ class Category { private final String name; public Category(String name) { this.name = name; } public String name() { return name; } @Override public boolean equals(Object o) { if (!(o instanceof Category)) return false; Category other = (Category) o; if (!java.util.Objects.equals(this.name, other.name)) return false; return true; } @Override public int hashCode() { return java.util.Objects.hash(this.name); } @Override public String toString() { return new StringBuilder("Category[").append("name=").append(this.name).append("]").toString(); } }
record Film(String title) {}
record Actor(String firstName, String lastName) {}
record Category(String name) {}
@Test
public void testMultisetMappingIntoJavaRecords() {

View File

@ -66,12 +66,12 @@
<meminitial>256m</meminitial>
<encoding>UTF-8</encoding>
<release>11</release>
<release>16</release>
<!-- IntelliJ needs these https://youtrack.jetbrains.com/issue/IDEA-195472 -->
<source>11</source>
<target>11</target>
<source>16</source>
<target>16</target>
<debug>true</debug>
<debuglevel>lines,vars,source</debuglevel>

View File

@ -51,9 +51,9 @@ public class TestContainersTest {
}
}
static final /* record */ class Film { private final String title; public Film(String title) { this.title = title; } public String title() { return title; } @Override public boolean equals(Object o) { if (!(o instanceof Film)) return false; Film other = (Film) o; if (!java.util.Objects.equals(this.title, other.title)) return false; return true; } @Override public int hashCode() { return java.util.Objects.hash(this.title); } @Override public String toString() { return new StringBuilder("Film[").append("title=").append(this.title).append("]").toString(); } }
static final /* record */ class Actor { private final String firstName; private final String lastName; public Actor(String firstName, String lastName) { this.firstName = firstName; this.lastName = lastName; } public String firstName() { return firstName; } public String lastName() { return lastName; } @Override public boolean equals(Object o) { if (!(o instanceof Actor)) return false; Actor other = (Actor) o; if (!java.util.Objects.equals(this.firstName, other.firstName)) return false; if (!java.util.Objects.equals(this.lastName, other.lastName)) return false; return true; } @Override public int hashCode() { return java.util.Objects.hash(this.firstName, this.lastName); } @Override public String toString() { return new StringBuilder("Actor[").append("firstName=").append(this.firstName).append(", lastName=").append(this.lastName).append("]").toString(); } }
static final /* record */ class Category { private final String name; public Category(String name) { this.name = name; } public String name() { return name; } @Override public boolean equals(Object o) { if (!(o instanceof Category)) return false; Category other = (Category) o; if (!java.util.Objects.equals(this.name, other.name)) return false; return true; } @Override public int hashCode() { return java.util.Objects.hash(this.name); } @Override public String toString() { return new StringBuilder("Category[").append("name=").append(this.name).append("]").toString(); } }
record Film(String title) {}
record Actor(String firstName, String lastName) {}
record Category(String name) {}
@Test
public void testMultisetMappingIntoJavaRecords() {

View File

@ -157,13 +157,13 @@ public class JPADatabase extends AbstractInterpretingDatabase {
if (count > 0)
log.info("Entities added", "Number of entities added: " + count);
else
log.warn("No entities added", ("" +
"No entities were added to the MetadataSources\n" +
"\n" +
"This can have several reasons, including:\n" +
"- The packages you've listed do not exist ({packages})\n" +
"- The entities in the listed packages are not on the JPADatabase classpath (you must compile them before running jOOQ's codegen, see \"how to organise your dependencies\" in the manual: https://www.jooq.org/doc/latest/manual/code-generation/codegen-jpa/!)\n" +
"").replace("{packages}", packages)
log.warn("No entities added", """
No entities were added to the MetadataSources
This can have several reasons, including:
- The packages you've listed do not exist ({packages})
- The entities in the listed packages are not on the JPADatabase classpath (you must compile them before running jOOQ's codegen, see "how to organise your dependencies" in the manual: https://www.jooq.org/doc/latest/manual/code-generation/codegen-jpa/!)
""".replace("{packages}", packages)
);
// This seems to be the way to do this in idiomatic Hibernate 5.0 API

View File

@ -127,7 +127,7 @@ public class DDLDatabase extends AbstractInterpretingDatabase {
ctx.configuration().set(new VisitListener() {
@Override
public void visitStart(VisitContext vc) {
if (vc.queryPart() instanceof Name) { Name n = (Name) vc.queryPart();
if (vc.queryPart() instanceof Name n) {
Name[] parts = n.parts();
boolean changed = false;

View File

@ -99,7 +99,7 @@ extends AbstractDefinition {
List<E> e = getElements0();
// [#5335] Warn if a table definition contains several identity columns
if (this instanceof TableDefinition) { TableDefinition t = (TableDefinition) this;
if (this instanceof TableDefinition t) {
if (e.stream().map(c -> (ColumnDefinition) c).filter(ColumnDefinition::isIdentity).count() > 1)
log.warn("Multiple identities", "Table " + getOutputName() + " has multiple identity columns. Only the first one is considered.");

View File

@ -90,7 +90,7 @@ public class DefaultColumnDefinition
this.readonly = readonly || isSyntheticReadonlyColumn(this, this.identity);
// [#6222] Copy the column's identity flag to the data type definition
if (type instanceof DefaultDataTypeDefinition) { DefaultDataTypeDefinition dd = (DefaultDataTypeDefinition) type;
if (type instanceof DefaultDataTypeDefinition dd) {
dd.identity(this.identity);
dd.readonly(this.readonly);
}

View File

@ -446,5 +446,5 @@ public class DefaultRelations implements Relations {
/**
* A simple local wrapper for a key definition (table + key name)
*/
private static final /* record */ class Key { private final TableDefinition table; private final String keyName; public Key(TableDefinition table, String keyName) { this.table = table; this.keyName = keyName; } public TableDefinition table() { return table; } public String keyName() { return keyName; } @Override public boolean equals(Object o) { if (!(o instanceof Key)) return false; Key other = (Key) o; if (!java.util.Objects.equals(this.table, other.table)) return false; if (!java.util.Objects.equals(this.keyName, other.keyName)) return false; return true; } @Override public int hashCode() { return java.util.Objects.hash(this.table, this.keyName); } @Override public String toString() { return new StringBuilder("Key[").append("table=").append(this.table).append(", keyName=").append(this.keyName).append("]").toString(); } }
private static record Key(TableDefinition table, String keyName) {}
}

View File

@ -659,7 +659,7 @@ public class H2Database extends AbstractDatabase implements ResultQueryDatabase
return result;
}
static final /* record */ class TableRecord { private final String schema; private final String table; private final TableType type; private final String comment; private final String source; public TableRecord(String schema, String table, TableType type, String comment, String source) { this.schema = schema; this.table = table; this.type = type; this.comment = comment; this.source = source; } public String schema() { return schema; } public String table() { return table; } public TableType type() { return type; } public String comment() { return comment; } public String source() { return source; } @Override public boolean equals(Object o) { if (!(o instanceof TableRecord)) return false; TableRecord other = (TableRecord) o; if (!java.util.Objects.equals(this.schema, other.schema)) return false; if (!java.util.Objects.equals(this.table, other.table)) return false; if (!java.util.Objects.equals(this.type, other.type)) return false; if (!java.util.Objects.equals(this.comment, other.comment)) return false; if (!java.util.Objects.equals(this.source, other.source)) return false; return true; } @Override public int hashCode() { return java.util.Objects.hash(this.schema, this.table, this.type, this.comment, this.source); } @Override public String toString() { return new StringBuilder("TableRecord[").append("schema=").append(this.schema).append(", table=").append(this.table).append(", type=").append(this.type).append(", comment=").append(this.comment).append(", source=").append(this.source).append("]").toString(); } }
static record TableRecord(String schema, String table, TableType type, String comment, String source) {}
@Override
protected List<TableDefinition> getTables0() throws SQLException {
@ -826,18 +826,18 @@ public class H2Database extends AbstractDatabase implements ResultQueryDatabase
private void getInlineEnums2_0(List<EnumDefinition> result) {
// TODO: Re-generate the H2 schema and use generated code to run this query
create().resultQuery(("" +
"select c.TABLE_SCHEMA , c.TABLE_NAME , c.COLUMN_NAME , array_agg(ev.value_name order by ev.VALUE_ORDINAL)\n" +
"from INFORMATION_SCHEMA.ENUM_VALUES ev\n" +
"join INFORMATION_SCHEMA.COLUMNS c\n" +
"on ev.OBJECT_SCHEMA = c.TABLE_SCHEMA\n" +
"and ev.OBJECT_NAME = c.TABLE_NAME\n" +
"and ev.ENUM_IDENTIFIER = c.DTD_IDENTIFIER\n" +
"where ev.OBJECT_TYPE = 'TABLE'\n" +
"and c.DOMAIN_NAME IS NULL\n" +
"group by c.TABLE_SCHEMA , c.TABLE_NAME , c.COLUMN_NAME\n" +
"order by 1, 2, 3\n" +
""))
create().resultQuery("""
select c.TABLE_SCHEMA , c.TABLE_NAME , c.COLUMN_NAME , array_agg(ev.value_name order by ev.VALUE_ORDINAL)
from INFORMATION_SCHEMA.ENUM_VALUES ev
join INFORMATION_SCHEMA.COLUMNS c
on ev.OBJECT_SCHEMA = c.TABLE_SCHEMA
and ev.OBJECT_NAME = c.TABLE_NAME
and ev.ENUM_IDENTIFIER = c.DTD_IDENTIFIER
where ev.OBJECT_TYPE = 'TABLE'
and c.DOMAIN_NAME IS NULL
group by c.TABLE_SCHEMA , c.TABLE_NAME , c.COLUMN_NAME
order by 1, 2, 3
""")
.coerce(COLUMNS.TABLE_SCHEMA, COLUMNS.TABLE_NAME, COLUMNS.COLUMN_NAME, arrayAgg(COLUMNS.COLUMN_NAME))
.forEach(r -> {
SchemaDefinition schema = getSchema(r.value1());
@ -868,7 +868,7 @@ public class H2Database extends AbstractDatabase implements ResultQueryDatabase
});
}
static final /* record */ class EnumRecord { private final String schema; private final String table; private final String column; private final String type; public EnumRecord(String schema, String table, String column, String type) { this.schema = schema; this.table = table; this.column = column; this.type = type; } public String schema() { return schema; } public String table() { return table; } public String column() { return column; } public String type() { return type; } @Override public boolean equals(Object o) { if (!(o instanceof EnumRecord)) return false; EnumRecord other = (EnumRecord) o; if (!java.util.Objects.equals(this.schema, other.schema)) return false; if (!java.util.Objects.equals(this.table, other.table)) return false; if (!java.util.Objects.equals(this.column, other.column)) return false; if (!java.util.Objects.equals(this.type, other.type)) return false; return true; } @Override public int hashCode() { return java.util.Objects.hash(this.schema, this.table, this.column, this.type); } @Override public String toString() { return new StringBuilder("EnumRecord[").append("schema=").append(this.schema).append(", table=").append(this.table).append(", column=").append(this.column).append(", type=").append(this.type).append("]").toString(); } }
static record EnumRecord (String schema, String table, String column, String type) {}
private void getInlineEnums1_4(List<EnumDefinition> result) {
@ -928,13 +928,13 @@ public class H2Database extends AbstractDatabase implements ResultQueryDatabase
private void getDomainEnums2_0(List<EnumDefinition> result) {
// TODO: Re-generate the H2 schema and use generated code to run this query
create().resultQuery(("" +
"select object_schema, object_name, array_agg(ev.value_name order by ev.VALUE_ORDINAL)\n" +
"from INFORMATION_SCHEMA.ENUM_VALUES ev\n" +
"where ev.OBJECT_TYPE = 'DOMAIN'\n" +
"group by object_schema, object_name\n" +
"order by 1, 2\n" +
""))
create().resultQuery("""
select object_schema, object_name, array_agg(ev.value_name order by ev.VALUE_ORDINAL)
from INFORMATION_SCHEMA.ENUM_VALUES ev
where ev.OBJECT_TYPE = 'DOMAIN'
group by object_schema, object_name
order by 1, 2
""")
.coerce(COLUMNS.TABLE_SCHEMA, COLUMNS.TABLE_NAME, arrayAgg(COLUMNS.COLUMN_NAME))
.forEach(r -> {
@ -950,7 +950,7 @@ public class H2Database extends AbstractDatabase implements ResultQueryDatabase
});
}
static final /* record */ class DomainRecord { private final String schema; private final String name; private final String sql; public DomainRecord(String schema, String name, String sql) { this.schema = schema; this.name = name; this.sql = sql; } public String schema() { return schema; } public String name() { return name; } public String sql() { return sql; } @Override public boolean equals(Object o) { if (!(o instanceof DomainRecord)) return false; DomainRecord other = (DomainRecord) o; if (!java.util.Objects.equals(this.schema, other.schema)) return false; if (!java.util.Objects.equals(this.name, other.name)) return false; if (!java.util.Objects.equals(this.sql, other.sql)) return false; return true; } @Override public int hashCode() { return java.util.Objects.hash(this.schema, this.name, this.sql); } @Override public String toString() { return new StringBuilder("DomainRecord[").append("schema=").append(this.schema).append(", name=").append(this.name).append(", sql=").append(this.sql).append("]").toString(); } }
static record DomainRecord (String schema, String name, String sql) {}
private void getDomainEnums1_4(List<EnumDefinition> result) {

View File

@ -458,7 +458,7 @@ public class MySQLDatabase extends AbstractDatabase implements ResultQueryDataba
return result;
}
static final /* record */ class ColumnRecord { private final String schema; private final String table; private final String column; private final String type; private final String comment; public ColumnRecord(String schema, String table, String column, String type, String comment) { this.schema = schema; this.table = table; this.column = column; this.type = type; this.comment = comment; } public String schema() { return schema; } public String table() { return table; } public String column() { return column; } public String type() { return type; } public String comment() { return comment; } @Override public boolean equals(Object o) { if (!(o instanceof ColumnRecord)) return false; ColumnRecord other = (ColumnRecord) o; if (!java.util.Objects.equals(this.schema, other.schema)) return false; if (!java.util.Objects.equals(this.table, other.table)) return false; if (!java.util.Objects.equals(this.column, other.column)) return false; if (!java.util.Objects.equals(this.type, other.type)) return false; if (!java.util.Objects.equals(this.comment, other.comment)) return false; return true; } @Override public int hashCode() { return java.util.Objects.hash(this.schema, this.table, this.column, this.type, this.comment); } @Override public String toString() { return new StringBuilder("ColumnRecord[").append("schema=").append(this.schema).append(", table=").append(this.table).append(", column=").append(this.column).append(", type=").append(this.type).append(", comment=").append(this.comment).append("]").toString(); } }
static record ColumnRecord (String schema, String table, String column, String type, String comment) {}
@Override
protected List<EnumDefinition> getEnums0() throws SQLException {

View File

@ -745,7 +745,7 @@ public class PostgresDatabase extends AbstractDatabase implements ResultQueryDat
return result;
}
static final /* record */ class Identifier { private final String schema; private final String name; public Identifier(String schema, String name) { this.schema = schema; this.name = name; } public String schema() { return schema; } public String name() { return name; } @Override public boolean equals(Object o) { if (!(o instanceof Identifier)) return false; Identifier other = (Identifier) o; if (!java.util.Objects.equals(this.schema, other.schema)) return false; if (!java.util.Objects.equals(this.name, other.name)) return false; return true; } @Override public int hashCode() { return java.util.Objects.hash(this.schema, this.name); } @Override public String toString() { return new StringBuilder("Identifier[").append("schema=").append(this.schema).append(", name=").append(this.name).append("]").toString(); } }
static record Identifier(String schema, String name) {}
@Override
protected List<EnumDefinition> getEnums0() throws SQLException {

View File

@ -46,12 +46,12 @@
<configuration>
<encoding>UTF-8</encoding>
<release>11</release>
<release>16</release>
<!-- IntelliJ needs these https://youtrack.jetbrains.com/issue/IDEA-195472 -->
<source>11</source>
<target>11</target>
<source>16</source>
<target>16</target>
</configuration>
</plugin>

View File

@ -70,7 +70,7 @@ import org.jooq.impl.QOM.UnmodifiableList;
* @see Table#asterisk()
* @author Lukas Eder
*/
public /* non-sealed */ interface Asterisk extends SelectFieldOrAsterisk {
public non-sealed interface Asterisk extends SelectFieldOrAsterisk {
/**
* The asterisk (<code>* EXCEPT (fields)</code>) expression to be used in

View File

@ -56,12 +56,12 @@ final class CLIUtil {
}
catch (NoClassDefFoundError e) {
throw new RuntimeException(
("" +
"A class definition could not be found when running the CLI utility.\n" +
"\n" +
"This is mostly due to a missing dependency. Make sure you have added the right dependencies\n" +
"as according to the manual for {url}\n" +
"").replace("{url}", url.replace("/latest/", "/" + MINOR_VERSION + "/")),
"""
A class definition could not be found when running the CLI utility.
This is mostly due to a missing dependency. Make sure you have added the right dependencies
as according to the manual for {url}
""".replace("{url}", url.replace("/latest/", "/" + MINOR_VERSION + "/")),
e
);
}

View File

@ -47,11 +47,11 @@ package org.jooq;
*
* @author Lukas Eder
*/
public /* sealed */ interface ColumnElement
public sealed interface ColumnElement
extends
QueryPart
/* permits
Comment */
permits
Comment
{
}

View File

@ -66,7 +66,7 @@ import org.jetbrains.annotations.ApiStatus.Experimental;
*
* @author Lukas Eder
*/
public /* non-sealed */ interface Comment extends ColumnElement {
public non-sealed interface Comment extends ColumnElement {
/**
* Get the comment.

View File

@ -61,7 +61,7 @@ import org.jooq.impl.DSL;
*
* @author Lukas Eder
*/
public /* non-sealed */ interface Constraint
public non-sealed interface Constraint
extends
FieldOrConstraint,
TableElement

View File

@ -134,8 +134,8 @@ public class Converters<T, U> extends AbstractConverter<T, U> {
* the argument converter's types.
*/
public static <T, U> Converter<T[], U[]> forArrays(Converter<T, U> converter) {
if (converter instanceof ArrayComponentConverter)
return ((ArrayComponentConverter<T, U>) converter).converter;
if (converter instanceof ArrayComponentConverter<T, U> a)
return a.converter;
else
return new ArrayConverter<>(converter);
}
@ -145,8 +145,8 @@ public class Converters<T, U> extends AbstractConverter<T, U> {
* converter, which converts array types.
*/
public static <T, U> Converter<T, U> forArrayComponents(Converter<T[], U[]> converter) {
if (converter instanceof ArrayConverter)
return ((ArrayConverter<T, U>) converter).converter;
if (converter instanceof ArrayConverter<T, U> a)
return a.converter;
else
return new ArrayComponentConverter<>(converter);
}

View File

@ -145,7 +145,7 @@ import org.jetbrains.annotations.Nullable;
* @param <T> The field type
* @author Lukas Eder
*/
public /* non-sealed */ interface Field<T>
public non-sealed interface Field<T>
extends
SelectField<T>,
GroupField,

View File

@ -49,12 +49,12 @@ package org.jooq;
* @deprecated - 3.17.0 - [#13005] - Use {@link TableElement} instead.
*/
@Deprecated
public /* sealed */ interface FieldOrConstraint
public sealed interface FieldOrConstraint
extends
TableElement
/* permits
permits
Field,
Constraint */
Constraint
{
}

View File

@ -55,12 +55,12 @@ package org.jooq;
*
* @author Lukas Eder
*/
public /* sealed */ interface FieldOrRow
public sealed interface FieldOrRow
extends
QueryPart
/* permits
permits
Field,
Row */
Row
{
}

View File

@ -45,13 +45,13 @@ package org.jooq;
*
* @author Lukas Eder
*/
public /* sealed */ interface FieldOrRowOrSelect
public sealed interface FieldOrRowOrSelect
extends
QueryPart
/* permits
permits
Field,
Row,
Select */
Select
{
}

View File

@ -104,8 +104,8 @@ public final class Geography implements Spatial {
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj instanceof Geography)
return data.equals(((Geography) obj).data);
if (obj instanceof Geography j)
return data.equals(j.data);
return false;
}

View File

@ -104,8 +104,8 @@ public final class Geometry implements Spatial {
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj instanceof Geometry)
return data.equals(((Geometry) obj).data);
if (obj instanceof Geometry j)
return data.equals(j.data);
return false;
}

View File

@ -65,14 +65,14 @@ import org.jooq.impl.QOM;
*
* @author Lukas Eder
*/
public /* sealed */ interface GroupField
public sealed interface GroupField
extends
QueryPart
/* permits
permits
Table,
Field,
QOM.EmptyGroupingSet,
QOM.Rollup,
QOM.Cube,
QOM.GroupingSets */
QOM.GroupingSets
{}

View File

@ -53,7 +53,7 @@ import org.jetbrains.annotations.ApiStatus.Experimental;
*
* @author Lukas Eder
*/
public /* non-sealed */ interface Index extends TableElement {
public non-sealed interface Index extends TableElement {
/**
* The table on which this index is defined.

View File

@ -101,8 +101,8 @@ public final class JSON implements Serializable {
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj instanceof JSON)
return data.equals(((JSON) obj).data);
if (obj instanceof JSON j)
return data.equals(j.data);
return false;
}

View File

@ -121,8 +121,8 @@ public final class JSONB implements Serializable {
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj instanceof JSONB)
return Objects.equals(parsed(), (((JSONB) obj).parsed()));
if (obj instanceof JSONB j)
return Objects.equals(parsed(), (j.parsed()));
return false;
}

View File

@ -45,12 +45,12 @@ package org.jooq;
*
* @author Lukas Eder
*/
public /* sealed */ interface OrderField<T>
public sealed interface OrderField<T>
extends
QueryPart
/* permits
permits
Field,
SortField */
SortField
{
}

View File

@ -94,7 +94,7 @@ import org.jetbrains.annotations.ApiStatus.Experimental;
* @author Lukas Eder
* @see DSL#param(String, Object)
*/
public /* non-sealed */ interface Param<T> extends ParamOrVariable<T> {
public non-sealed interface Param<T> extends ParamOrVariable<T> {
/**
* The parameter name. This name is useful for two things:

View File

@ -42,12 +42,12 @@ package org.jooq;
*
* @author Lukas Eder
*/
public /* sealed */ interface ParamOrVariable<T>
public sealed interface ParamOrVariable<T>
extends
Field<T>
/* permits
permits
Param,
Variable */
Variable
{
}

View File

@ -69,7 +69,7 @@ import org.jetbrains.annotations.ApiStatus.Experimental;
*
* @author Lukas Eder
*/
public /* non-sealed */ interface QualifiedAsterisk extends SelectFieldOrAsterisk {
public non-sealed interface QualifiedAsterisk extends SelectFieldOrAsterisk {
/**
* The qualifier.

View File

@ -80,7 +80,7 @@ import org.jetbrains.annotations.ApiStatus.Experimental;
*
* @author Lukas Eder
*/
public /* non-sealed */ interface Row
public non-sealed interface Row
extends
Fields,
FieldOrRow,

View File

@ -97,7 +97,7 @@ import org.jetbrains.annotations.ApiStatus.Experimental;
* @param <R> The record type being returned by this query
* @author Lukas Eder
*/
public /* non-sealed */ interface Select<R extends Record>
public non-sealed interface Select<R extends Record>
extends
ResultQuery<R>,
TableLike<R>,

View File

@ -52,7 +52,7 @@ import org.jetbrains.annotations.NotNull;
*
* @author Lukas Eder
*/
public /* non-sealed */ interface SelectField<T> extends SelectFieldOrAsterisk, Named, Typed<T> {
public non-sealed interface SelectField<T> extends SelectFieldOrAsterisk, Named, Typed<T> {
// ------------------------------------------------------------------------
// Aliasing

View File

@ -46,13 +46,13 @@ package org.jooq;
*
* @author Lukas Eder
*/
public /* sealed */ interface SelectFieldOrAsterisk
public sealed interface SelectFieldOrAsterisk
extends
QueryPart
/* permits
permits
SelectField,
Asterisk,
QualifiedAsterisk */
QualifiedAsterisk
{
}

View File

@ -73,7 +73,7 @@ import org.jetbrains.annotations.ApiStatus.Experimental;
* @see Field#asc()
* @see Field#desc()
*/
public /* non-sealed */ interface SortField<T> extends OrderField<T> {
public non-sealed interface SortField<T> extends OrderField<T> {
/**
* The name of this sort field

View File

@ -139,7 +139,7 @@ import org.jetbrains.annotations.Nullable;
* @param <R> The record type associated with this table
* @author Lukas Eder
*/
public /* non-sealed */ interface Table<R extends Record>
public non-sealed interface Table<R extends Record>
extends
TableLike<R>,
RecordQualifier<R>,

View File

@ -47,14 +47,14 @@ package org.jooq;
*
* @author Lukas Eder
*/
public /* sealed */ interface TableElement
public sealed interface TableElement
extends
Named
/* permits
permits
FieldOrConstraint,
Field,
Constraint,
Index */
Index
{
}

View File

@ -67,13 +67,13 @@ import org.jetbrains.annotations.NotNull;
* @param <R> The record type
* @author Lukas Eder
*/
public /* sealed */ interface TableLike<R extends Record>
public sealed interface TableLike<R extends Record>
extends
Fields,
QueryPart
/* permits
permits
Select,
Table */
Table
{
/**

View File

@ -101,8 +101,8 @@ public final class XML implements Serializable {
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj instanceof XML)
return data.equals(((XML) obj).data);
if (obj instanceof XML x)
return data.equals(x.data);
return false;
}

View File

@ -165,7 +165,7 @@ implements
@Override
public boolean equals(Object that) {
if (that instanceof QOM.Abs) { QOM.Abs<?> o = (QOM.Abs<?>) that;
if (that instanceof QOM.Abs<?> o) {
return
StringUtils.equals($value(), o.$value())
;

View File

@ -236,7 +236,7 @@ abstract class AbstractContext<C extends Context<C>> extends AbstractScope imple
@Override
public final C visit(Field<?> part) {
return part instanceof Condition ? visit((QueryPart) DSL.field((Condition) part)) : visit((QueryPart) part);
return part instanceof Condition c ? visit((QueryPart) DSL.field(c)) : visit((QueryPart) part);
}
@Override
@ -546,12 +546,12 @@ abstract class AbstractContext<C extends Context<C>> extends AbstractScope imple
@Override
public final RenderContext renderContext() {
return context() instanceof RenderContext ? (RenderContext) context() : null;
return context() instanceof RenderContext c ? c : null;
}
@Override
public final BindContext bindContext() {
return context() instanceof BindContext ? (BindContext) context() : null;
return context() instanceof BindContext c ? c : null;
}
}

View File

@ -235,16 +235,16 @@ abstract class AbstractDMLQuery<R extends Record> extends AbstractRowCountQuery
returningResolvedAsterisks.clear();
for (SelectFieldOrAsterisk s : returning)
if (s instanceof Field)
returningResolvedAsterisks.add((Field<?>) s);
else if (s instanceof QualifiedAsterisk)
returningResolvedAsterisks.addAll(Arrays.asList(((QualifiedAsterisk) s).qualifier().fields()));
if (s instanceof Field<?> f)
returningResolvedAsterisks.add(f);
else if (s instanceof QualifiedAsterisk a)
returningResolvedAsterisks.addAll(Arrays.asList(a.qualifier().fields()));
else if (s instanceof Asterisk)
returningResolvedAsterisks.addAll(Arrays.asList(table.fields()));
else if (s instanceof Row)
returningResolvedAsterisks.add(new RowAsField<>((Row) s));
else if (s instanceof Table)
returningResolvedAsterisks.add(new TableAsField<>((Table<?>) s));
else if (s instanceof Row r)
returningResolvedAsterisks.add(new RowAsField<>(r));
else if (s instanceof Table<?> t)
returningResolvedAsterisks.add(new TableAsField<>(t));
else
throw new UnsupportedOperationException("Type not supported: " + s);
}

View File

@ -240,7 +240,7 @@ abstract class AbstractField<T> extends AbstractTypedNamed<T> implements Field<T
@SuppressWarnings("unchecked")
@Override
public Field<T> as(Name alias) {
return new FieldAlias<>((Field<T>) (this instanceof Condition ? DSL.field((Condition) this) : this), alias);
return new FieldAlias<>((Field<T>) (this instanceof Condition c ? DSL.field(c) : this), alias);
}
@Override
@ -312,7 +312,7 @@ abstract class AbstractField<T> extends AbstractTypedNamed<T> implements Field<T
@Override
public final SortField<T> sort(SortOrder order) {
return this instanceof NoField ? (NoField<T>) this : new SortFieldImpl<>(this, order);
return this instanceof NoField<T> n ? n : new SortFieldImpl<>(this, order);
}
@Override
@ -1482,14 +1482,14 @@ abstract class AbstractField<T> extends AbstractTypedNamed<T> implements Field<T
return new IsNotDistinctFrom<>(this, nullSafe(field, getDataType()));
case IN:
if (field instanceof ScalarSubquery)
return new In<>(this, (Select<? extends Record1<T>>) ((ScalarSubquery<?>) field).query);
if (field instanceof ScalarSubquery<?> s)
return new In<>(this, (Select<? extends Record1<T>>) s.query);
break;
case NOT_IN:
if (field instanceof ScalarSubquery)
return new NotIn<>(this, (Select<? extends Record1<T>>) ((ScalarSubquery<?>) field).query);
if (field instanceof ScalarSubquery<?> s)
return new NotIn<>(this, (Select<? extends Record1<T>>) s.query);
break;
}

View File

@ -641,8 +641,8 @@ abstract class AbstractMeta extends AbstractScope implements Meta, Serializable
@Override
public boolean equals(Object obj) {
if (obj instanceof Meta)
return ddl().equals(((Meta) obj).ddl());
if (obj instanceof Meta m)
return ddl().equals(m.ddl());
return false;
}

View File

@ -373,7 +373,7 @@ implements
// [#1626] [#11126] NameImpl equality can be decided without executing the
// rather expensive implementation of AbstractQueryPart.equals()
if (that instanceof AbstractName) { AbstractName n = (AbstractName) that;
if (that instanceof AbstractName n) {
// [#11126] No need to access name arrays if not both names are equally qualified
if (qualified() != n.qualified())

View File

@ -112,8 +112,8 @@ abstract class AbstractNamed extends AbstractQueryPart implements Named {
// [#2144] Non-equality can be decided early, without executing the
// rather expensive implementation of AbstractQueryPart.equals()
if (that instanceof AbstractNamed)
if (!getQualifiedName().equals(((AbstractNamed) that).getQualifiedName()))
if (that instanceof AbstractNamed n)
if (!getQualifiedName().equals(n.getQualifiedName()))
return false;
return super.equals(that);

View File

@ -104,8 +104,8 @@ abstract class AbstractParam<T> extends AbstractParamX<T> implements SimpleQuery
? paramName
// [#3707] Protect value.toString call for certain jOOQ types.
: value instanceof QualifiedRecord
? ((QualifiedRecord<?>) value).getQualifier().getName()
: value instanceof QualifiedRecord<?> q
? q.getQualifier().getName()
@ -121,7 +121,7 @@ abstract class AbstractParam<T> extends AbstractParamX<T> implements SimpleQuery
// [#13392] The generated name of a byte[] value shouldn't depend on the
// identity of the value, but on the value itself
if (value instanceof byte[]) { byte[] b = (byte[]) value;
if (value instanceof byte[] b) {
return "b_" + Internal.hash0(Arrays.hashCode(Arrays.copyOf(b, 16)));
}
else
@ -143,7 +143,7 @@ abstract class AbstractParam<T> extends AbstractParamX<T> implements SimpleQuery
}
private static boolean positive(Object value) {
return value instanceof Number ? ((Number) value).doubleValue() >= 0 : false;
return value instanceof Number n ? n.doubleValue() >= 0 : false;
}
@Override
@ -249,7 +249,7 @@ abstract class AbstractParam<T> extends AbstractParamX<T> implements SimpleQuery
if (this == that)
return true;
if (that instanceof Param) { Param<?> p = (Param<?>) that;
if (that instanceof Param<?> p) {
Object thatValue = p.getValue();
if (value == null)
@ -269,10 +269,10 @@ abstract class AbstractParam<T> extends AbstractParamX<T> implements SimpleQuery
public int hashCode() {
return value == null
? 0
: value instanceof byte[]
? Arrays.hashCode((byte[]) value)
: value instanceof Object[]
? Arrays.hashCode((Object[]) value)
: value instanceof byte[] a
? Arrays.hashCode(a)
: value instanceof Object[] a
? Arrays.hashCode(a)
: value.hashCode();
}
}

View File

@ -160,11 +160,11 @@ abstract class AbstractQueryPart implements QueryPartInternal {
// This is a working default implementation. It should be overridden by
// concrete subclasses, to improve performance
if (that instanceof QueryPart) { QueryPart q = (QueryPart) that;
if (that instanceof QueryPart q) {
// [#10635] The two QueryParts may have different Settings attached.
DSLContext dsl1 = Tools.configuration(configuration()).dsl();
DSLContext dsl2 = that instanceof AbstractQueryPart ? Tools.configuration(((AbstractQueryPart) that).configuration()).dsl() : dsl1;
DSLContext dsl2 = that instanceof AbstractQueryPart a ? Tools.configuration(a.configuration()).dsl() : dsl1;
String sql1 = dsl1.renderInlined(this);
String sql2 = dsl2.renderInlined(q);

View File

@ -159,7 +159,7 @@ abstract class AbstractRecord extends AbstractStore implements Record {
int size = size();
for (int i = 0; i < size; i++) {
if (values[i] instanceof Attachable) { Attachable a = (Attachable) values[i];
if (values[i] instanceof Attachable a) {
if (result == null)
result = new ArrayList<>();
@ -416,8 +416,8 @@ abstract class AbstractRecord extends AbstractStore implements Record {
set(index, field, value);
else if (Tools.nonReplacingEmbeddable(field)) {
Field<?>[] f = embeddedFields(field);
Object[] v = value instanceof EmbeddableRecord
? ((EmbeddableRecord) value).intoArray()
Object[] v = value instanceof EmbeddableRecord e
? e.intoArray()
: new Object[f.length];
for (int i = 0; i < f.length; i++)
@ -860,7 +860,7 @@ abstract class AbstractRecord extends AbstractStore implements Record {
try {
// [#1522] [#2989] If possible the complete state of this record should be copied onto the other record
if (target instanceof AbstractRecord) { AbstractRecord t = (AbstractRecord) target;
if (target instanceof AbstractRecord t) {
// Iterate over target fields, to avoid ambiguities when two source fields share the same name.
// [#3634] If external targetFields are provided, use those instead of the target record's fields.

View File

@ -431,8 +431,8 @@ abstract class AbstractResult<R extends Record> extends AbstractFormattable impl
return format.emptyString();
// [#7802] Nested records should generate nested CSV data structures
String result = value instanceof Formattable
? ((Formattable) value).formatCSV(format)
String result = value instanceof Formattable f
? f.formatCSV(format)
: format0(value, false, false);
switch (format.quote()) {
@ -490,7 +490,7 @@ abstract class AbstractResult<R extends Record> extends AbstractFormattable impl
if (format.format())
writer.append(format.newline()).append(format.indentString(3));
if (field instanceof TableField) { TableField<?, ?> f = (TableField<?, ?>) field;
if (field instanceof TableField<?, ?> f) {
Table<?> table = f.getTable();
if (table != null) {
@ -620,12 +620,12 @@ abstract class AbstractResult<R extends Record> extends AbstractFormattable impl
static final void formatJSON0(Object value, Writer writer, JSONFormat format) throws java.io.IOException {
// [#2741] TODO: This logic will be externalised in new SPI
if (value instanceof byte[]) { byte[] a = (byte[]) value;
if (value instanceof byte[] a) {
JSONValue.writeJSONString(Base64.getEncoder().encodeToString(a), writer);
}
// [#6563] Arrays can be serialised natively in JSON
else if (value instanceof Object[]) { Object[] array = (Object[]) value;
else if (value instanceof Object[] array) {
writer.append('[');
for (int i = 0; i < array.length; i++) {
@ -639,7 +639,7 @@ abstract class AbstractResult<R extends Record> extends AbstractFormattable impl
}
// [#7782] Nested records should generate nested JSON data structures
else if (value instanceof Formattable) { Formattable f = (Formattable) value;
else if (value instanceof Formattable f) {
f.formatJSON(writer, format);
}
@ -779,7 +779,7 @@ abstract class AbstractResult<R extends Record> extends AbstractFormattable impl
for (Field<?> field : fields.fields.fields) {
writer.append(newline).append(format.indentString(2)).append("<field");
if (field instanceof TableField) { TableField<?, ?> f = (TableField<?, ?>) field;
if (field instanceof TableField<?, ?> f) {
Table<?> table = f.getTable();
if (table != null) {
@ -870,7 +870,7 @@ abstract class AbstractResult<R extends Record> extends AbstractFormattable impl
else {
writer.append(">");
if (value instanceof Formattable) { Formattable f = (Formattable) value;
if (value instanceof Formattable f) {
writer.append(newline).append(format.indentString(recordLevel + 2));
int previous = format.globalIndent();
f.formatXML(writer, format.globalIndent(format.globalIndent() + format.indent() * (recordLevel + 2)));
@ -1092,8 +1092,8 @@ abstract class AbstractResult<R extends Record> extends AbstractFormattable impl
try {
for (R record : this) {
if (table == null)
if (record instanceof TableRecord)
table = ((TableRecord<?>) record).getTable();
if (record instanceof TableRecord<?> r)
table = r.getTable();
else
table = table(name("UNKNOWN_TABLE"));
@ -1171,7 +1171,7 @@ abstract class AbstractResult<R extends Record> extends AbstractFormattable impl
for (Field<?> field : fields.fields.fields) {
Element eField = document.createElement("field");
if (field instanceof TableField) { TableField<?, ?> f = (TableField<?, ?>) field;
if (field instanceof TableField<?, ?> f) {
Table<?> table = f.getTable();
if (table != null) {
@ -1300,7 +1300,7 @@ abstract class AbstractResult<R extends Record> extends AbstractFormattable impl
for (Field<?> field : fields.fields.fields) {
AttributesImpl attrs = new AttributesImpl();
if (field instanceof TableField) { TableField<?, ?> f = (TableField<?, ?>) field;
if (field instanceof TableField<?, ?> f) {
Table<?> table = f.getTable();
if (table != null) {
@ -1378,32 +1378,32 @@ abstract class AbstractResult<R extends Record> extends AbstractFormattable impl
if (value == null) {
formatted += visual ? "{null}" : null;
}
else if (value instanceof byte[]) { byte[] a = (byte[]) value;
else if (value instanceof byte[] a) {
formatted += Base64.getEncoder().encodeToString(a);
}
else if (value instanceof Object[]) { Object[] a = (Object[]) value;
else if (value instanceof Object[] a) {
// [#6545] Nested arrays are handled recursively
formatted += Arrays.stream(a).map(f -> format0(f, false, visual)).collect(joining(", ", "[", "]"));
}
else if (value instanceof EnumType) { EnumType e = (EnumType) value;
else if (value instanceof EnumType e) {
formatted += e.getLiteral();
}
else if (value instanceof List) { List<?> l = (List<?>) value;
else if (value instanceof List<?> l) {
formatted += l.stream().map(f -> format0(f, false, visual)).collect(joining(", ", "[", "]"));
}
else if (value instanceof Record) { Record r = (Record) value;
else if (value instanceof Record r) {
formatted += Arrays
.stream(r.intoArray())
.map(f -> format0(f, false, visual))
.collect(joining(", ", "(", ")"));
}
// [#6080] Support formatting of nested ROWs
else if (value instanceof Param) { Param<?> p = (Param<?>) value;
else if (value instanceof Param<?> p) {
formatted += format0(p.getValue(), false, visual);
}
// [#5238] Oracle DATE is really a TIMESTAMP(0)...
else if (value instanceof Date) { Date d = (Date) value;
else if (value instanceof Date d) {
String date = value.toString();
if (Date.valueOf(date).equals(value))

View File

@ -137,7 +137,7 @@ abstract class AbstractStore extends AbstractFormattable {
return true;
// Note: keep this implementation in-sync with AbstractRecord.compareTo()!
if (obj instanceof AbstractStore) { AbstractStore that = (AbstractStore) obj;
if (obj instanceof AbstractStore that) {
if (size() == that.size()) {
for (int i = 0; i < size(); i++) {
final Object thisValue = get(i);

View File

@ -128,8 +128,8 @@ implements
@Override
public boolean equals(Object that) {
if (that instanceof UnknownField)
return index == ((UnknownField<?>) that).index;
if (that instanceof UnknownField<?> f)
return index == f.index;
else
return false;
}

View File

@ -831,8 +831,8 @@ abstract class AbstractTable<R extends Record> extends AbstractNamed implements
TableFieldImpl<R, U> tableField = new TableFieldImpl<>(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);
if (table instanceof TableImpl<?> t)
t.fields0().add(tableField);
return tableField;
}

View File

@ -320,8 +320,8 @@ implements
@Override
public final WindowFinalStep<T> over(WindowSpecification specification) {
this.windowSpecification = specification instanceof WindowSpecificationImpl
? (WindowSpecificationImpl) specification
this.windowSpecification = specification instanceof WindowSpecificationImpl w
? w
: new WindowSpecificationImpl((WindowDefinitionImpl) specification);
return this;

View File

@ -189,7 +189,7 @@ implements
@Override
public boolean equals(Object that) {
if (that instanceof QOM.Acos) { QOM.Acos o = (QOM.Acos) that;
if (that instanceof QOM.Acos o) {
return
StringUtils.equals($value(), o.$value())
;

View File

@ -218,7 +218,7 @@ implements
@Override
public boolean equals(Object that) {
if (that instanceof QOM.Acosh) { QOM.Acosh o = (QOM.Acosh) that;
if (that instanceof QOM.Acosh o) {
return
StringUtils.equals($value(), o.$value())
;

View File

@ -236,7 +236,7 @@ implements
@Override
public boolean equals(Object that) {
if (that instanceof QOM.Acoth) { QOM.Acoth o = (QOM.Acoth) that;
if (that instanceof QOM.Acoth o) {
return
StringUtils.equals($value(), o.$value())
;

View File

@ -176,7 +176,7 @@ implements
@Override
public boolean equals(Object that) {
if (that instanceof QOM.Add) { QOM.Add<?> o = (QOM.Add<?>) that;
if (that instanceof QOM.Add<?> o) {
return
StringUtils.equals($arg1(), o.$arg1()) &&
StringUtils.equals($arg2(), o.$arg2())

View File

@ -236,10 +236,10 @@ final class Alias<Q extends QueryPart> extends AbstractQueryPart implements UEmp
// [#3156] Do not SELECT * from derived tables to prevent ambiguously defined columns
// in those derived tables
Select<?> wrappedAsSelect =
wrapped instanceof Select
? (Select<?>) wrapped
: wrapped instanceof DerivedTable
? ((DerivedTable<?>) wrapped).query()
wrapped instanceof Select<?> s
? s
: wrapped instanceof DerivedTable<?> d
? d.query()
: select(asterisk()).from(((Table<?>) wrapped).as(alias));
List<Field<?>> select = wrappedAsSelect.getSelect();

View File

@ -469,11 +469,11 @@ implements
if (fields.size() == 1) {
TableElement first = fields.iterator().next();
if (first instanceof Field)
return add((Field<?>) first);
else if (first instanceof Constraint)
return add((Constraint) first);
else if (first instanceof Index)
if (first instanceof Field<?> f)
return add(f);
else if (first instanceof Constraint c)
return add(c);
else if (first instanceof Index i)
throw new UnsupportedOperationException("ALTER TABLE .. ADD INDEX not yet supported, see https://github.com/jOOQ/jOOQ/issues/13006");
}
@ -1301,7 +1301,7 @@ implements
TableElement part = add.get(i);
ctx.qualify(false, c -> c.visit(part));
if (part instanceof Field) { Field<?> f = (Field<?>) part;
if (part instanceof Field<?> f) {
ctx.sql(' ');
toSQLDDLTypeDeclarationForAddition(ctx, f.getDataType());
}

View File

@ -181,7 +181,7 @@ implements
@Override
public boolean equals(Object that) {
if (that instanceof QOM.And) { QOM.And o = (QOM.And) that;
if (that instanceof QOM.And o) {
return
StringUtils.equals($arg1(), o.$arg1()) &&
StringUtils.equals($arg2(), o.$arg2())

View File

@ -184,7 +184,7 @@ implements
@Override
public boolean equals(Object that) {
if (that instanceof QOM.AnyValue) { QOM.AnyValue<?> o = (QOM.AnyValue<?>) that;
if (that instanceof QOM.AnyValue<?> o) {
return
StringUtils.equals($field(), o.$field())
;

View File

@ -207,7 +207,7 @@ implements
@Override
public boolean equals(Object that) {
if (that instanceof QOM.ArrayGet) { QOM.ArrayGet<?> o = (QOM.ArrayGet<?>) that;
if (that instanceof QOM.ArrayGet<?> o) {
return
StringUtils.equals($array(), o.$array()) &&
StringUtils.equals($index(), o.$index())

View File

@ -175,7 +175,7 @@ implements
@Override
public boolean equals(Object that) {
if (that instanceof QOM.Ascii) { QOM.Ascii o = (QOM.Ascii) that;
if (that instanceof QOM.Ascii o) {
return
StringUtils.equals($string(), o.$string())
;

View File

@ -185,7 +185,7 @@ implements
@Override
public boolean equals(Object that) {
if (that instanceof QOM.Asin) { QOM.Asin o = (QOM.Asin) that;
if (that instanceof QOM.Asin o) {
return
StringUtils.equals($value(), o.$value())
;

View File

@ -218,7 +218,7 @@ implements
@Override
public boolean equals(Object that) {
if (that instanceof QOM.Asinh) { QOM.Asinh o = (QOM.Asinh) that;
if (that instanceof QOM.Asinh o) {
return
StringUtils.equals($value(), o.$value())
;

View File

@ -172,7 +172,7 @@ implements
@Override
public boolean equals(Object that) {
if (that instanceof QOM.Atan) { QOM.Atan o = (QOM.Atan) that;
if (that instanceof QOM.Atan o) {
return
StringUtils.equals($value(), o.$value())
;

View File

@ -191,7 +191,7 @@ implements
@Override
public boolean equals(Object that) {
if (that instanceof QOM.Atan2) { QOM.Atan2 o = (QOM.Atan2) that;
if (that instanceof QOM.Atan2 o) {
return
StringUtils.equals($x(), o.$x()) &&
StringUtils.equals($y(), o.$y())

View File

@ -216,7 +216,7 @@ implements
@Override
public boolean equals(Object that) {
if (that instanceof QOM.Atanh) { QOM.Atanh o = (QOM.Atanh) that;
if (that instanceof QOM.Atanh o) {
return
StringUtils.equals($value(), o.$value())
;

View File

@ -147,7 +147,7 @@ implements
@Override
public boolean equals(Object that) {
if (that instanceof QOM.Avg) { QOM.Avg o = (QOM.Avg) that;
if (that instanceof QOM.Avg o) {
return
StringUtils.equals($field(), o.$field()) &&
$distinct() == o.$distinct()

View File

@ -213,8 +213,8 @@ final class BatchCRUD extends AbstractBatch {
// [#3362] If new records (fetched = false) are batch-stored twice in a row, the second
// batch-store needs to generate an UPDATE statement.
if (record instanceof AbstractRecord)
((AbstractRecord) record).fetched = action != Action.DELETE;
if (record instanceof AbstractRecord r)
r.fetched = action != Action.DELETE;
}
}

View File

@ -194,7 +194,7 @@ implements
@Override
public boolean equals(Object that) {
if (that instanceof QOM.BitAnd) { QOM.BitAnd<?> o = (QOM.BitAnd<?>) that;
if (that instanceof QOM.BitAnd<?> o) {
return
StringUtils.equals($arg1(), o.$arg1()) &&
StringUtils.equals($arg2(), o.$arg2())

View File

@ -337,7 +337,7 @@ implements
@Override
public boolean equals(Object that) {
if (that instanceof QOM.BitAndAgg) { QOM.BitAndAgg<?> o = (QOM.BitAndAgg<?>) that;
if (that instanceof QOM.BitAndAgg<?> o) {
return
StringUtils.equals($value(), o.$value())
;

View File

@ -507,7 +507,7 @@ implements
@Override
public boolean equals(Object that) {
if (that instanceof QOM.BitCount) { QOM.BitCount o = (QOM.BitCount) that;
if (that instanceof QOM.BitCount o) {
return
StringUtils.equals($value(), o.$value())
;

View File

@ -225,7 +225,7 @@ implements
@Override
public boolean equals(Object that) {
if (that instanceof QOM.BitLength) { QOM.BitLength o = (QOM.BitLength) that;
if (that instanceof QOM.BitLength o) {
return
StringUtils.equals($string(), o.$string())
;

View File

@ -151,7 +151,7 @@ implements
@Override
public boolean equals(Object that) {
if (that instanceof QOM.BitNand) { QOM.BitNand<?> o = (QOM.BitNand<?>) that;
if (that instanceof QOM.BitNand<?> o) {
return
StringUtils.equals($arg1(), o.$arg1()) &&
StringUtils.equals($arg2(), o.$arg2())

View File

@ -148,7 +148,7 @@ implements
@Override
public boolean equals(Object that) {
if (that instanceof QOM.BitNandAgg) { QOM.BitNandAgg<?> o = (QOM.BitNandAgg<?>) that;
if (that instanceof QOM.BitNandAgg<?> o) {
return
StringUtils.equals($value(), o.$value())
;

View File

@ -151,7 +151,7 @@ implements
@Override
public boolean equals(Object that) {
if (that instanceof QOM.BitNor) { QOM.BitNor<?> o = (QOM.BitNor<?>) that;
if (that instanceof QOM.BitNor<?> o) {
return
StringUtils.equals($arg1(), o.$arg1()) &&
StringUtils.equals($arg2(), o.$arg2())

View File

@ -148,7 +148,7 @@ implements
@Override
public boolean equals(Object that) {
if (that instanceof QOM.BitNorAgg) { QOM.BitNorAgg<?> o = (QOM.BitNorAgg<?>) that;
if (that instanceof QOM.BitNorAgg<?> o) {
return
StringUtils.equals($value(), o.$value())
;

View File

@ -182,7 +182,7 @@ implements
@Override
public boolean equals(Object that) {
if (that instanceof QOM.BitNot) { QOM.BitNot<?> o = (QOM.BitNot<?>) that;
if (that instanceof QOM.BitNot<?> o) {
return
StringUtils.equals($arg1(), o.$arg1())
;

View File

@ -203,7 +203,7 @@ implements
@Override
public boolean equals(Object that) {
if (that instanceof QOM.BitOr) { QOM.BitOr<?> o = (QOM.BitOr<?>) that;
if (that instanceof QOM.BitOr<?> o) {
return
StringUtils.equals($arg1(), o.$arg1()) &&
StringUtils.equals($arg2(), o.$arg2())

Some files were not shown because too many files have changed in this diff Show More