[jOOQ/jOOQ#13093] Remove a few redundant null checks in jOOQ's internals
This commit is contained in:
parent
8b43ac89be
commit
f9c58f9423
@ -827,7 +827,7 @@ implements
|
||||
result = prime * result + length();
|
||||
result = prime * result + precision();
|
||||
result = prime * result + scale();
|
||||
result = prime * result + ((getType() == null) ? 0 : getType().hashCode());
|
||||
result = prime * result + getType().hashCode();
|
||||
result = prime * result + ((tType0() == null) ? 0 : tType0().hashCode());
|
||||
result = prime * result + ((typeName0() == null) ? 0 : typeName0().hashCode());
|
||||
return result;
|
||||
@ -850,11 +850,7 @@ implements
|
||||
return false;
|
||||
if (!eq(scale0(), other.scale0()))
|
||||
return false;
|
||||
if (getType() == null) {
|
||||
if (other.getType() != null)
|
||||
return false;
|
||||
}
|
||||
else if (!getType().equals(other.getType()))
|
||||
if (!getType().equals(other.getType()))
|
||||
return false;
|
||||
if (tType0() == null) {
|
||||
if (other.tType0() != null)
|
||||
|
||||
@ -100,7 +100,7 @@ abstract class AbstractNamed extends AbstractQueryPart implements Named {
|
||||
|
||||
// [#1938] This is a much more efficient hashCode() implementation
|
||||
// compared to that of standard QueryParts
|
||||
return getQualifiedName() == null ? 0 : getQualifiedName().hashCode();
|
||||
return getQualifiedName().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -1833,6 +1833,9 @@ public class DefaultConfiguration extends AbstractConfiguration {
|
||||
@Override
|
||||
@Deprecated
|
||||
public final org.jooq.SchemaMapping schemaMapping() {
|
||||
if (mapping == null)
|
||||
mapping = new org.jooq.SchemaMapping(this);
|
||||
|
||||
return mapping;
|
||||
}
|
||||
|
||||
|
||||
@ -2055,7 +2055,7 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
|
||||
throw expected("FOLLOWING", "PRECEDING");
|
||||
else if (parseKeywordIf("CURRENT ROW"))
|
||||
s4 = s3.andCurrentRow();
|
||||
else if ((n = parseUnsignedIntegerLiteral()) != null)
|
||||
else if (asTrue(n = parseUnsignedIntegerLiteral()))
|
||||
if (parseKeywordIf("PRECEDING"))
|
||||
s4 = s3.andPreceding(n.intValue());
|
||||
else if (parseKeywordIf("FOLLOWING"))
|
||||
@ -2104,7 +2104,7 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
|
||||
: range
|
||||
? s2.rangeCurrentRow()
|
||||
: s2.groupsCurrentRow();
|
||||
else if ((n = parseUnsignedIntegerLiteral()) != null)
|
||||
else if (asTrue(n = parseUnsignedIntegerLiteral()))
|
||||
if (parseKeywordIf("PRECEDING"))
|
||||
s4 = s2 == null
|
||||
? rows
|
||||
@ -14287,6 +14287,11 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
|
||||
return result;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private final boolean asTrue(Object o) {
|
||||
return true;
|
||||
}
|
||||
|
||||
private final String mark() {
|
||||
int[] line = line();
|
||||
return "[" + line[0] + ":" + line[1] + "] "
|
||||
|
||||
@ -43,6 +43,7 @@ import static org.jooq.conf.InvocationOrder.REVERSE;
|
||||
import static org.jooq.impl.RecordDelegate.RecordLifecycleType.LOAD;
|
||||
import static org.jooq.impl.RecordDelegate.RecordLifecycleType.REFRESH;
|
||||
import static org.jooq.impl.Tools.attachRecords;
|
||||
import static org.jooq.impl.Tools.isEmpty;
|
||||
import static org.jooq.impl.Tools.map;
|
||||
|
||||
import java.util.Arrays;
|
||||
@ -108,7 +109,7 @@ final class RecordDelegate<R extends Record> {
|
||||
if (configuration != null) {
|
||||
providers = configuration.recordListenerProviders();
|
||||
|
||||
if (providers != null && providers.length > 0) {
|
||||
if (!isEmpty(providers)) {
|
||||
listeners = map(providers, p -> p.provide(), RecordListener[]::new);
|
||||
ctx = new DefaultRecordContext(configuration, executeType(), record);
|
||||
}
|
||||
|
||||
@ -3207,8 +3207,7 @@ final class Tools {
|
||||
if (mapping == null)
|
||||
mapping = scope.configuration().schemaMapping();
|
||||
|
||||
if (mapping != null)
|
||||
return mapping.map(catalog);
|
||||
return mapping.map(catalog);
|
||||
}
|
||||
|
||||
return catalog;
|
||||
@ -3224,8 +3223,7 @@ final class Tools {
|
||||
if (mapping == null)
|
||||
mapping = scope.configuration().schemaMapping();
|
||||
|
||||
if (mapping != null)
|
||||
return mapping.map(schema);
|
||||
return mapping.map(schema);
|
||||
}
|
||||
|
||||
return schema;
|
||||
@ -3241,8 +3239,7 @@ final class Tools {
|
||||
if (mapping == null)
|
||||
mapping = scope.configuration().schemaMapping();
|
||||
|
||||
if (mapping != null)
|
||||
return mapping.map(table);
|
||||
return mapping.map(table);
|
||||
}
|
||||
|
||||
return table;
|
||||
@ -5548,8 +5545,7 @@ final class Tools {
|
||||
private static final DataType<String> emulateEnumType(DataType<? extends EnumType> type, EnumType[] enums) {
|
||||
int length = 0;
|
||||
for (EnumType e : enums)
|
||||
if (e.getLiteral() != null)
|
||||
length = Math.max(length, e.getLiteral().length());
|
||||
length = Math.max(length, e.getLiteral().length());
|
||||
|
||||
return VARCHAR(length).nullability(type.nullability()).defaultValue((Field) type.defaultValue());
|
||||
}
|
||||
|
||||
@ -235,7 +235,7 @@ final class VersionImpl extends AbstractNode<Version> implements Version {
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((id() == null) ? 0 : id().hashCode());
|
||||
result = prime * result + id().hashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -248,11 +248,7 @@ final class VersionImpl extends AbstractNode<Version> implements Version {
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
VersionImpl other = (VersionImpl) obj;
|
||||
if (id() == null) {
|
||||
if (other.id() != null)
|
||||
return false;
|
||||
}
|
||||
else if (!id().equals(other.id()))
|
||||
if (!id().equals(other.id()))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user