Simplify if-statements with instanceof checks
Closes gh-25449
This commit is contained in:
parent
c7f44ff671
commit
3b12beb1b8
|
@ -469,7 +469,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
|
|||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (other == null || !(other instanceof TestBean)) {
|
||||
if (!(other instanceof TestBean)) {
|
||||
return false;
|
||||
}
|
||||
TestBean tb2 = (TestBean) other;
|
||||
|
|
|
@ -63,7 +63,7 @@ class TypeHelper {
|
|||
if (type instanceof DeclaredType) {
|
||||
DeclaredType declaredType = (DeclaredType) type;
|
||||
Element enclosingElement = declaredType.asElement().getEnclosingElement();
|
||||
if (enclosingElement != null && enclosingElement instanceof TypeElement) {
|
||||
if (enclosingElement instanceof TypeElement) {
|
||||
return getQualifiedName(enclosingElement) + "$" + declaredType.asElement().getSimpleName().toString();
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -223,7 +223,7 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria
|
|||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object other) {
|
||||
return (this == other || other instanceof SpringCacheAnnotationParser);
|
||||
return (other instanceof SpringCacheAnnotationParser);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -62,7 +62,7 @@ public class OperatorInstanceof extends Operator {
|
|||
Object leftValue = left.getValue();
|
||||
Object rightValue = right.getValue();
|
||||
BooleanTypedValue result;
|
||||
if (rightValue == null || !(rightValue instanceof Class)) {
|
||||
if (!(rightValue instanceof Class)) {
|
||||
throw new SpelEvaluationException(getRightOperand().getStartPosition(),
|
||||
SpelMessage.INSTANCEOF_OPERATOR_NEEDS_CLASS_OPERAND,
|
||||
(rightValue == null ? "null" : rightValue.getClass().getName()));
|
||||
|
|
|
@ -181,7 +181,7 @@ public abstract class AbstractGenericWebContextLoader extends AbstractContextLoa
|
|||
|
||||
// If the WebApplicationContext has no parent or the parent is not a WebApplicationContext,
|
||||
// set the current context as the root WebApplicationContext:
|
||||
if (parent == null || (!(parent instanceof WebApplicationContext))) {
|
||||
if (!(parent instanceof WebApplicationContext)) {
|
||||
String resourceBasePath = webMergedConfig.getResourceBasePath();
|
||||
ResourceLoader resourceLoader = (resourceBasePath.startsWith(ResourceLoader.CLASSPATH_URL_PREFIX) ?
|
||||
new DefaultResourceLoader() : new FileSystemResourceLoader());
|
||||
|
|
|
@ -61,7 +61,7 @@ public class Ejb3TransactionAnnotationParser implements TransactionAnnotationPar
|
|||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object other) {
|
||||
return (this == other || other instanceof Ejb3TransactionAnnotationParser);
|
||||
return (other instanceof Ejb3TransactionAnnotationParser);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -82,7 +82,7 @@ public class JtaTransactionAnnotationParser implements TransactionAnnotationPars
|
|||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object other) {
|
||||
return (this == other || other instanceof JtaTransactionAnnotationParser);
|
||||
return (other instanceof JtaTransactionAnnotationParser);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -104,7 +104,7 @@ public class SpringTransactionAnnotationParser implements TransactionAnnotationP
|
|||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object other) {
|
||||
return (this == other || other instanceof SpringTransactionAnnotationParser);
|
||||
return (other instanceof SpringTransactionAnnotationParser);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -167,8 +167,7 @@ public class PathPattern implements Comparable<PathPattern> {
|
|||
if (elem instanceof CaptureTheRestPathElement || elem instanceof WildcardTheRestPathElement) {
|
||||
this.catchAll = true;
|
||||
}
|
||||
if (elem instanceof SeparatorPathElement && elem.next != null &&
|
||||
elem.next instanceof WildcardPathElement && elem.next.next == null) {
|
||||
if (elem instanceof SeparatorPathElement && elem.next instanceof WildcardPathElement && elem.next.next == null) {
|
||||
this.endsWithSeparatorWildcard = true;
|
||||
}
|
||||
elem = elem.next;
|
||||
|
|
|
@ -96,7 +96,7 @@ public class WebSocketMessageBrokerStats {
|
|||
}
|
||||
}
|
||||
SubProtocolHandler defaultHandler = this.webSocketHandler.getDefaultProtocolHandler();
|
||||
if (defaultHandler != null && defaultHandler instanceof StompSubProtocolHandler) {
|
||||
if (defaultHandler instanceof StompSubProtocolHandler) {
|
||||
return (StompSubProtocolHandler) defaultHandler;
|
||||
}
|
||||
return null;
|
||||
|
|
Loading…
Reference in New Issue