CollectionUtils.lastElement for common Set/List extraction
Issue: SPR-16374
This commit is contained in:
@@ -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.
|
||||
@@ -26,6 +26,7 @@ import org.springframework.asm.ClassWriter;
|
||||
import org.springframework.asm.MethodVisitor;
|
||||
import org.springframework.asm.Opcodes;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
/**
|
||||
* Manages the class being generated by the compilation process.
|
||||
@@ -153,10 +154,7 @@ public class CodeFlow implements Opcodes {
|
||||
*/
|
||||
@Nullable
|
||||
public String lastDescriptor() {
|
||||
if (this.compilationScopes.peek().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return this.compilationScopes.peek().get(this.compilationScopes.peek().size() - 1);
|
||||
return CollectionUtils.lastElement(this.compilationScopes.peek());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -31,6 +31,7 @@ import org.springframework.expression.spel.SpelEvaluationException;
|
||||
import org.springframework.expression.spel.SpelMessage;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
@@ -160,7 +161,7 @@ public class Selection extends SpelNodeImpl {
|
||||
}
|
||||
|
||||
if (this.variant == LAST) {
|
||||
return new ValueRef.TypedValueHolderValueRef(new TypedValue(result.get(result.size() - 1)), this);
|
||||
return new ValueRef.TypedValueHolderValueRef(new TypedValue(CollectionUtils.lastElement(result)), this);
|
||||
}
|
||||
|
||||
if (operand instanceof Iterable) {
|
||||
|
||||
Reference in New Issue
Block a user