This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-jexl.git
The following commit(s) were added to refs/heads/master by this push: new 0b048dd7 Use modern Map API 0b048dd7 is described below commit 0b048dd7293128c2b1923fda5d4e3bee27762577 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Sat Jul 8 08:29:10 2023 -0400 Use modern Map API --- .../commons/jexl3/internal/introspection/Permissions.java | 3 +-- .../commons/jexl3/internal/introspection/Uberspect.java | 12 +++++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/apache/commons/jexl3/internal/introspection/Permissions.java b/src/main/java/org/apache/commons/jexl3/internal/introspection/Permissions.java index 5d64429d..1de7ca29 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/introspection/Permissions.java +++ b/src/main/java/org/apache/commons/jexl3/internal/introspection/Permissions.java @@ -259,8 +259,7 @@ public class Permissions implements JexlPermissions { * @return the package constraints instance, not-null. */ private NoJexlPackage getNoJexlPackage(final String packageName) { - final NoJexlPackage njp = packages.get(packageName); - return njp != null ? njp : JEXL_PACKAGE; + return packages.getOrDefault(packageName, JEXL_PACKAGE); } /** diff --git a/src/main/java/org/apache/commons/jexl3/internal/introspection/Uberspect.java b/src/main/java/org/apache/commons/jexl3/internal/introspection/Uberspect.java index c349a59d..57dc7ad3 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/introspection/Uberspect.java +++ b/src/main/java/org/apache/commons/jexl3/internal/introspection/Uberspect.java @@ -448,9 +448,8 @@ public class Uberspect implements JexlUberspect { JexlArithmetic.Uberspect jau = null; if (arithmetic != null) { final Class<? extends JexlArithmetic> aclass = arithmetic.getClass(); - Set<JexlOperator> ops = operatorMap.get(aclass); - if (ops == null) { - ops = EnumSet.noneOf(JexlOperator.class); + Set<JexlOperator> ops = operatorMap.computeIfAbsent(aclass, k -> { + Set<JexlOperator> newOps = EnumSet.noneOf(JexlOperator.class); // deal only with derived classes if (!JexlArithmetic.class.equals(aclass)) { for (final JexlOperator op : JexlOperator.values()) { @@ -469,16 +468,15 @@ public class Uberspect implements JexlUberspect { JexlArithmetic.class.getMethod(method.getName(), method.getParameterTypes()); } catch (final NoSuchMethodException xmethod) { // method was not found in JexlArithmetic; this is an operator definition - ops.add(op); + newOps.add(op); } } } } } } - // register this arithmetic class in the operator map - operatorMap.put(aclass, ops); - } + return newOps; + }); jau = new ArithmeticUberspect(arithmetic, ops); } return jau;