Fix overridden methods nullability
Issue: SPR-15869
This commit is contained in:
@@ -76,6 +76,7 @@ public class CompositeStringExpression implements Expression {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public <T> T getValue(@Nullable Class<T> expectedResultType) throws EvaluationException {
|
||||
Object value = getValue();
|
||||
return ExpressionUtils.convertTypedValue(null, new TypedValue(value), expectedResultType);
|
||||
@@ -94,6 +95,7 @@ public class CompositeStringExpression implements Expression {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public <T> T getValue(Object rootObject, @Nullable Class<T> desiredResultType) throws EvaluationException {
|
||||
Object value = getValue(rootObject);
|
||||
return ExpressionUtils.convertTypedValue(null, new TypedValue(value), desiredResultType);
|
||||
@@ -112,6 +114,7 @@ public class CompositeStringExpression implements Expression {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public <T> T getValue(EvaluationContext context, @Nullable Class<T> expectedResultType)
|
||||
throws EvaluationException {
|
||||
|
||||
@@ -132,6 +135,7 @@ public class CompositeStringExpression implements Expression {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public <T> T getValue(EvaluationContext context, Object rootObject, @Nullable Class<T> desiredResultType)
|
||||
throws EvaluationException {
|
||||
|
||||
|
||||
@@ -60,6 +60,7 @@ public class LiteralExpression implements Expression {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public <T> T getValue(@Nullable Class<T> expectedResultType) throws EvaluationException {
|
||||
Object value = getValue();
|
||||
return ExpressionUtils.convertTypedValue(null, new TypedValue(value), expectedResultType);
|
||||
@@ -71,6 +72,7 @@ public class LiteralExpression implements Expression {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public <T> T getValue(Object rootObject, @Nullable Class<T> desiredResultType) throws EvaluationException {
|
||||
Object value = getValue(rootObject);
|
||||
return ExpressionUtils.convertTypedValue(null, new TypedValue(value), desiredResultType);
|
||||
@@ -82,6 +84,7 @@ public class LiteralExpression implements Expression {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public <T> T getValue(EvaluationContext context, @Nullable Class<T> expectedResultType)
|
||||
throws EvaluationException {
|
||||
|
||||
@@ -95,6 +98,7 @@ public class LiteralExpression implements Expression {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public <T> T getValue(EvaluationContext context, Object rootObject, @Nullable Class<T> desiredResultType)
|
||||
throws EvaluationException {
|
||||
|
||||
|
||||
@@ -104,6 +104,7 @@ public abstract class SpelNodeImpl implements SpelNode, Opcodes {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public final Object getValue(ExpressionState expressionState) throws EvaluationException {
|
||||
return getValueInternal(expressionState).getValue();
|
||||
}
|
||||
@@ -136,6 +137,7 @@ public abstract class SpelNodeImpl implements SpelNode, Opcodes {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Class<?> getObjectClass(@Nullable Object obj) {
|
||||
if (obj == null) {
|
||||
return null;
|
||||
|
||||
@@ -114,6 +114,7 @@ public class SpelExpression implements Expression {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Object getValue() throws EvaluationException {
|
||||
if (this.compiledAst != null) {
|
||||
try {
|
||||
@@ -143,6 +144,7 @@ public class SpelExpression implements Expression {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
@Nullable
|
||||
public <T> T getValue(@Nullable Class<T> expectedResultType) throws EvaluationException {
|
||||
if (this.compiledAst != null) {
|
||||
try {
|
||||
@@ -179,6 +181,7 @@ public class SpelExpression implements Expression {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Object getValue(Object rootObject) throws EvaluationException {
|
||||
if (this.compiledAst != null) {
|
||||
try {
|
||||
@@ -206,6 +209,7 @@ public class SpelExpression implements Expression {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
@Nullable
|
||||
public <T> T getValue(Object rootObject, @Nullable Class<T> expectedResultType) throws EvaluationException {
|
||||
if (this.compiledAst != null) {
|
||||
try {
|
||||
@@ -240,6 +244,7 @@ public class SpelExpression implements Expression {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Object getValue(EvaluationContext context) throws EvaluationException {
|
||||
Assert.notNull(context, "EvaluationContext is required");
|
||||
|
||||
@@ -269,6 +274,7 @@ public class SpelExpression implements Expression {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
@Nullable
|
||||
public <T> T getValue(EvaluationContext context, @Nullable Class<T> expectedResultType) throws EvaluationException {
|
||||
Assert.notNull(context, "EvaluationContext is required");
|
||||
|
||||
@@ -303,6 +309,7 @@ public class SpelExpression implements Expression {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Object getValue(EvaluationContext context, Object rootObject) throws EvaluationException {
|
||||
Assert.notNull(context, "EvaluationContext is required");
|
||||
|
||||
@@ -331,6 +338,7 @@ public class SpelExpression implements Expression {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
@Nullable
|
||||
public <T> T getValue(EvaluationContext context, Object rootObject, @Nullable Class<T> expectedResultType)
|
||||
throws EvaluationException {
|
||||
|
||||
@@ -366,16 +374,19 @@ public class SpelExpression implements Expression {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Class<?> getValueType() throws EvaluationException {
|
||||
return getValueType(getEvaluationContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Class<?> getValueType(Object rootObject) throws EvaluationException {
|
||||
return getValueType(getEvaluationContext(), rootObject);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Class<?> getValueType(EvaluationContext context) throws EvaluationException {
|
||||
Assert.notNull(context, "EvaluationContext is required");
|
||||
ExpressionState expressionState = new ExpressionState(context, this.configuration);
|
||||
@@ -384,6 +395,7 @@ public class SpelExpression implements Expression {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Class<?> getValueType(EvaluationContext context, Object rootObject) throws EvaluationException {
|
||||
ExpressionState expressionState = new ExpressionState(context, toTypedValue(rootObject), this.configuration);
|
||||
TypeDescriptor typeDescriptor = this.ast.getValueInternal(expressionState).getTypeDescriptor();
|
||||
@@ -391,11 +403,13 @@ public class SpelExpression implements Expression {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public TypeDescriptor getValueTypeDescriptor() throws EvaluationException {
|
||||
return getValueTypeDescriptor(getEvaluationContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public TypeDescriptor getValueTypeDescriptor(Object rootObject) throws EvaluationException {
|
||||
ExpressionState expressionState =
|
||||
new ExpressionState(getEvaluationContext(), toTypedValue(rootObject), this.configuration);
|
||||
@@ -403,6 +417,7 @@ public class SpelExpression implements Expression {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public TypeDescriptor getValueTypeDescriptor(EvaluationContext context) throws EvaluationException {
|
||||
Assert.notNull(context, "EvaluationContext is required");
|
||||
ExpressionState expressionState = new ExpressionState(context, this.configuration);
|
||||
@@ -410,6 +425,7 @@ public class SpelExpression implements Expression {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public TypeDescriptor getValueTypeDescriptor(EvaluationContext context, Object rootObject)
|
||||
throws EvaluationException {
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.springframework.expression.ConstructorResolver;
|
||||
import org.springframework.expression.EvaluationContext;
|
||||
import org.springframework.expression.EvaluationException;
|
||||
import org.springframework.expression.TypeConverter;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* A constructor resolver that uses reflection to locate the constructor that should be invoked.
|
||||
@@ -49,6 +50,7 @@ public class ReflectiveConstructorResolver implements ConstructorResolver {
|
||||
* </ol>
|
||||
*/
|
||||
@Override
|
||||
@Nullable
|
||||
public ConstructorExecutor resolve(EvaluationContext context, String typeName, List<TypeDescriptor> argumentTypes)
|
||||
throws AccessException {
|
||||
|
||||
|
||||
@@ -103,6 +103,7 @@ public class ReflectiveMethodResolver implements MethodResolver {
|
||||
* </ol>
|
||||
*/
|
||||
@Override
|
||||
@Nullable
|
||||
public MethodExecutor resolve(EvaluationContext context, Object targetObject, String name,
|
||||
List<TypeDescriptor> argumentTypes) throws AccessException {
|
||||
|
||||
|
||||
@@ -84,6 +84,7 @@ public class ReflectivePropertyAccessor implements PropertyAccessor {
|
||||
* Returns {@code null} which means this is a general purpose accessor.
|
||||
*/
|
||||
@Override
|
||||
@Nullable
|
||||
public Class<?>[] getSpecificTargetClasses() {
|
||||
return null;
|
||||
}
|
||||
@@ -590,6 +591,7 @@ public class ReflectivePropertyAccessor implements PropertyAccessor {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Class<?>[] getSpecificTargetClasses() {
|
||||
throw new UnsupportedOperationException("Should not be called on an OptimalPropertyAccessor");
|
||||
}
|
||||
|
||||
@@ -222,6 +222,7 @@ public class StandardEvaluationContext implements EvaluationContext {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Object lookupVariable(String name) {
|
||||
return this.variables.get(name);
|
||||
}
|
||||
|
||||
@@ -63,6 +63,7 @@ public class StandardTypeConverter implements TypeConverter {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Object convertValue(@Nullable Object value, @Nullable TypeDescriptor sourceType, TypeDescriptor targetType) {
|
||||
try {
|
||||
return this.conversionService.convert(value, sourceType, targetType);
|
||||
|
||||
Reference in New Issue
Block a user