Skip to content

Commit cc29db4

Browse files
committed
Polishing
1 parent 90b93ff commit cc29db4

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

spring-expression/src/main/java/org/springframework/expression/spel/ast/PropertyOrFieldReference.java

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ public ValueRef getValueRef(ExpressionState state) throws EvaluationException {
7878

7979
@Override
8080
public TypedValue getValueInternal(ExpressionState state) throws EvaluationException {
81-
TypedValue tv = getValueInternal(state.getActiveContextObject(), state.getEvaluationContext(), state.getConfiguration().isAutoGrowNullReferences());
81+
TypedValue tv = getValueInternal(state.getActiveContextObject(), state.getEvaluationContext(),
82+
state.getConfiguration().isAutoGrowNullReferences());
8283
if (this.cachedReadAccessor instanceof CompilablePropertyAccessor) {
8384
CompilablePropertyAccessor accessor = (CompilablePropertyAccessor) this.cachedReadAccessor;
8485
this.exitTypeDescriptor = CodeFlow.toDescriptor(accessor.getPropertyType());
@@ -100,7 +101,7 @@ private TypedValue getValueInternal(TypedValue contextObject, EvaluationContext
100101
// Create a new collection or map ready for the indexer
101102
if (resultDescriptor.getType().equals(List.class)) {
102103
try {
103-
if (isWritableProperty(this.name,contextObject,eContext)) {
104+
if (isWritableProperty(this.name, contextObject,eContext)) {
104105
List<?> newList = ArrayList.class.newInstance();
105106
writeProperty(contextObject, eContext, this.name, newList);
106107
result = readProperty(contextObject, eContext, this.name);
@@ -156,12 +157,12 @@ private TypedValue getValueInternal(TypedValue contextObject, EvaluationContext
156157
}
157158

158159
@Override
159-
public void setValue(ExpressionState state, Object newValue) throws SpelEvaluationException {
160+
public void setValue(ExpressionState state, Object newValue) throws EvaluationException {
160161
writeProperty(state.getActiveContextObject(), state.getEvaluationContext(), this.name, newValue);
161162
}
162163

163164
@Override
164-
public boolean isWritable(ExpressionState state) throws SpelEvaluationException {
165+
public boolean isWritable(ExpressionState state) throws EvaluationException {
165166
return isWritableProperty(this.name, state.getActiveContextObject(), state.getEvaluationContext());
166167
}
167168

@@ -173,9 +174,11 @@ public String toStringAST() {
173174
/**
174175
* Attempt to read the named property from the current context object.
175176
* @return the value of the property
176-
* @throws SpelEvaluationException if any problem accessing the property or it cannot be found
177+
* @throws EvaluationException if any problem accessing the property or it cannot be found
177178
*/
178-
private TypedValue readProperty(TypedValue contextObject, EvaluationContext eContext, String name) throws EvaluationException {
179+
private TypedValue readProperty(TypedValue contextObject, EvaluationContext eContext, String name)
180+
throws EvaluationException {
181+
179182
Object targetObject = contextObject.getValue();
180183
if (targetObject == null && this.nullSafe) {
181184
return TypedValue.NULL;
@@ -193,7 +196,8 @@ private TypedValue readProperty(TypedValue contextObject, EvaluationContext eCon
193196
}
194197
}
195198

196-
List<PropertyAccessor> accessorsToTry = getPropertyAccessorsToTry(contextObject.getValue(), eContext.getPropertyAccessors());
199+
List<PropertyAccessor> accessorsToTry =
200+
getPropertyAccessorsToTry(contextObject.getValue(), eContext.getPropertyAccessors());
197201
// Go through the accessors that may be able to resolve it. If they are a cacheable accessor then
198202
// get the accessor and use it. If they are not cacheable but report they can read the property
199203
// then ask them to read it
@@ -223,7 +227,9 @@ private TypedValue readProperty(TypedValue contextObject, EvaluationContext eCon
223227
}
224228
}
225229

226-
private void writeProperty(TypedValue contextObject, EvaluationContext eContext, String name, Object newValue) throws SpelEvaluationException {
230+
private void writeProperty(TypedValue contextObject, EvaluationContext eContext, String name, Object newValue)
231+
throws EvaluationException {
232+
227233
if (contextObject.getValue() == null && this.nullSafe) {
228234
return;
229235
}
@@ -241,7 +247,8 @@ private void writeProperty(TypedValue contextObject, EvaluationContext eContext,
241247
}
242248
}
243249

244-
List<PropertyAccessor> accessorsToTry = getPropertyAccessorsToTry(contextObject.getValue(), eContext.getPropertyAccessors());
250+
List<PropertyAccessor> accessorsToTry =
251+
getPropertyAccessorsToTry(contextObject.getValue(), eContext.getPropertyAccessors());
245252
if (accessorsToTry != null) {
246253
try {
247254
for (PropertyAccessor accessor : accessorsToTry) {
@@ -266,8 +273,11 @@ private void writeProperty(TypedValue contextObject, EvaluationContext eContext,
266273
}
267274
}
268275

269-
public boolean isWritableProperty(String name, TypedValue contextObject, EvaluationContext eContext) throws SpelEvaluationException {
270-
List<PropertyAccessor> accessorsToTry = getPropertyAccessorsToTry(contextObject.getValue(), eContext.getPropertyAccessors());
276+
public boolean isWritableProperty(String name, TypedValue contextObject, EvaluationContext eContext)
277+
throws EvaluationException {
278+
279+
List<PropertyAccessor> accessorsToTry =
280+
getPropertyAccessorsToTry(contextObject.getValue(), eContext.getPropertyAccessors());
271281
if (accessorsToTry != null) {
272282
for (PropertyAccessor accessor : accessorsToTry) {
273283
try {
@@ -360,8 +370,8 @@ public AccessorLValue(PropertyOrFieldReference propertyOrFieldReference, TypedVa
360370
@Override
361371
public TypedValue getValue() {
362372
TypedValue value = this.ref.getValueInternal(this.contextObject, this.eContext, this.autoGrowNullReferences);
363-
if (ref.cachedReadAccessor instanceof CompilablePropertyAccessor) {
364-
CompilablePropertyAccessor accessor = (CompilablePropertyAccessor)this.ref.cachedReadAccessor;
373+
if (this.ref.cachedReadAccessor instanceof CompilablePropertyAccessor) {
374+
CompilablePropertyAccessor accessor = (CompilablePropertyAccessor) this.ref.cachedReadAccessor;
365375
this.ref.exitTypeDescriptor = CodeFlow.toDescriptor(accessor.getPropertyType());
366376
}
367377
return value;

0 commit comments

Comments
 (0)