Polishing
This commit is contained in:
parent
4ec4e93ece
commit
dcbc2ef134
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2023 the original author or authors.
|
* Copyright 2002-2024 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -23,8 +23,8 @@ import org.springframework.util.Assert;
|
||||||
import org.springframework.util.ObjectUtils;
|
import org.springframework.util.ObjectUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represent an {@link AnnotatedElement} on a particular {@link Class}
|
* Represents an {@link AnnotatedElement} in a particular {@link Class}
|
||||||
* and is suitable as a key.
|
* and is suitable for use as a cache key.
|
||||||
*
|
*
|
||||||
* @author Costin Leau
|
* @author Costin Leau
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2023 the original author or authors.
|
* Copyright 2002-2024 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -24,11 +24,10 @@ import org.springframework.expression.Expression;
|
||||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.ObjectUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shared utility class used to evaluate and cache SpEL expressions that
|
* Shared utility class used to evaluate and cache SpEL expressions that
|
||||||
* are defined on {@link java.lang.reflect.AnnotatedElement}.
|
* are defined on an {@link java.lang.reflect.AnnotatedElement AnnotatedElement}.
|
||||||
*
|
*
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
* @since 4.2
|
* @since 4.2
|
||||||
|
|
@ -41,6 +40,13 @@ public abstract class CachedExpressionEvaluator {
|
||||||
private final ParameterNameDiscoverer parameterNameDiscoverer = new DefaultParameterNameDiscoverer();
|
private final ParameterNameDiscoverer parameterNameDiscoverer = new DefaultParameterNameDiscoverer();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new instance with the default {@link SpelExpressionParser}.
|
||||||
|
*/
|
||||||
|
protected CachedExpressionEvaluator() {
|
||||||
|
this(new SpelExpressionParser());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance with the specified {@link SpelExpressionParser}.
|
* Create a new instance with the specified {@link SpelExpressionParser}.
|
||||||
*/
|
*/
|
||||||
|
|
@ -49,13 +55,6 @@ public abstract class CachedExpressionEvaluator {
|
||||||
this.parser = parser;
|
this.parser = parser;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new instance with a default {@link SpelExpressionParser}.
|
|
||||||
*/
|
|
||||||
protected CachedExpressionEvaluator() {
|
|
||||||
this(new SpelExpressionParser());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the {@link SpelExpressionParser} to use.
|
* Return the {@link SpelExpressionParser} to use.
|
||||||
|
|
@ -72,12 +71,13 @@ public abstract class CachedExpressionEvaluator {
|
||||||
return this.parameterNameDiscoverer;
|
return this.parameterNameDiscoverer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the {@link Expression} for the specified SpEL value
|
* Return the parsed {@link Expression} for the specified SpEL expression.
|
||||||
* <p>{@link #parseExpression(String) Parse the expression} if it hasn't been already.
|
* <p>{@linkplain #parseExpression(String) Parses} the expression if it hasn't
|
||||||
|
* already been parsed and cached.
|
||||||
* @param cache the cache to use
|
* @param cache the cache to use
|
||||||
* @param elementKey the element on which the expression is defined
|
* @param elementKey the {@code AnnotatedElementKey} containing the element
|
||||||
|
* on which the expression is defined
|
||||||
* @param expression the expression to parse
|
* @param expression the expression to parse
|
||||||
*/
|
*/
|
||||||
protected Expression getExpression(Map<ExpressionKey, Expression> cache,
|
protected Expression getExpression(Map<ExpressionKey, Expression> cache,
|
||||||
|
|
@ -125,8 +125,7 @@ public abstract class CachedExpressionEvaluator {
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(@Nullable Object other) {
|
public boolean equals(@Nullable Object other) {
|
||||||
return (this == other || (other instanceof ExpressionKey that &&
|
return (this == other || (other instanceof ExpressionKey that &&
|
||||||
this.element.equals(that.element) &&
|
this.element.equals(that.element) && this.expression.equals(that.expression)));
|
||||||
ObjectUtils.nullSafeEquals(this.expression, that.expression)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ import org.springframework.lang.Nullable;
|
||||||
public class SpelParserConfiguration {
|
public class SpelParserConfiguration {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default maximum length permitted for a SpEL expression.
|
* Default maximum length permitted for a SpEL expression: {@value}.
|
||||||
* @since 5.2.24
|
* @since 5.2.24
|
||||||
*/
|
*/
|
||||||
public static final int DEFAULT_MAX_EXPRESSION_LENGTH = 10_000;
|
public static final int DEFAULT_MAX_EXPRESSION_LENGTH = 10_000;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue