From d6e0c94e32b3880a61dfe3cdedea65b88d36113b Mon Sep 17 00:00:00 2001 From: Khaled Yakdan Date: Wed, 19 Oct 2022 06:56:00 +0200 Subject: [PATCH] Fix Checkstyle and PMD errors --- .../apache/commons/jxpath/ri/JXPathClassFilter.java | 2 +- .../org/apache/commons/jxpath/ri/JXPathFilter.java | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/apache/commons/jxpath/ri/JXPathClassFilter.java b/src/main/java/org/apache/commons/jxpath/ri/JXPathClassFilter.java index d5a37f3b1..1367bf40b 100644 --- a/src/main/java/org/apache/commons/jxpath/ri/JXPathClassFilter.java +++ b/src/main/java/org/apache/commons/jxpath/ri/JXPathClassFilter.java @@ -37,5 +37,5 @@ public interface JXPathClassFilter { * passed. * @return true if the java class can be exposed via xpath, false otherwise */ - public boolean exposeToXPath(String className); + boolean exposeToXPath(String className); } diff --git a/src/main/java/org/apache/commons/jxpath/ri/JXPathFilter.java b/src/main/java/org/apache/commons/jxpath/ri/JXPathFilter.java index 3192f85b8..bba8d900e 100644 --- a/src/main/java/org/apache/commons/jxpath/ri/JXPathFilter.java +++ b/src/main/java/org/apache/commons/jxpath/ri/JXPathFilter.java @@ -30,7 +30,7 @@ * @version $Revision$ $Date$ */ public class JXPathFilter implements JXPathClassFilter { - Set allowedClassesList = null; + private Set allowedClassesList = null; public JXPathFilter() { init(); @@ -39,7 +39,7 @@ public JXPathFilter() { public void init() { String restrictedClasses = System.getProperty("jxpath.class.allow"); allowedClassesList = null; - if ((restrictedClasses != null) && (restrictedClasses.trim().length() > 0)) { + if (restrictedClasses != null && restrictedClasses.trim().length() > 0) { allowedClassesList = new HashSet<>(); allowedClassesList.addAll(Arrays.asList(restrictedClasses.split(","))); } @@ -54,15 +54,11 @@ public void init() { */ @Override public boolean exposeToXPath(String className) { - if ((allowedClassesList == null) || (allowedClassesList.size() < 1)) { + if (allowedClassesList == null || allowedClassesList.size() < 1) { return false; } - if (allowedClassesList.contains(className) || allowedClassesList.contains("*")) { - return true; - } - - return false; + return allowedClassesList.contains(className) || allowedClassesList.contains("*"); } }