You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bval.apache.org by mb...@apache.org on 2017/05/02 04:53:22 UTC

svn commit: r1793432 [4/5] - in /bval/branches/bv2.x: ./ bval-core/src/main/java/org/apache/bval/ bval-core/src/main/java/org/apache/bval/model/ bval-core/src/main/java/org/apache/bval/routines/ bval-core/src/main/java/org/apache/bval/util/ bval-core/s...

Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/resolver/CachingTraversableResolver.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/resolver/CachingTraversableResolver.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/resolver/CachingTraversableResolver.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/resolver/CachingTraversableResolver.java Tue May  2 04:53:20 2017
@@ -21,6 +21,7 @@ import javax.validation.TraversableResol
 import java.lang.annotation.ElementType;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Objects;
 
 /**
  * Cache results of a delegated traversable resovler to optimize calls
@@ -34,7 +35,7 @@ import java.util.Map;
  */
 public class CachingTraversableResolver implements TraversableResolver, CachingRelevant {
     private TraversableResolver delegate;
-    private Map<CacheEntry, CacheEntry> cache = new HashMap<CacheEntry, CacheEntry>();
+    private Map<CacheEntry, CacheEntry> cache = new HashMap<>();
 
     /**
      * Convenience method to check whether caching is necessary on a given {@link TraversableResolver}.
@@ -61,11 +62,8 @@ public class CachingTraversableResolver
      * @see #needsCaching(TraversableResolver)
      */
     public static TraversableResolver cacheFor(TraversableResolver traversableResolver) {
-        if (needsCaching(traversableResolver)) {
-            return new CachingTraversableResolver(traversableResolver);
-        } else {
-            return traversableResolver;
-        }
+        return needsCaching(traversableResolver) ? new CachingTraversableResolver(traversableResolver)
+            : traversableResolver;
     }
 
     /**
@@ -158,15 +156,14 @@ public class CachingTraversableResolver
             if (this == o) {
                 return true;
             }
-            if (o == null || getClass() != o.getClass()) {
+            if (o == null || !getClass().equals(o.getClass())) {
                 return false;
             }
 
             CacheEntry that = (CacheEntry) o;
 
-            return elementType == that.elementType && path.equals(that.path) && type.equals(that.type)
-                && !(object != null ? !object.equals(that.object) : that.object != null) && node.equals(that.node);
-
+            return elementType == that.elementType && Objects.equals(path, that.path) && Objects.equals(type, that.type)
+                && Objects.equals(object, that.object) && Objects.equals(node, that.node);
         }
 
         /**
@@ -178,12 +175,7 @@ public class CachingTraversableResolver
         }
 
         private int buildHashCode() {
-            int result = object != null ? object.hashCode() : 0;
-            result = 31 * result + node.hashCode();
-            result = 31 * result + type.hashCode();
-            result = 31 * result + path.hashCode();
-            result = 31 * result + elementType.hashCode();
-            return result;
+            return Objects.hash(object, node, type, path, elementType);
         }
     }
-}
\ No newline at end of file
+}

Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/util/ClassHelper.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/util/ClassHelper.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/util/ClassHelper.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/util/ClassHelper.java Tue May  2 04:53:20 2017
@@ -20,7 +20,11 @@ package org.apache.bval.jsr.util;
 
 import java.io.Serializable;
 import java.security.AccessController;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 
 /**
  * Common operations on classes that do not require an {@link AccessController}.
@@ -28,6 +32,7 @@ import java.util.List;
  * @author Carlos Vara
  */
 public class ClassHelper {
+    private static final Set<Class<?>> IGNORED_TYPES = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(null,Object.class,Serializable.class,Cloneable.class)));
 
     private ClassHelper() {
         // No instances please
@@ -42,10 +47,7 @@ public class ClassHelper {
      * @param clazz
      */
     public static List<Class<?>> fillFullClassHierarchyAsList(List<Class<?>> allClasses, Class<?> clazz) {
-        if (clazz == null || clazz == Object.class || clazz == Serializable.class || clazz == Cloneable.class) {
-            return allClasses;
-        }
-        if (allClasses.contains(clazz)) {
+        if (IGNORED_TYPES.contains(clazz) || allClasses.contains(clazz)) {
             return allClasses;
         }
         allClasses.add(clazz);

Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/util/IOs.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/util/IOs.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/util/IOs.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/util/IOs.java Tue May  2 04:53:20 2017
@@ -35,9 +35,6 @@ public class IOs {
         }
 
         // force ByteArrayOutputStream since we close the stream ATM
-        /*if (stream.markSupported()) {
-            return stream;
-        } else {*/
         try {
             final ByteArrayOutputStream baos = new ByteArrayOutputStream();
             final byte[] buffer = new byte[1024];
@@ -49,9 +46,9 @@ public class IOs {
         } catch (final IOException e) {
             throw new RuntimeException(e);
         }
-        /*}*/
     }
 
+    //TODO see if needed
     public static void closeQuietly(Closeable closeable) {
         if (closeable != null) {
             try {

Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/util/LeafNodeBuilderCustomizableContextImpl.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/util/LeafNodeBuilderCustomizableContextImpl.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/util/LeafNodeBuilderCustomizableContextImpl.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/util/LeafNodeBuilderCustomizableContextImpl.java Tue May  2 04:53:20 2017
@@ -21,22 +21,18 @@ package org.apache.bval.jsr.util;
 import org.apache.bval.jsr.ConstraintValidatorContextImpl;
 
 import javax.validation.ConstraintValidatorContext;
-import javax.validation.ElementKind;
 
 public class LeafNodeBuilderCustomizableContextImpl
     implements ConstraintValidatorContext.ConstraintViolationBuilder.LeafNodeBuilderCustomizableContext {
     private final ConstraintValidatorContextImpl context;
     private final PathImpl path;
     private final String template;
-    private final NodeImpl node;
 
     public LeafNodeBuilderCustomizableContextImpl(final ConstraintValidatorContextImpl parent, String messageTemplate,
         PathImpl propertyPath) {
         context = parent;
         template = messageTemplate;
         path = propertyPath;
-        node = new NodeImpl((String) null);
-        node.setKind(ElementKind.BEAN);
     }
 
     @Override

Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/util/NodeBuilderCustomizableContextImpl.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/util/NodeBuilderCustomizableContextImpl.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/util/NodeBuilderCustomizableContextImpl.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/util/NodeBuilderCustomizableContextImpl.java Tue May  2 04:53:20 2017
@@ -45,8 +45,7 @@ final class NodeBuilderCustomizableConte
         parent = contextImpl;
         messageTemplate = template;
         propertyPath = path;
-        node = new NodeImpl(name);
-        node.setKind(ElementKind.PROPERTY);
+        node = new NodeImpl.PropertyNodeImpl(name);
     }
 
     /**
@@ -74,15 +73,13 @@ final class NodeBuilderCustomizableConte
         String name) {
         propertyPath.addNode(node);
         node = new NodeImpl.PropertyNodeImpl(name);
-        node.setKind(ElementKind.PROPERTY);
-        return null;
+        return this;
     }
 
     @Override
     public ConstraintValidatorContext.ConstraintViolationBuilder.LeafNodeBuilderCustomizableContext addBeanNode() {
         propertyPath.addNode(node);
-        node = new NodeImpl((String) null);
-        node.setKind(ElementKind.BEAN);
+        node = new NodeImpl.BeanNodeImpl();
         return new LeafNodeBuilderCustomizableContextImpl(parent, messageTemplate, propertyPath);
     }
 

Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/util/NodeBuilderDefinedContextImpl.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/util/NodeBuilderDefinedContextImpl.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/util/NodeBuilderDefinedContextImpl.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/util/NodeBuilderDefinedContextImpl.java Tue May  2 04:53:20 2017
@@ -61,8 +61,7 @@ public final class NodeBuilderDefinedCon
 
     @Override
     public ConstraintValidatorContext.ConstraintViolationBuilder.LeafNodeBuilderCustomizableContext addBeanNode() {
-        final NodeImpl node = new NodeImpl((String) null);
-        node.setKind(ElementKind.BEAN);
+        final NodeImpl node = new NodeImpl.BeanNodeImpl();
         propertyPath.addNode(node);
         return new LeafNodeBuilderCustomizableContextImpl(parent, messageTemplate, propertyPath);
     }

Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/util/NodeContextBuilderImpl.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/util/NodeContextBuilderImpl.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/util/NodeContextBuilderImpl.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/util/NodeContextBuilderImpl.java Tue May  2 04:53:20 2017
@@ -98,4 +98,4 @@ final class NodeContextBuilderImpl imple
         return parent;
     }
 
-}
\ No newline at end of file
+}

Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/util/NodeImpl.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/util/NodeImpl.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/util/NodeImpl.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/util/NodeImpl.java Tue May  2 04:53:20 2017
@@ -24,13 +24,13 @@ import javax.validation.Path.Node;
 import java.io.Serializable;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 
 public class NodeImpl implements Path.Node, Serializable {
 
     private static final long serialVersionUID = 1L;
     private static final String INDEX_OPEN = "[";
     private static final String INDEX_CLOSE = "]";
-    private List<Class<?>> parameterTypes;
 
     /**
      * Append a Node to the specified StringBuilder.
@@ -85,6 +85,7 @@ public class NodeImpl implements Path.No
     private int parameterIndex;
     private Object key;
     private ElementKind kind;
+    private List<Class<?>> parameterTypes;
 
     /**
      * Create a new NodeImpl instance.
@@ -99,7 +100,7 @@ public class NodeImpl implements Path.No
      * @param node
      */
     NodeImpl(Path.Node node) {
-        this.name = node.getName();
+        this(node.getName());
         this.inIterable = node.isInIterable();
         this.index = node.getIndex();
         this.key = node.getKey();
@@ -213,29 +214,14 @@ public class NodeImpl implements Path.No
         if (this == o) {
             return true;
         }
-        if (o == null || getClass() != o.getClass()) {
+        if (o == null || !getClass().equals(o.getClass())) {
             return false;
         }
 
         NodeImpl node = (NodeImpl) o;
 
-        if (inIterable != node.inIterable) {
-            return false;
-        }
-        if (index != null ? !index.equals(node.index) : node.index != null) {
-            return false;
-        }
-        if (key != null ? !key.equals(node.key) : node.key != null) {
-            return false;
-        }
-        if (name != null ? !name.equals(node.name) : node.name != null) {
-            return false;
-        }
-        if (kind != null ? !kind.equals(node.kind) : node.kind != null) {
-            return false;
-        }
-
-        return true;
+        return inIterable == node.inIterable && Objects.equals(index, node.index) && Objects.equals(key, node.key)
+            && Objects.equals(name, node.name) && kind == node.kind;
     }
 
     /**
@@ -243,12 +229,7 @@ public class NodeImpl implements Path.No
      */
     @Override
     public int hashCode() {
-        int result = name != null ? name.hashCode() : 0;
-        result = 31 * result + (inIterable ? 1 : 0);
-        result = 31 * result + (index != null ? index.hashCode() : 0);
-        result = 31 * result + (key != null ? key.hashCode() : 0);
-        result = 31 * result + (kind != null ? kind.hashCode() : 0);
-        return result;
+        return Objects.hash(name, Boolean.valueOf(inIterable), index, key, kind);
     }
 
     public int getParameterIndex() {
@@ -263,6 +244,7 @@ public class NodeImpl implements Path.No
         this.parameterTypes = parameterTypes;
     }
 
+    @SuppressWarnings("serial")
     public static class ParameterNodeImpl extends NodeImpl implements Path.ParameterNode {
         public ParameterNodeImpl(final Node cast) {
             super(cast);
@@ -282,6 +264,7 @@ public class NodeImpl implements Path.No
         }
     }
 
+    @SuppressWarnings("serial")
     public static class ConstructorNodeImpl extends NodeImpl implements Path.ConstructorNode {
         public ConstructorNodeImpl(final Node cast) {
             super(cast);
@@ -301,6 +284,7 @@ public class NodeImpl implements Path.No
         }
     }
 
+    @SuppressWarnings("serial")
     public static class CrossParameterNodeImpl extends NodeImpl implements Path.CrossParameterNode {
         public CrossParameterNodeImpl() {
             super("<cross-parameter>");
@@ -316,6 +300,7 @@ public class NodeImpl implements Path.No
         }
     }
 
+    @SuppressWarnings("serial")
     public static class MethodNodeImpl extends NodeImpl implements Path.MethodNode {
         public MethodNodeImpl(final Node cast) {
             super(cast);
@@ -335,6 +320,7 @@ public class NodeImpl implements Path.No
         }
     }
 
+    @SuppressWarnings("serial")
     public static class ReturnValueNodeImpl extends NodeImpl implements Path.ReturnValueNode {
         public ReturnValueNodeImpl(final Node cast) {
             super(cast);
@@ -350,6 +336,7 @@ public class NodeImpl implements Path.No
         }
     }
 
+    @SuppressWarnings("serial")
     public static class PropertyNodeImpl extends NodeImpl implements Path.PropertyNode {
         public PropertyNodeImpl(final String name) {
             super(name);
@@ -365,6 +352,7 @@ public class NodeImpl implements Path.No
         }
     }
 
+    @SuppressWarnings("serial")
     public static class BeanNodeImpl extends NodeImpl implements Path.BeanNode {
         public BeanNodeImpl() {
             // no-op

Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/util/PathImpl.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/util/PathImpl.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/util/PathImpl.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/util/PathImpl.java Tue May  2 04:53:20 2017
@@ -20,9 +20,9 @@ package org.apache.bval.jsr.util;
 
 import javax.validation.Path;
 import java.io.Serializable;
-import java.util.ArrayList;
 import java.util.Iterator;
-import java.util.List;
+import java.util.LinkedList;
+import java.util.Objects;
 
 /**
  * Description: object holding the property path as a list of nodes.
@@ -88,8 +88,6 @@ public class PathImpl implements Path, S
 
     }
 
-    private final List<Node> nodeList;
-
     /**
      * Returns a {@code Path} instance representing the path described by the given string. To create a root node the
      * empty string should be passed. Note: This signature is to maintain pluggability with the RI impl.
@@ -99,7 +97,7 @@ public class PathImpl implements Path, S
      * @return a {@code Path} instance representing the path described by the given string.
      */
     public static PathImpl createPathFromString(String propertyPath) {
-        if (propertyPath == null || propertyPath.length() == 0) {
+        if (propertyPath == null || propertyPath.isEmpty()) {
             return create();
         }
         return PathNavigation.navigateAndReturn(propertyPath, new PathImplBuilder());
@@ -127,13 +125,6 @@ public class PathImpl implements Path, S
         return path == null ? null : new PathImpl(path);
     }
 
-    private PathImpl(Path path) {
-        this.nodeList = new ArrayList<Node>();
-        for (final Object aPath : path) {
-            nodeList.add(newNode(Node.class.cast(aPath)));
-        }
-    }
-
     private static Node newNode(final Node cast) {
         if (PropertyNode.class.isInstance(cast)) {
             return new NodeImpl.PropertyNodeImpl(cast);
@@ -162,14 +153,14 @@ public class PathImpl implements Path, S
         return new NodeImpl(cast);
     }
 
+    private final LinkedList<Node> nodeList = new LinkedList<>();
+
     private PathImpl() {
-        nodeList = new ArrayList<Node>();
     }
 
-    private PathImpl(List<Node> nodeList) {
-        this.nodeList = new ArrayList<Node>();
-        for (Node node : nodeList) {
-            this.nodeList.add(new NodeImpl(node));
+    private PathImpl(Iterable<? extends Node> nodes) {
+        for (final Path.Node node : nodes) {
+            nodeList.add(newNode(node));
         }
     }
 
@@ -183,7 +174,7 @@ public class PathImpl implements Path, S
         if (nodeList.size() != 1) {
             return false;
         }
-        Path.Node first = nodeList.get(0);
+        Path.Node first = nodeList.peekFirst();
         return !first.isInIterable() && first.getName() == null;
     }
 
@@ -193,13 +184,10 @@ public class PathImpl implements Path, S
      * @return PathImpl
      */
     public PathImpl getPathWithoutLeafNode() {
-        List<Node> nodes = new ArrayList<Node>(nodeList);
-        PathImpl path = null;
-        if (nodes.size() > 1) {
-            nodes.remove(nodes.size() - 1);
-            path = new PathImpl(nodes);
+        if (nodeList.size() < 2) {
+            return null;
         }
-        return path;
+        return new PathImpl(nodeList.subList(0, nodeList.size() - 1));
     }
 
     /**
@@ -210,10 +198,9 @@ public class PathImpl implements Path, S
      */
     public void addNode(Node node) {
         if (isRootPath()) {
-            nodeList.set(0, node);
-        } else {
-            nodeList.add(node);
+            nodeList.pop();
         }
+        nodeList.add(node);
     }
 
     /**
@@ -254,11 +241,11 @@ public class PathImpl implements Path, S
      *             if no nodes are found
      */
     public Node removeLeafNode() {
-        if (isRootPath() || nodeList.size() == 0) {
+        if (isRootPath() || nodeList.isEmpty()) {
             throw new IllegalStateException("No nodes in path!");
         }
         try {
-            return nodeList.remove(nodeList.size() - 1);
+            return nodeList.removeLast();
         } finally {
             if (nodeList.isEmpty()) {
                 nodeList.add(new NodeImpl((String) null));
@@ -272,10 +259,10 @@ public class PathImpl implements Path, S
      * @return {@link NodeImpl}
      */
     public NodeImpl getLeafNode() {
-        if (nodeList.size() == 0) {
+        if (nodeList.isEmpty()) {
             return null;
         }
-        return (NodeImpl) nodeList.get(nodeList.size() - 1);
+        return (NodeImpl) nodeList.peekLast();
     }
 
     /**
@@ -347,13 +334,10 @@ public class PathImpl implements Path, S
         if (this == o) {
             return true;
         }
-        if (o == null || getClass() != o.getClass()) {
+        if (o == null || !getClass().equals(o.getClass())) {
             return false;
         }
-
-        PathImpl path = (PathImpl) o;
-        return !(nodeList != null && !nodeList.equals(path.nodeList)) && !(nodeList == null && path.nodeList != null);
-
+        return Objects.equals(nodeList, ((PathImpl) o).nodeList);
     }
 
     /**
@@ -361,7 +345,7 @@ public class PathImpl implements Path, S
      */
     @Override
     public int hashCode() {
-        return nodeList != null ? nodeList.hashCode() : 0;
+        return Objects.hashCode(nodeList);
     }
 
 }

Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/util/PathNavigation.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/util/PathNavigation.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/util/PathNavigation.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/util/PathNavigation.java Tue May  2 04:53:20 2017
@@ -36,7 +36,7 @@ public class PathNavigation {
     /**
      * Path traversal callback function interface.
      */
-    public interface Callback<T> {
+    interface Callback<T> {
         /**
          * Handle a .-delimited property.
          * 
@@ -67,13 +67,13 @@ public class PathNavigation {
     /**
      * Callback "procedure" that always returns null.
      */
-    public static abstract class CallbackProcedure implements Callback<Object> {
+    public static abstract class CallbackProcedure implements Callback<Void> {
 
         /**
          * {@inheritDoc}
          */
         @Override
-        public final Object result() {
+        public final Void result() {
             complete();
             return null;
         }
@@ -275,7 +275,7 @@ public class PathNavigation {
     /**
      * ParsePosition/Callback
      */
-    private static class PathPosition extends ParsePosition implements Callback<Object> {
+    private static class PathPosition extends ParsePosition implements Callback<Void> {
         final Callback<?> delegate;
 
         /**
@@ -336,7 +336,7 @@ public class PathNavigation {
          * {@inheritDoc}
          */
         @Override
-        public Object result() {
+        public Void result() {
             return null;
         }
 

Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/util/Proxies.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/util/Proxies.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/util/Proxies.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/util/Proxies.java Tue May  2 04:53:20 2017
@@ -26,7 +26,7 @@ public final class Proxies {
     private static final Set<String> KNOWN_PROXY_CLASSNAMES;
 
     static {
-        final Set<String> s = new HashSet<String>();
+        final Set<String> s = new HashSet<>();
         s.add("org.jboss.weld.bean.proxy.ProxyObject");
         KNOWN_PROXY_CLASSNAMES = Collections.unmodifiableSet(s);
     }

Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/util/ValidationContextTraversal.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/util/ValidationContextTraversal.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/util/ValidationContextTraversal.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/util/ValidationContextTraversal.java Tue May  2 04:53:20 2017
@@ -219,4 +219,4 @@ public class ValidationContextTraversal
                 .resolveMetaBean(ObjectUtils.defaultIfNull(validationContext.getBean(), rawType)));
         }
     }
-}
\ No newline at end of file
+}

Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/xml/AnnotationIgnores.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/xml/AnnotationIgnores.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/xml/AnnotationIgnores.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/xml/AnnotationIgnores.java Tue May  2 04:53:20 2017
@@ -38,7 +38,7 @@ public final class AnnotationIgnores {
      * xml configuration. 
      * If 'ignore-annotations' is not specified: default = true
      */
-    private final Map<Class<?>, Boolean> ignoreAnnotationDefaults = new HashMap<Class<?>, Boolean>();
+    private final Map<Class<?>, Boolean> ignoreAnnotationDefaults = new HashMap<>();
 
     /**
      * Keeps track of explicitly excluded members (fields and properties) for a given class.
@@ -47,15 +47,13 @@ public final class AnnotationIgnores {
      * <code>true</code> in the configuration
      * for this class.
      */
-    private final Map<Class<?>, Map<Member, Boolean>> ignoreAnnotationOnMember =
-        new HashMap<Class<?>, Map<Member, Boolean>>();
+    private final Map<Class<?>, Map<Member, Boolean>> ignoreAnnotationOnMember = new HashMap<>();
 
-    private final Map<Class<?>, Boolean> ignoreAnnotationOnClass = new HashMap<Class<?>, Boolean>();
+    private final Map<Class<?>, Boolean> ignoreAnnotationOnClass = new HashMap<>();
 
-    private final Map<Class<?>, Map<Member, Map<Integer, Boolean>>> ignoreAnnotationOnParameter =
-        new HashMap<Class<?>, Map<Member, Map<Integer, Boolean>>>();
-    private final Map<Member, Boolean> ignoreAnnotationOnReturn = new HashMap<Member, Boolean>();
-    private final Map<Member, Boolean> ignoreAnnotationOnCrossParameter = new HashMap<Member, Boolean>();
+    private final Map<Class<?>, Map<Member, Map<Integer, Boolean>>> ignoreAnnotationOnParameter = new HashMap<>();
+    private final Map<Member, Boolean> ignoreAnnotationOnReturn = new HashMap<>();
+    private final Map<Member, Boolean> ignoreAnnotationOnCrossParameter = new HashMap<>();
 
     /**
      * Record the ignore state for a particular annotation type.
@@ -63,7 +61,7 @@ public final class AnnotationIgnores {
      * @param b, default true if null
      */
     public void setDefaultIgnoreAnnotation(Class<?> clazz, Boolean b) {
-        ignoreAnnotationDefaults.put(clazz, b == null || b.booleanValue());
+        ignoreAnnotationDefaults.put(clazz, b == null ? Boolean.TRUE : b);
     }
 
     /**
@@ -71,8 +69,8 @@ public final class AnnotationIgnores {
      * @param clazz
      * @return boolean
      */
-    public boolean getDefaultIgnoreAnnotation(Class<?> clazz) {
-        return ignoreAnnotationDefaults.containsKey(clazz) && ignoreAnnotationDefaults.get(clazz);
+    public boolean isDefaultIgnoreAnnotation(Class<?> clazz) {
+        return Boolean.TRUE.equals(ignoreAnnotationDefaults.get(clazz));
     }
 
     /**
@@ -80,13 +78,7 @@ public final class AnnotationIgnores {
      * @param member
      */
     public void setIgnoreAnnotationsOnMember(Member member, boolean value) {
-        Class<?> beanClass = member.getDeclaringClass();
-        Map<Member, Boolean> memberList = ignoreAnnotationOnMember.get(beanClass);
-        if (memberList == null) {
-            memberList = new HashMap<Member, Boolean>();
-            ignoreAnnotationOnMember.put(beanClass, memberList);
-        }
-        memberList.put(member, value);
+        ignoreAnnotationOnMember.computeIfAbsent(member.getDeclaringClass(), k -> new HashMap<>()).put(member, value);
     }
 
     /**
@@ -97,56 +89,35 @@ public final class AnnotationIgnores {
     public boolean isIgnoreAnnotations(final Member member) {
         final Class<?> clazz = member.getDeclaringClass();
         final Map<Member, Boolean> ignoreAnnotationForMembers = ignoreAnnotationOnMember.get(clazz);
+        final boolean result;
         if (ignoreAnnotationForMembers != null && ignoreAnnotationForMembers.containsKey(member)) {
-            final boolean value = ignoreAnnotationForMembers.get(member);
-            if (value) {
-                logMessage(member, clazz);
-            }
-            return value;
+            result = ignoreAnnotationForMembers.get(member).booleanValue();
+        } else {
+            result = isDefaultIgnoreAnnotation(clazz);
         }
-
-        final boolean ignoreAnnotation = getDefaultIgnoreAnnotation(clazz);
-        if (ignoreAnnotation) {
+        if (result) {
             logMessage(member, clazz);
         }
-        return ignoreAnnotation;
+        return result;
     }
 
     public void setIgnoreAnnotationsOnParameter(final Member method, final int i, final boolean value) {
-        final Class<?> beanClass = method.getDeclaringClass();
-        Map<Member, Map<Integer, Boolean>> memberList = ignoreAnnotationOnParameter.get(beanClass);
-        if (memberList == null) {
-            memberList = new HashMap<Member, Map<Integer, Boolean>>();
-            ignoreAnnotationOnParameter.put(beanClass, memberList);
-        }
-        Map<Integer, Boolean> indexes = memberList.get(method);
-        if (indexes == null) {
-            indexes = new HashMap<Integer, Boolean>();
-            memberList.put(method, indexes);
-        }
-        indexes.put(i, value);
+        ignoreAnnotationOnParameter.computeIfAbsent(method.getDeclaringClass(), k -> new HashMap<>())
+            .computeIfAbsent(method, k -> new HashMap<>()).put(i, value);
     }
 
     public boolean isIgnoreAnnotationOnParameter(final Member m, final int i) {
         final Map<Member, Map<Integer, Boolean>> members = ignoreAnnotationOnParameter.get(m.getDeclaringClass());
-        if (members != null) {
-            final Map<Integer, Boolean> indexes = members.get(m);
-            if (indexes != null && indexes.containsKey(i)) {
-                return indexes.get(i);
-            }
+        if (members == null) {
+            return false;
         }
-        return false;
+        final Map<Integer, Boolean> indexes = members.get(m);
+        return indexes != null && Boolean.TRUE.equals(indexes.get(Integer.valueOf(i)));
     }
 
     private void logMessage(Member member, Class<?> clazz) {
-        String type;
-        if (member instanceof Field) {
-            type = "Field";
-        } else {
-            type = "Property";
-        }
-        log.log(Level.FINEST, String.format("%s level annotations are getting ignored for %s.%s", type, clazz.getName(),
-            member.getName()));
+        log.log(Level.FINEST, String.format("%s level annotations are getting ignored for %s.%s",
+            member instanceof Field ? "Field" : "Property", clazz.getName(), member.getName()));
     }
 
     /**
@@ -164,12 +135,8 @@ public final class AnnotationIgnores {
      * @return boolean
      */
     public boolean isIgnoreAnnotations(Class<?> clazz) {
-        boolean ignoreAnnotation;
-        if (ignoreAnnotationOnClass.containsKey(clazz)) {
-            ignoreAnnotation = ignoreAnnotationOnClass.get(clazz);
-        } else {
-            ignoreAnnotation = getDefaultIgnoreAnnotation(clazz);
-        }
+        boolean ignoreAnnotation = ignoreAnnotationOnClass.containsKey(clazz) ? ignoreAnnotationOnClass.get(clazz)
+            : isDefaultIgnoreAnnotation(clazz);
         if (ignoreAnnotation) {
             log.log(Level.FINEST, String.format("Class level annotation are getting ignored for %s", clazz.getName()));
         }
@@ -181,11 +148,7 @@ public final class AnnotationIgnores {
     }
 
     public boolean isIgnoreAnnotationOnReturn(final Member m) {
-        final Boolean value = ignoreAnnotationOnReturn.get(m);
-        if (value != null) {
-            return value;
-        }
-        return false;
+        return Boolean.TRUE.equals(ignoreAnnotationOnReturn.get(m));
     }
 
     public void setIgnoreAnnotationOnCrossParameter(final Member method, final boolean value) {
@@ -193,10 +156,6 @@ public final class AnnotationIgnores {
     }
 
     public boolean isIgnoreAnnotationOnCrossParameter(final Member m) {
-        final Boolean value = ignoreAnnotationOnCrossParameter.get(m);
-        if (value != null) {
-            return value;
-        }
-        return false;
+        return Boolean.TRUE.equals(ignoreAnnotationOnCrossParameter.get(m));
     }
 }

Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/xml/AnnotationProxy.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/xml/AnnotationProxy.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/xml/AnnotationProxy.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/xml/AnnotationProxy.java Tue May  2 04:53:20 2017
@@ -16,15 +16,15 @@
  */
 package org.apache.bval.jsr.xml;
 
-import javax.validation.Valid;
 import java.io.Serializable;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.SortedSet;
-import java.util.TreeSet;
+import java.util.SortedMap;
+import java.util.TreeMap;
+import java.util.stream.Collectors;
+
+import javax.validation.Valid;
 
 /**
  * Description: <br/>
@@ -38,7 +38,7 @@ class AnnotationProxy implements Annotat
     private static final long serialVersionUID = 1L;
 
     private final Class<? extends Annotation> annotationType;
-    private final Map<String, Object> values;
+    private final SortedMap<String, Object> values;
 
     /**
      * Create a new AnnotationProxy instance.
@@ -48,26 +48,21 @@ class AnnotationProxy implements Annotat
      */
     public <A extends Annotation> AnnotationProxy(AnnotationProxyBuilder<A> descriptor) {
         this.annotationType = descriptor.getType();
-        values = getAnnotationValues(descriptor);
-    }
-
-    private <A extends Annotation> Map<String, Object> getAnnotationValues(AnnotationProxyBuilder<A> descriptor) {
-        final Map<String, Object> result = new HashMap<String, Object>();
+        values = new TreeMap<>();
         int processedValuesFromDescriptor = 0;
         for (final Method m : descriptor.getMethods()) {
             if (descriptor.contains(m.getName())) {
-                result.put(m.getName(), descriptor.getValue(m.getName()));
+                values.put(m.getName(), descriptor.getValue(m.getName()));
                 processedValuesFromDescriptor++;
             } else if (m.getDefaultValue() != null) {
-                result.put(m.getName(), m.getDefaultValue());
+                values.put(m.getName(), m.getDefaultValue());
             } else {
                 throw new IllegalArgumentException("No value provided for " + m.getName());
             }
         }
         if (processedValuesFromDescriptor != descriptor.size() && !Valid.class.equals(annotationType)) {
-            throw new RuntimeException("Trying to instanciate " + annotationType + " with unknown paramters.");
+            throw new RuntimeException("Trying to instantiate " + annotationType + " with unknown paramters.");
         }
-        return result;
     }
 
     /**
@@ -94,22 +89,7 @@ class AnnotationProxy implements Annotat
      */
     @Override
     public String toString() {
-        StringBuilder result = new StringBuilder();
-        result.append('@').append(annotationType().getName()).append('(');
-        boolean comma = false;
-        for (String m : getMethodsSorted()) {
-            if (comma)
-                result.append(", ");
-            result.append(m).append('=').append(values.get(m));
-            comma = true;
-        }
-        result.append(")");
-        return result.toString();
-    }
-
-    private SortedSet<String> getMethodsSorted() {
-        SortedSet<String> result = new TreeSet<String>();
-        result.addAll(values.keySet());
-        return result;
+        return values.entrySet().stream().map(e -> String.format("%s=%s", e.getKey(), e.getValue()))
+            .collect(Collectors.joining(", ", String.format("@%s(", annotationType().getName()), ")"));
     }
 }

Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/xml/AnnotationProxyBuilder.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/xml/AnnotationProxyBuilder.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/xml/AnnotationProxyBuilder.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/xml/AnnotationProxyBuilder.java Tue May  2 04:53:20 2017
@@ -48,7 +48,7 @@ public final class AnnotationProxyBuilde
     private static final ConcurrentMap<Class<?>, Method[]> METHODS_CACHE = new ConcurrentHashMap<Class<?>, Method[]>();
 
     private final Class<A> type;
-    private final Map<String, Object> elements = new HashMap<String, Object>();
+    private final Map<String, Object> elements = new HashMap<>();
     private final Method[] methods;
 
     /**
@@ -63,15 +63,7 @@ public final class AnnotationProxyBuilde
 
     public static <A> Method[] findMethods(final Class<A> annotationType) {
         if (annotationType.getName().startsWith("javax.validation.constraints.")) { // cache built-in constraints only to avoid mem leaks
-            Method[] mtd = METHODS_CACHE.get(annotationType);
-            if (mtd == null) {
-                final Method[] value = Reflection.getDeclaredMethods(annotationType);
-                mtd = METHODS_CACHE.putIfAbsent(annotationType, value);
-                if (mtd == null) {
-                    mtd = value;
-                }
-            }
-            return mtd;
+            return METHODS_CACHE.computeIfAbsent(annotationType, k -> Reflection.getDeclaredMethods(k));
         }
         return Reflection.getDeclaredMethods(annotationType);
     }
@@ -84,14 +76,12 @@ public final class AnnotationProxyBuilde
      */
     public AnnotationProxyBuilder(Class<A> annotationType, Map<String, Object> elements) {
         this(annotationType);
-        for (Map.Entry<String, Object> entry : elements.entrySet()) {
-            this.elements.put(entry.getKey(), entry.getValue());
-        }
+        elements.forEach(this.elements::put);
     }
 
     /**
      * Create a builder initially configured to create an annotation equivalent
-     * to <code>annot</code>.
+     * to {@code annot}.
      * 
      * @param annot Annotation to be replicated.
      */
@@ -102,8 +92,7 @@ public final class AnnotationProxyBuilde
         for (Method m : methods) {
             final boolean mustUnset = Reflection.setAccessible(m, true);
             try {
-                Object value = m.invoke(annot);
-                this.elements.put(m.getName(), value);
+                this.elements.put(m.getName(), m.invoke(annot));
             } catch (Exception e) {
                 throw new ValidationException("Cannot access annotation " + annot + " element: " + m.getName(), e);
             } finally {
@@ -203,16 +192,21 @@ public final class AnnotationProxyBuilde
         final ClassLoader classLoader = Reflection.getClassLoader(getType());
         @SuppressWarnings("unchecked")
         final Class<A> proxyClass = (Class<A>) Proxy.getProxyClass(classLoader, getType());
-        final InvocationHandler handler = new AnnotationProxy(this);
-        return doCreateAnnotation(proxyClass, handler);
+        return doCreateAnnotation(proxyClass, new AnnotationProxy(this));
     }
 
     @Privileged
     private A doCreateAnnotation(final Class<A> proxyClass, final InvocationHandler handler) {
         try {
             Constructor<A> constructor = proxyClass.getConstructor(InvocationHandler.class);
-            Reflection.setAccessible(constructor, true); // java 8
-            return constructor.newInstance(handler);
+            final boolean mustUnset = Reflection.setAccessible(constructor, true); // java 8
+            try {
+                return constructor.newInstance(handler);
+            } finally {
+                if (mustUnset) {
+                    Reflection.setAccessible(constructor, false);
+                }
+            }
         } catch (Exception e) {
             throw new ValidationException("Unable to create annotation for configured constraint", e);
         }

Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/xml/MetaConstraint.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/xml/MetaConstraint.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/xml/MetaConstraint.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/xml/MetaConstraint.java Tue May  2 04:53:20 2017
@@ -57,28 +57,29 @@ public class MetaConstraint<T, A extends
         this.member = member;
         this.beanClass = beanClass;
         this.annotation = annotation;
-        if (member != null) {
+        if (member == null) {
+            this.accessStrategy = null;
+        } else {
             accessStrategy = createAccessStrategy(member);
             /*TODO: see if can really be removed
             if (accessStrategy == null || accessStrategy.getPropertyName() == null) { // can happen if method does not follow the bean convention
                 throw new ValidationException("Annotated method does not follow the JavaBeans naming convention: " + member);
             }
             */
-        } else {
-            this.accessStrategy = null;
         }
     }
 
     private static AccessStrategy createAccessStrategy(Member member) {
         if (member instanceof Method) {
             return new MethodAccess((Method) member);
-        } else if (member instanceof Field) {
+        }
+        if (member instanceof Field) {
             return new FieldAccess((Field) member);
-        } else if (member instanceof Constructor<?>) {
+        }
+        if (member instanceof Constructor<?>) {
             return new ConstructorAccess((Constructor<?>) member);
-        } else {
-            return null; // class level
         }
+        return null; // class level
     }
 
     /**
@@ -118,6 +119,6 @@ public class MetaConstraint<T, A extends
     }
 
     public void setIndex(final int index) {
-        this.index = index;
+        this.index = Integer.valueOf(index);
     }
 }

Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/xml/ValidationMappingParser.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/xml/ValidationMappingParser.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/xml/ValidationMappingParser.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/xml/ValidationMappingParser.java Tue May  2 04:53:20 2017
@@ -26,13 +26,16 @@ import java.lang.reflect.Field;
 import java.lang.reflect.Member;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.EnumSet;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Optional;
 import java.util.Set;
+import java.util.function.Predicate;
+import java.util.function.Supplier;
+import java.util.stream.Stream;
 
 import javax.validation.Constraint;
 import javax.validation.ConstraintValidator;
@@ -95,7 +98,7 @@ public class ValidationMappingParser {
                     throw new ValidationException(beanClass.getName() + " has already be configured in xml.");
                 }
 
-                boolean ignoreAnnotations = bean.getIgnoreAnnotations() == null ? true : bean.getIgnoreAnnotations();
+                boolean ignoreAnnotations = !Boolean.FALSE.equals(bean.getIgnoreAnnotations());
                 factory.getAnnotationIgnores().setDefaultIgnoreAnnotation(beanClass, ignoreAnnotations);
                 processClassLevel(bean.getClassType(), beanClass, defaultPackage);
                 processConstructorLevel(bean.getConstructor(), beanClass, defaultPackage, ignoreAnnotations);
@@ -154,10 +157,8 @@ public class ValidationMappingParser {
         }
 
         // constraints
-        for (ConstraintType constraint : classType.getConstraint()) {
-            MetaConstraint<?, ?> metaConstraint = createConstraint(constraint, beanClass, null, defaultPackage);
-            factory.addMetaConstraint(beanClass, metaConstraint);
-        }
+        classType.getConstraint().stream().map(c -> createConstraint(c, beanClass, null, defaultPackage))
+            .forEach(mc -> factory.addMetaConstraint(beanClass, mc));
     }
 
     @SuppressWarnings("unchecked")
@@ -185,10 +186,9 @@ public class ValidationMappingParser {
     }
 
     private void checkValidName(String name) {
-        for (ConstraintAnnotationAttributes attr : RESERVED_PARAMS) {
-            if (attr.getAttributeName().equals(name)) {
-                throw new ValidationException(name + " is a reserved parameter name.");
-            }
+        if (RESERVED_PARAMS.stream().map(ConstraintAnnotationAttributes::getAttributeName)
+            .anyMatch(Predicate.isEqual(name))) {
+            throw new ValidationException(name + " is a reserved parameter name.");
         }
     }
 
@@ -212,7 +212,7 @@ public class ValidationMappingParser {
             }
             return getSingleValue(elementType.getContent().get(0), returnType, defaultPackage);
         }
-        List<Object> values = new ArrayList<Object>();
+        List<Object> values = new ArrayList<>();
         for (Serializable s : elementType.getContent()) {
             values.add(getSingleValue(s, returnType.getComponentType(), defaultPackage));
         }
@@ -220,7 +220,7 @@ public class ValidationMappingParser {
     }
 
     private void removeEmptyContentElements(ElementType elementType) {
-        List<Serializable> contentToDelete = new ArrayList<Serializable>();
+        List<Serializable> contentToDelete = new ArrayList<>();
         for (Serializable content : elementType.getContent()) {
             if (content instanceof String && ((String) content).matches("[\\n ].*")) {
                 contentToDelete.add(content);
@@ -260,10 +260,10 @@ public class ValidationMappingParser {
          * spec: Note that if the raw string is unqualified,
          * default package is taken into account.
          */
-        if (returnType.equals(String.class)) {
+        if (String.class.equals(returnType)) {
             return value;
         }
-        if (returnType.equals(Class.class)) {
+        if (Class.class.equals(returnType)) {
             ClassLoader cl = Reflection.getClassLoader(ValidationMappingParser.class);
             try {
                 return Reflection.toClass(toQualifiedClassName(value, defaultPackage), cl);
@@ -312,7 +312,7 @@ public class ValidationMappingParser {
 
     private <A extends Annotation> Annotation createAnnotation(AnnotationType annotationType, Class<A> returnType,
         String defaultPackage) {
-        AnnotationProxyBuilder<A> metaAnnotation = new AnnotationProxyBuilder<A>(returnType);
+        AnnotationProxyBuilder<A> metaAnnotation = new AnnotationProxyBuilder<>(returnType);
         for (ElementType elementType : annotationType.getElement()) {
             String name = elementType.getName();
             Class<?> parameterType = getAnnotationParameterType(returnType, name);
@@ -326,12 +326,7 @@ public class ValidationMappingParser {
         if (groupsType == null) {
             return ObjectUtils.EMPTY_CLASS_ARRAY;
         }
-
-        List<Class<?>> groupList = new ArrayList<Class<?>>();
-        for (String groupClass : groupsType.getValue()) {
-            groupList.add(loadClass(groupClass, defaultPackage));
-        }
-        return groupList.toArray(new Class[groupList.size()]);
+        return loadClasses(groupsType.getValue()::stream, defaultPackage);
     }
 
     @SuppressWarnings("unchecked")
@@ -339,35 +334,24 @@ public class ValidationMappingParser {
         if (payloadType == null) {
             return new Class[] {};
         }
-
-        List<Class<? extends Payload>> payloadList = new ArrayList<Class<? extends Payload>>();
-        for (String groupClass : payloadType.getValue()) {
-            Class<?> payload = loadClass(groupClass, defaultPackage);
-            if (!Payload.class.isAssignableFrom(payload)) {
+        return streamClasses(payloadType.getValue()::stream, defaultPackage).peek(pc -> {
+            if (!Payload.class.isAssignableFrom(pc)) {
                 throw new ValidationException(
-                    "Specified payload class " + payload.getName() + " does not implement javax.validation.Payload");
+                    "Specified payload class " + pc.getName() + " does not implement javax.validation.Payload");
             }
-            payloadList.add((Class<? extends Payload>) payload);
-        }
-        return payloadList.toArray(new Class[payloadList.size()]);
+        }).<Class<? extends Payload>> map(pc -> pc.asSubclass(Payload.class)).toArray(Class[]::new);
     }
 
     private Class<?>[] createGroupSequence(GroupSequenceType groupSequenceType, String defaultPackage) {
-        if (groupSequenceType != null) {
-            Class<?>[] groupSequence = new Class<?>[groupSequenceType.getValue().size()];
-            int i = 0;
-            for (String groupName : groupSequenceType.getValue()) {
-                Class<?> group = loadClass(groupName, defaultPackage);
-                groupSequence[i++] = group;
-            }
-            return groupSequence;
+        if (groupSequenceType == null) {
+            return null;
         }
-        return null;
+        return loadClasses(groupSequenceType.getValue()::stream, defaultPackage);
     }
 
     private <A> void processMethodLevel(final List<MethodType> methods, final Class<A> beanClass,
         final String defaultPackage, final boolean parentIgnoreAnn, final Collection<String> getters) {
-        final List<String> methodNames = new ArrayList<String>();
+        final List<String> methodNames = new ArrayList<>();
         for (final MethodType methodType : methods) {
             final String methodName = methodType.getName();
             if (methodNames.contains(methodName) || getters.contains(methodName)) {
@@ -376,8 +360,8 @@ public class ValidationMappingParser {
             }
             methodNames.add(methodName);
 
-            final Method method =
-                Reflection.getDeclaredMethod(beanClass, methodName, toTypes(methodType.getParameter(), defaultPackage));
+            final Method method = Reflection.getDeclaredMethod(beanClass, methodName,
+                loadClasses(() -> methodType.getParameter().stream().map(ParameterType::getType), defaultPackage));
             if (method == null) {
                 throw new ValidationException(beanClass.getName() + " does not contain the method  " + methodName);
             }
@@ -387,12 +371,8 @@ public class ValidationMappingParser {
                 methodType.getIgnoreAnnotations() == null ? parentIgnoreAnn : methodType.getIgnoreAnnotations();
             factory.getAnnotationIgnores().setIgnoreAnnotationsOnMember(method, ignoreMethodAnnotation);
 
-            final boolean ignoreAnn;
-            if (methodType.getIgnoreAnnotations() == null) {
-                ignoreAnn = parentIgnoreAnn;
-            } else {
-                ignoreAnn = methodType.getIgnoreAnnotations();
-            }
+            final boolean ignoreAnn =
+                methodType.getIgnoreAnnotations() == null ? parentIgnoreAnn : methodType.getIgnoreAnnotations();
 
             // constraints
             int i = 0;
@@ -404,7 +384,7 @@ public class ValidationMappingParser {
                     factory.addMetaConstraint(beanClass, constraint);
                 }
                 if (p.getValid() != null) {
-                    final MetaConstraint<?, ?> constraint = new MetaConstraint<A, Annotation>(beanClass, method,
+                    final MetaConstraint<?, ?> constraint = new MetaConstraint<>(beanClass, method,
                         AnnotationProxyBuilder.ValidAnnotation.INSTANCE);
                     constraint.setIndex(i);
                     factory.addMetaConstraint(beanClass, constraint);
@@ -414,7 +394,7 @@ public class ValidationMappingParser {
                     for (final GroupConversionType groupConversion : p.getConvertGroup()) {
                         final Class<?> from = loadClass(groupConversion.getFrom(), defaultPackage);
                         final Class<?> to = loadClass(groupConversion.getTo(), defaultPackage);
-                        final MetaConstraint<?, ?> constraint = new MetaConstraint<A, Annotation>(beanClass, method,
+                        final MetaConstraint<?, ?> constraint = new MetaConstraint<>(beanClass, method,
                             new AnnotationProxyBuilder.ConvertGroupAnnotation(from, to));
                         constraint.setIndex(i);
                         factory.addMetaConstraint(beanClass, constraint);
@@ -436,7 +416,7 @@ public class ValidationMappingParser {
                     factory.addMetaConstraint(beanClass, constraint);
                 }
                 if (returnValue.getValid() != null) {
-                    final MetaConstraint<?, ?> constraint = new MetaConstraint<A, Annotation>(beanClass, method,
+                    final MetaConstraint<?, ?> constraint = new MetaConstraint<>(beanClass, method,
                         AnnotationProxyBuilder.ValidAnnotation.INSTANCE);
                     factory.addMetaConstraint(beanClass, constraint);
                 }
@@ -445,7 +425,7 @@ public class ValidationMappingParser {
                     for (final GroupConversionType groupConversion : returnValue.getConvertGroup()) {
                         final Class<?> from = loadClass(groupConversion.getFrom(), defaultPackage);
                         final Class<?> to = loadClass(groupConversion.getTo(), defaultPackage);
-                        final MetaConstraint<?, ?> constraint = new MetaConstraint<A, Annotation>(beanClass, method,
+                        final MetaConstraint<?, ?> constraint = new MetaConstraint<>(beanClass, method,
                             new AnnotationProxyBuilder.ConvertGroupAnnotation(from, to));
                         factory.addMetaConstraint(beanClass, constraint);
                     }
@@ -470,8 +450,8 @@ public class ValidationMappingParser {
     private <A> void processConstructorLevel(final List<ConstructorType> constructors, final Class<A> beanClass,
         final String defaultPackage, final boolean parentIgnore) {
         for (final ConstructorType constructorType : constructors) {
-            final Constructor<?> constructor =
-                Reflection.getDeclaredConstructor(beanClass, toTypes(constructorType.getParameter(), defaultPackage));
+            final Constructor<?> constructor = Reflection.getDeclaredConstructor(beanClass,
+                loadClasses(() -> constructorType.getParameter().stream().map(ParameterType::getType), defaultPackage));
             if (constructor == null) {
                 throw new ValidationException(
                     beanClass.getName() + " does not contain the constructor  " + constructorType);
@@ -482,12 +462,8 @@ public class ValidationMappingParser {
                 constructorType.getIgnoreAnnotations() == null ? parentIgnore : constructorType.getIgnoreAnnotations();
             factory.getAnnotationIgnores().setIgnoreAnnotationsOnMember(constructor, ignoreMethodAnnotation);
 
-            final boolean ignoreAnn;
-            if (constructorType.getIgnoreAnnotations() == null) {
-                ignoreAnn = parentIgnore;
-            } else {
-                ignoreAnn = constructorType.getIgnoreAnnotations();
-            }
+            final boolean ignoreAnn =
+                constructorType.getIgnoreAnnotations() == null ? parentIgnore : constructorType.getIgnoreAnnotations();
 
             // constraints
             int i = 0;
@@ -499,7 +475,7 @@ public class ValidationMappingParser {
                     factory.addMetaConstraint(beanClass, constraint);
                 }
                 if (p.getValid() != null) {
-                    final MetaConstraint<?, ?> constraint = new MetaConstraint<A, Annotation>(beanClass, constructor,
+                    final MetaConstraint<?, ?> constraint = new MetaConstraint<>(beanClass, constructor,
                         AnnotationProxyBuilder.ValidAnnotation.INSTANCE);
                     constraint.setIndex(i);
                     factory.addMetaConstraint(beanClass, constraint);
@@ -509,7 +485,7 @@ public class ValidationMappingParser {
                     for (final GroupConversionType groupConversion : p.getConvertGroup()) {
                         final Class<?> from = loadClass(groupConversion.getFrom(), defaultPackage);
                         final Class<?> to = loadClass(groupConversion.getTo(), defaultPackage);
-                        final MetaConstraint<?, ?> constraint = new MetaConstraint<A, Annotation>(beanClass,
+                        final MetaConstraint<?, ?> constraint = new MetaConstraint<>(beanClass,
                             constructor, new AnnotationProxyBuilder.ConvertGroupAnnotation(from, to));
                         constraint.setIndex(i);
                         factory.addMetaConstraint(beanClass, constraint);
@@ -522,7 +498,7 @@ public class ValidationMappingParser {
                     // TODO what ?
                 }
                 factory.getAnnotationIgnores().setIgnoreAnnotationsOnParameter(constructor, i,
-                    p.getIgnoreAnnotations() != null ? p.getIgnoreAnnotations() : ignoreAnn);
+                    p.getIgnoreAnnotations() == null ? ignoreAnn : p.getIgnoreAnnotations());
 
                 i++;
             }
@@ -536,7 +512,7 @@ public class ValidationMappingParser {
                     factory.addMetaConstraint(beanClass, constraint);
                 }
                 if (returnValue.getValid() != null) {
-                    final MetaConstraint<?, ?> constraint = new MetaConstraint<A, Annotation>(beanClass, constructor,
+                    final MetaConstraint<?, ?> constraint = new MetaConstraint<>(beanClass, constructor,
                         AnnotationProxyBuilder.ValidAnnotation.INSTANCE);
                     constraint.setIndex(-1);
                     factory.addMetaConstraint(beanClass, constraint);
@@ -546,14 +522,14 @@ public class ValidationMappingParser {
                     for (final GroupConversionType groupConversion : returnValue.getConvertGroup()) {
                         final Class<?> from = loadClass(groupConversion.getFrom(), defaultPackage);
                         final Class<?> to = loadClass(groupConversion.getTo(), defaultPackage);
-                        final MetaConstraint<?, ?> constraint = new MetaConstraint<A, Annotation>(beanClass,
+                        final MetaConstraint<?, ?> constraint = new MetaConstraint<>(beanClass,
                             constructor, new AnnotationProxyBuilder.ConvertGroupAnnotation(from, to));
                         constraint.setIndex(-1);
                         factory.addMetaConstraint(beanClass, constraint);
                     }
                 }
                 factory.getAnnotationIgnores().setIgnoreAnnotationOnReturn(constructor,
-                    returnValue.getIgnoreAnnotations() != null ? returnValue.getIgnoreAnnotations() : ignoreAnn);
+                    returnValue.getIgnoreAnnotations() == null ? ignoreAnn : returnValue.getIgnoreAnnotations());
             }
 
             final CrossParameterType crossParameter = constructorType.getCrossParameter();
@@ -564,26 +540,14 @@ public class ValidationMappingParser {
                     factory.addMetaConstraint(beanClass, constraint);
                 }
                 factory.getAnnotationIgnores().setIgnoreAnnotationOnCrossParameter(constructor,
-                    crossParameter.getIgnoreAnnotations() != null ? crossParameter.getIgnoreAnnotations() : ignoreAnn);
+                    crossParameter.getIgnoreAnnotations() == null ? ignoreAnn : crossParameter.getIgnoreAnnotations());
             }
         }
     }
 
-    private Class<?>[] toTypes(final List<ParameterType> parameter, final String defaultPck) {
-        if (parameter == null) {
-            return null;
-        }
-        final Class<?>[] types = new Class<?>[parameter.size()];
-        int i = 0;
-        for (final ParameterType type : parameter) {
-            types[i++] = loadClass(type.getType(), defaultPck);
-        }
-        return types;
-    }
-
     private <A> void processFieldLevel(List<FieldType> fields, Class<A> beanClass, String defaultPackage,
         boolean ignoreAnnotations) {
-        final List<String> fieldNames = new ArrayList<String>();
+        final List<String> fieldNames = new ArrayList<>();
         for (FieldType fieldType : fields) {
             String fieldName = fieldType.getName();
             if (fieldNames.contains(fieldName)) {
@@ -610,7 +574,7 @@ public class ValidationMappingParser {
             for (final GroupConversionType conversion : fieldType.getConvertGroup()) {
                 final Class<?> from = loadClass(conversion.getFrom(), defaultPackage);
                 final Class<?> to = loadClass(conversion.getTo(), defaultPackage);
-                final MetaConstraint<?, ?> constraint = new MetaConstraint<A, Annotation>(beanClass, field,
+                final MetaConstraint<?, ?> constraint = new MetaConstraint<>(beanClass, field,
                     new AnnotationProxyBuilder.ConvertGroupAnnotation(from, to));
                 factory.addMetaConstraint(beanClass, constraint);
             }
@@ -625,7 +589,7 @@ public class ValidationMappingParser {
 
     private <A> Collection<String> processPropertyLevel(List<GetterType> getters, Class<A> beanClass,
         String defaultPackage, boolean ignoreAnnotatino) {
-        List<String> getterNames = new ArrayList<String>();
+        List<String> getterNames = new ArrayList<>();
         for (GetterType getterType : getters) {
             final String getterName = getterType.getName();
             final String methodName = "get" + StringUtils.capitalize(getterType.getName());
@@ -654,7 +618,7 @@ public class ValidationMappingParser {
             for (final GroupConversionType conversion : getterType.getConvertGroup()) {
                 final Class<?> from = loadClass(conversion.getFrom(), defaultPackage);
                 final Class<?> to = loadClass(conversion.getTo(), defaultPackage);
-                final MetaConstraint<?, ?> constraint = new MetaConstraint<A, Annotation>(beanClass, method,
+                final MetaConstraint<?, ?> constraint = new MetaConstraint<>(beanClass, method,
                     new AnnotationProxyBuilder.ConvertGroupAnnotation(from, to));
                 factory.addMetaConstraint(beanClass, constraint);
             }
@@ -683,14 +647,12 @@ public class ValidationMappingParser {
             Class<? extends Annotation> annotationClass = (Class<? extends Annotation>) clazz;
 
             ValidatedByType validatedByType = constraintDefinition.getValidatedBy();
-            List<Class<? extends ConstraintValidator<?, ?>>> classes =
-                new ArrayList<Class<? extends ConstraintValidator<?, ?>>>();
+            List<Class<? extends ConstraintValidator<?, ?>>> classes = new ArrayList<>();
             /*
              If include-existing-validator is set to false,
              ConstraintValidator defined on the constraint annotation are ignored.
               */
-            if (validatedByType.getIncludeExistingValidators() != null
-                && validatedByType.getIncludeExistingValidators()) {
+            if (Boolean.TRUE.equals(validatedByType.getIncludeExistingValidators())) {
                 /*
                  If set to true, the list of ConstraintValidators described in XML
                  are concatenated to the list of ConstraintValidator described on the
@@ -699,8 +661,7 @@ public class ValidationMappingParser {
                 classes.addAll(findConstraintValidatorClasses(annotationClass));
             }
             for (String validatorClassName : validatedByType.getValue()) {
-                Class<? extends ConstraintValidator<?, ?>> validatorClass;
-                validatorClass = (Class<? extends ConstraintValidator<?, ?>>) loadClass(validatorClassName);
+                Class<? extends ConstraintValidator<?, ?>> validatorClass = (Class<? extends ConstraintValidator<?, ?>>) loadClass(validatorClassName);
 
                 if (!ConstraintValidator.class.isAssignableFrom(validatorClass)) {
                     throw new ValidationException(validatorClass + " is not a constraint validator class");
@@ -717,50 +678,49 @@ public class ValidationMappingParser {
             if (factory.getConstraintsCache().containsConstraintValidator(annotationClass)) {
                 throw new ValidationException(
                     "Constraint validator for " + annotationClass.getName() + " already configured.");
-            } else {
-                factory.getConstraintsCache().putConstraintValidator(annotationClass,
-                    classes.toArray(new Class[classes.size()]));
             }
+            factory.getConstraintsCache().putConstraintValidator(annotationClass,
+                classes.toArray(new Class[classes.size()]));
         }
     }
 
     private List<Class<? extends ConstraintValidator<? extends Annotation, ?>>> findConstraintValidatorClasses(
         Class<? extends Annotation> annotationType) {
-        List<Class<? extends ConstraintValidator<? extends Annotation, ?>>> classes =
-            new ArrayList<Class<? extends ConstraintValidator<? extends Annotation, ?>>>();
+        List<Class<? extends ConstraintValidator<? extends Annotation, ?>>> classes = new ArrayList<>();
 
         Class<? extends ConstraintValidator<?, ?>>[] validator =
             factory.getDefaultConstraints().getValidatorClasses(annotationType);
-        if (validator == null) {
-            /* Collections.addAll() would be more straightforward here, but there is an Oracle compiler bug of some sort
-             * that precludes this:
-             */
-            Class<? extends ConstraintValidator<?, ?>>[] validatedBy =
-                annotationType.getAnnotation(Constraint.class).validatedBy();
-            classes.addAll(Arrays.asList(validatedBy));
-        } else {
-            Collections.addAll(classes, validator);
-        }
+
+        Collections.addAll(classes, Optional.ofNullable(validator)
+            .orElseGet(() -> annotationType.getAnnotation(Constraint.class).validatedBy()));
+
         return classes;
     }
 
+    private Class<?>[] loadClasses(Supplier<Stream<String>> classNames, String defaultPackage) {
+        return streamClasses(classNames, defaultPackage).toArray(Class[]::new);
+    }
+
+    private Stream<Class<?>> streamClasses(Supplier<Stream<String>> classNames, String defaultPackage) {
+        return classNames.get().map(c -> loadClass(c, defaultPackage));
+    }
+
     private Class<?> loadClass(String className, String defaultPackage) {
         return loadClass(toQualifiedClassName(className, defaultPackage));
     }
 
     private String toQualifiedClassName(String className, String defaultPackage) {
-        if (!isQualifiedClass(className)) {
-            if (className.startsWith("[L") && className.endsWith(";")) {
-                className = "[L" + defaultPackage + "." + className.substring(2);
-            } else {
-                className = defaultPackage + "." + className;
-            }
+        if (isQualifiedClass(className)) {
+            return className;
+        }
+        if (className.startsWith("[L") && className.endsWith(";")) {
+            return "[L" + defaultPackage + "." + className.substring(2);
         }
-        return className;
+        return defaultPackage + "." + className;
     }
 
     private boolean isQualifiedClass(String clazz) {
-        return clazz.contains(".");
+        return clazz.indexOf('.') >= 0;
     }
 
     @Privileged
@@ -788,5 +748,4 @@ public class ValidationMappingParser {
             throw new ValidationException("Unable to load class: " + className, ex);
         }
     }
-
 }

Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/xml/ValidationParser.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/xml/ValidationParser.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/xml/ValidationParser.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/xml/ValidationParser.java Tue May  2 04:53:20 2017
@@ -108,7 +108,20 @@ public class ValidationParser {
             parser.xmlConfig = parseXmlConfig(file);
         }
 
-        if (parser.xmlConfig != null) {
+        if (parser.xmlConfig == null) { // default config
+            final CopyOnWriteArraySet<ExecutableType> executableTypes = new CopyOnWriteArraySet<>();
+            executableTypes.add(ExecutableType.CONSTRUCTORS);
+            executableTypes.add(ExecutableType.NON_GETTER_METHODS);
+
+            parser.bootstrap = new BootstrapConfigurationImpl(
+                    null, null, null, null, null,
+                    new CopyOnWriteArraySet<>(),
+                    true,
+                    executableTypes,
+                    new HashMap<>());
+
+            targetConfig.setExecutableValidation(executableTypes);
+        } else {
             if (parser.xmlConfig.getExecutableValidation() == null) {
                 final ExecutableValidationType value = new ExecutableValidationType();
                 value.setEnabled(true);
@@ -129,29 +142,16 @@ public class ValidationParser {
                     parser.xmlConfig.getMessageInterpolator(),
                     parser.xmlConfig.getTraversableResolver(),
                     parser.xmlConfig.getParameterNameProvider(),
-                    new CopyOnWriteArraySet<String>(parser.xmlConfig.getConstraintMapping()),
+                    new CopyOnWriteArraySet<>(parser.xmlConfig.getConstraintMapping()),
                     parser.xmlConfig.getExecutableValidation().getEnabled(),
-                    new CopyOnWriteArraySet<ExecutableType>(targetConfig.getExecutableValidation()),
+                    new CopyOnWriteArraySet<>(targetConfig.getExecutableValidation()),
                     toMap(parser.xmlConfig.getProperty()));
-        } else { // default config
-            final CopyOnWriteArraySet<ExecutableType> executableTypes = new CopyOnWriteArraySet<ExecutableType>();
-            executableTypes.add(ExecutableType.CONSTRUCTORS);
-            executableTypes.add(ExecutableType.NON_GETTER_METHODS);
-
-            parser.bootstrap = new BootstrapConfigurationImpl(
-                    null, null, null, null, null,
-                    new CopyOnWriteArraySet<String>(),
-                    true,
-                    executableTypes,
-                    new HashMap<String, String>());
-
-            targetConfig.setExecutableValidation(executableTypes);
         }
         return parser;
     }
 
     private static Map<String, String> toMap(final List<PropertyType> property) {
-        final Map<String, String> map = new HashMap<String, String>();
+        final Map<String, String> map = new HashMap<>();
         if (property != null) {
             for (final PropertyType p : property) {
                 map.put(p.getName(), p.getValue());
@@ -162,9 +162,7 @@ public class ValidationParser {
 
     @Privileged
     private static ValidationConfigType parseXmlConfig(final String validationXmlFile) {
-        InputStream inputStream = null;
-        try {
-            inputStream = getInputStream(getValidationXmlFile(validationXmlFile));
+        try (InputStream inputStream = getInputStream(getValidationXmlFile(validationXmlFile))) {
             if (inputStream == null) {
             	log.log(Level.FINEST, String.format("No %s found. Using annotation based configuration only.", validationXmlFile));
                 return null;
@@ -180,12 +178,8 @@ public class ValidationParser {
             JAXBElement<ValidationConfigType> root =
                     unmarshaller.unmarshal(stream, ValidationConfigType.class);
             return root.getValue();
-        } catch (JAXBException e) {
-            throw new ValidationException("Unable to parse " + validationXmlFile, e);
-        } catch (IOException e) {
+        } catch (JAXBException | IOException e) {
             throw new ValidationException("Unable to parse " + validationXmlFile, e);
-        } finally {
-            IOs.closeQuietly(inputStream);
         }
     }
 
@@ -247,7 +241,7 @@ public class ValidationParser {
     }
 
     private static void applyExecutableValidation(final ValidationConfigType xmlConfig, final ConfigurationImpl targetConfig) {
-        final CopyOnWriteArrayList<ExecutableType> executableTypes = new CopyOnWriteArrayList<ExecutableType>();
+        final CopyOnWriteArrayList<ExecutableType> executableTypes = new CopyOnWriteArrayList<>();
         if (xmlConfig.getExecutableValidation() != null && xmlConfig.getExecutableValidation().getEnabled()
                 && xmlConfig.getExecutableValidation().getDefaultValidatedExecutableTypes() != null) {
             executableTypes.addAll(xmlConfig.getExecutableValidation().getDefaultValidatedExecutableTypes().getExecutableType());
@@ -267,16 +261,15 @@ public class ValidationParser {
 
     private void applyParameterNameProvider(final ValidationConfigType xmlConfig, final ConfigurationImpl targetConfig) {
         final String parameterNameProvider = xmlConfig.getParameterNameProvider();
-        if (targetConfig.getParameterNameProvider() == targetConfig.getDefaultParameterNameProvider()) { // ref ==
-            if (parameterNameProvider != null) {
-                final Class<?> loaded = loadClass(parameterNameProvider);
-                if (loaded == null) {
-                    log.log(Level.SEVERE, "Can't load " + parameterNameProvider);
-                } else {
-                    final Class<? extends ParameterNameProvider> clazz = loaded.asSubclass(ParameterNameProvider.class);
-                    targetConfig.parameterNameProviderClass(clazz);
-                    log.log(Level.INFO, String.format("Using %s as validation provider.", parameterNameProvider));
-                }
+        if (targetConfig.getParameterNameProvider() == targetConfig.getDefaultParameterNameProvider()
+            && parameterNameProvider != null) {
+            final Class<?> loaded = loadClass(parameterNameProvider);
+            if (loaded == null) {
+                log.log(Level.SEVERE, "Can't load " + parameterNameProvider);
+            } else {
+                final Class<? extends ParameterNameProvider> clazz = loaded.asSubclass(ParameterNameProvider.class);
+                targetConfig.parameterNameProviderClass(clazz);
+                log.log(Level.INFO, String.format("Using %s as validation provider.", parameterNameProvider));
             }
         }
     }
@@ -296,13 +289,11 @@ public class ValidationParser {
     private void applyMessageInterpolator(ValidationConfigType xmlConfig,
                                           ConfigurationImpl target) {
         String messageInterpolatorClass = xmlConfig.getMessageInterpolator();
-        if (target.getMessageInterpolator() == target.getDefaultMessageInterpolator()) { // ref ==
-            if (messageInterpolatorClass != null) {
-                Class<MessageInterpolator> clazz = (Class<MessageInterpolator>)
-                        loadClass(messageInterpolatorClass);
-                target.messageInterpolatorClass(clazz);
-                log.log(Level.INFO, String.format("Using %s as message interpolator.", messageInterpolatorClass));
-            }
+        if (target.getMessageInterpolator() == target.getDefaultMessageInterpolator()
+            && messageInterpolatorClass != null) {
+            Class<MessageInterpolator> clazz = (Class<MessageInterpolator>) loadClass(messageInterpolatorClass);
+            target.messageInterpolatorClass(clazz);
+            log.log(Level.INFO, String.format("Using %s as message interpolator.", messageInterpolatorClass));
         }
     }
 
@@ -311,8 +302,7 @@ public class ValidationParser {
                                           ConfigurationImpl target) {
         String traversableResolverClass = xmlConfig.getTraversableResolver();
         if (target.getTraversableResolver() == target.getDefaultTraversableResolver() && traversableResolverClass != null) {
-		    Class<TraversableResolver> clazz = (Class<TraversableResolver>)
-		            loadClass(traversableResolverClass);
+            Class<TraversableResolver> clazz = (Class<TraversableResolver>) loadClass(traversableResolverClass);
 		    target.traversableResolverClass(clazz);
 		    log.log(Level.INFO, String.format("Using %s as traversable resolver.", traversableResolverClass));
 		}
@@ -323,8 +313,8 @@ public class ValidationParser {
                                         ConfigurationImpl target) {
         String constraintFactoryClass = xmlConfig.getConstraintValidatorFactory();
         if (target.getConstraintValidatorFactory() == target.getDefaultConstraintValidatorFactory() && constraintFactoryClass != null) {
-		    Class<ConstraintValidatorFactory> clazz = (Class<ConstraintValidatorFactory>)
-		            loadClass(constraintFactoryClass);
+            Class<ConstraintValidatorFactory> clazz =
+                (Class<ConstraintValidatorFactory>) loadClass(constraintFactoryClass);
 		    target.constraintValidatorFactoryClass(clazz);
 		    log.log(Level.INFO, String.format("Using %s as constraint factory.", constraintFactoryClass));
 		}
@@ -334,7 +324,7 @@ public class ValidationParser {
                                      ConfigurationImpl target) {
         for (String rawMappingFileName : xmlConfig.getConstraintMapping()) {
             String mappingFileName = rawMappingFileName;
-            if (mappingFileName.startsWith("/")) {
+            if (mappingFileName.charAt(0) == '/') {
                 // Classloader needs a path without a starting /
                 mappingFileName = mappingFileName.substring(1);
             }

Modified: bval/branches/bv2.x/bval-xstream/src/main/java/org/apache/bval/routines/EMailValidation.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-xstream/src/main/java/org/apache/bval/routines/EMailValidation.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-xstream/src/main/java/org/apache/bval/routines/EMailValidation.java (original)
+++ bval/branches/bv2.x/bval-xstream/src/main/java/org/apache/bval/routines/EMailValidation.java Tue May  2 04:53:20 2017
@@ -27,12 +27,13 @@ import java.util.regex.Pattern;
  */
 public class EMailValidation implements Validation {
 
-    private java.util.regex.Pattern pattern = EMailValidationUtils.DEFAULT_EMAIL_PATTERN;
+    private Pattern pattern = EMailValidationUtils.DEFAULT_EMAIL_PATTERN;
 
     @Override
     public <T extends ValidationListener> void validate(ValidationContext<T> context) {
-        if (context.getPropertyValue() == null)
+        if (context.getPropertyValue() == null) {
             return;
+        }
         if (!EMailValidationUtils.isValid(context.getPropertyValue(), getPattern())) {
             context.getListener().addError(Reasons.EMAIL_ADDRESS, context);
         }

Modified: bval/branches/bv2.x/bval-xstream/src/main/java/org/apache/bval/routines/StandardValidation.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-xstream/src/main/java/org/apache/bval/routines/StandardValidation.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-xstream/src/main/java/org/apache/bval/routines/StandardValidation.java (original)
+++ bval/branches/bv2.x/bval-xstream/src/main/java/org/apache/bval/routines/StandardValidation.java Tue May  2 04:53:20 2017
@@ -61,10 +61,12 @@ public class StandardValidation implemen
 
     protected <T extends ValidationListener> void validateTimeLag(ValidationContext<T> context) {
         String lag = (String) context.getMetaProperty().getFeature(TIME_LAG);
-        if (lag == null)
+        if (lag == null) {
             return;
-        if (context.getPropertyValue() == null)
+        }
+        if (context.getPropertyValue() == null) {
             return;
+        }
         long date = ((Date) context.getPropertyValue()).getTime();
         long now = System.currentTimeMillis();
         if (XMLMetaValue.TIMELAG_Future.equals(lag)) {
@@ -85,10 +87,12 @@ public class StandardValidation implemen
     protected <T extends ValidationListener> void validateRegExp(ValidationContext<T> context) {
         final MetaProperty meta = context.getMetaProperty();
         final String regExp = (String) meta.getFeature(REG_EXP);
-        if (regExp == null)
+        if (regExp == null) {
             return;
-        if (context.getPropertyValue() == null)
+        }
+        if (context.getPropertyValue() == null) {
             return;
+        }
 
         final String value = String.valueOf(context.getPropertyValue());
         try {
@@ -118,8 +122,9 @@ public class StandardValidation implemen
     protected <T extends ValidationListener> void validateMaxValue(ValidationContext<T> context) {
         @SuppressWarnings("unchecked")
         Comparable<Object> maxValue = (Comparable<Object>) context.getMetaProperty().getFeature(MAX_VALUE);
-        if (maxValue == null || context.getPropertyValue() == null)
+        if (maxValue == null || context.getPropertyValue() == null) {
             return;
+        }
         if (compare(context, maxValue, context.getPropertyValue()) < 0) {
             context.getListener().addError(MAX_VALUE, context);
         }
@@ -142,17 +147,21 @@ public class StandardValidation implemen
 
     protected <T extends ValidationListener> void validateMaxLength(ValidationContext<T> context) {
         Integer maxLength = (Integer) context.getMetaProperty().getFeature(Features.Property.MAX_LENGTH);
-        if (maxLength == null)
+        if (maxLength == null) {
             return;
-        if (context.getPropertyValue() == null)
+        }
+        if (context.getPropertyValue() == null) {
             return;
+        }
 
         final Object value = context.getPropertyValue();
-        int length = 0;
+        int length;
         if (value instanceof String) {
             length = ((String) value).length();
         } else if (value instanceof Collection<?>) {
             length = ((Collection<?>) value).size();
+        } else {
+            length = 0;
         }
         if (length > maxLength) {
             context.getListener().addError(MAX_LENGTH, context);
@@ -161,17 +170,21 @@ public class StandardValidation implemen
 
     protected <T extends ValidationListener> void validateMinLength(ValidationContext<T> context) {
         Integer maxLength = (Integer) context.getMetaProperty().getFeature(Features.Property.MIN_LENGTH);
-        if (maxLength == null)
+        if (maxLength == null) {
             return;
-        if (context.getPropertyValue() == null)
+        }
+        if (context.getPropertyValue() == null) {
             return;
+        }
 
         final Object value = context.getPropertyValue();
-        int length = 0;
+        int length;
         if (value instanceof String) {
             length = ((String) value).length();
         } else if (value instanceof Collection<?>) {
             length = ((Collection<?>) value).size();
+        } else {
+            length = 0;
         }
         if (length < maxLength) {
             context.getListener().addError(MIN_LENGTH, context);
@@ -179,10 +192,8 @@ public class StandardValidation implemen
     }
 
     protected <T extends ValidationListener> void validateMandatory(ValidationContext<T> context) {
-        if (context.getMetaProperty().isMandatory()) {
-            if (context.getPropertyValue() == null) {
-                context.getListener().addError(MANDATORY, context);
-            }
+        if (context.getMetaProperty().isMandatory() && context.getPropertyValue() == null) {
+            context.getListener().addError(MANDATORY, context);
         }
     }