Nullability refinements (based on IntelliJ IDEA 2018.1 introspection)
Issue: SPR-15756
This commit is contained in:
@@ -58,7 +58,7 @@ public class CodeFlow implements Opcodes {
|
||||
* sub-expressions like the expressions for the argument values in a method invocation
|
||||
* expression.
|
||||
*/
|
||||
private final Deque<ArrayList<String>> compilationScopes;
|
||||
private final Deque<List<String>> compilationScopes;
|
||||
|
||||
/**
|
||||
* As SpEL ast nodes are called to generate code for the main evaluation method
|
||||
@@ -128,7 +128,7 @@ public class CodeFlow implements Opcodes {
|
||||
*/
|
||||
public void pushDescriptor(@Nullable String descriptor) {
|
||||
if (descriptor != null) {
|
||||
this.compilationScopes.peek().add(descriptor);
|
||||
this.compilationScopes.element().add(descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ public class ExpressionState {
|
||||
if (CollectionUtils.isEmpty(this.contextObjects)) {
|
||||
return this.rootObject;
|
||||
}
|
||||
return this.contextObjects.peek();
|
||||
return this.contextObjects.element();
|
||||
}
|
||||
|
||||
public void pushActiveContextObject(TypedValue obj) {
|
||||
@@ -136,7 +136,7 @@ public class ExpressionState {
|
||||
if (CollectionUtils.isEmpty(this.scopeRootObjects)) {
|
||||
return this.rootObject;
|
||||
}
|
||||
return this.scopeRootObjects.peek();
|
||||
return this.scopeRootObjects.element();
|
||||
}
|
||||
|
||||
public void setVariable(String name, @Nullable Object value) {
|
||||
@@ -157,8 +157,8 @@ public class ExpressionState {
|
||||
}
|
||||
|
||||
public Object convertValue(Object value, TypeDescriptor targetTypeDescriptor) throws EvaluationException {
|
||||
Object result = this.relatedContext.getTypeConverter().convertValue(value,
|
||||
TypeDescriptor.forObject(value), targetTypeDescriptor);
|
||||
Object result = this.relatedContext.getTypeConverter().convertValue(
|
||||
value, TypeDescriptor.forObject(value), targetTypeDescriptor);
|
||||
if (result == null) {
|
||||
throw new IllegalStateException("Null conversion result for value [" + value + "]");
|
||||
}
|
||||
@@ -172,7 +172,8 @@ public class ExpressionState {
|
||||
@Nullable
|
||||
public Object convertValue(TypedValue value, TypeDescriptor targetTypeDescriptor) throws EvaluationException {
|
||||
Object val = value.getValue();
|
||||
return this.relatedContext.getTypeConverter().convertValue(val, TypeDescriptor.forObject(val), targetTypeDescriptor);
|
||||
return this.relatedContext.getTypeConverter().convertValue(
|
||||
val, TypeDescriptor.forObject(val), targetTypeDescriptor);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -199,7 +200,7 @@ public class ExpressionState {
|
||||
}
|
||||
|
||||
public void setLocalVariable(String name, Object value) {
|
||||
initVariableScopes().peek().setVariable(name, value);
|
||||
initVariableScopes().element().setVariable(name, value);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -212,16 +213,16 @@ public class ExpressionState {
|
||||
return null;
|
||||
}
|
||||
|
||||
private LinkedList<VariableScope> initVariableScopes() {
|
||||
private Deque<VariableScope> initVariableScopes() {
|
||||
if (this.variableScopes == null) {
|
||||
this.variableScopes = new LinkedList<>();
|
||||
// top level empty variable scope
|
||||
// top-level empty variable scope
|
||||
this.variableScopes.add(new VariableScope());
|
||||
}
|
||||
return this.variableScopes;
|
||||
}
|
||||
|
||||
private ArrayDeque<TypedValue> initScopeRootObjects() {
|
||||
private Deque<TypedValue> initScopeRootObjects() {
|
||||
if (this.scopeRootObjects == null) {
|
||||
this.scopeRootObjects = new ArrayDeque<>();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -58,7 +58,7 @@ public interface ValueRef {
|
||||
/**
|
||||
* A ValueRef for the null value.
|
||||
*/
|
||||
static class NullValueRef implements ValueRef {
|
||||
class NullValueRef implements ValueRef {
|
||||
|
||||
static final NullValueRef INSTANCE = new NullValueRef();
|
||||
|
||||
@@ -85,13 +85,13 @@ public interface ValueRef {
|
||||
/**
|
||||
* A ValueRef holder for a single value, which cannot be set.
|
||||
*/
|
||||
static class TypedValueHolderValueRef implements ValueRef {
|
||||
class TypedValueHolderValueRef implements ValueRef {
|
||||
|
||||
private final TypedValue typedValue;
|
||||
|
||||
private final SpelNodeImpl node; // used only for error reporting
|
||||
|
||||
public TypedValueHolderValueRef(TypedValue typedValue,SpelNodeImpl node) {
|
||||
public TypedValueHolderValueRef(TypedValue typedValue, SpelNodeImpl node) {
|
||||
this.typedValue = typedValue;
|
||||
this.node = node;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user