bval-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r1793432 [3/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...
Date Tue, 02 May 2017 04:53:22 GMT
Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ClassValidator.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ClassValidator.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ClassValidator.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ClassValidator.java Tue May  2 04:53:20 2017
@@ -261,10 +261,8 @@ public class ClassValidator implements C
                 edesc = metaBean.initFeature(JsrFeatures.Bean.BEAN_DESCRIPTOR, createBeanDescriptor(metaBean));
             }
             return edesc;
-        } catch (final ConstraintDefinitionException definitionEx) {
-            throw definitionEx;
-        } catch (final ConstraintDeclarationException declarationEx) {
-            throw declarationEx;
+        } catch (final ConstraintDefinitionException | ConstraintDeclarationException ex) {
+            throw ex;
         } catch (final RuntimeException ex) {
             throw new ValidationException("error retrieving constraints for " + clazz, ex);
         }
@@ -386,7 +384,7 @@ public class ClassValidator implements C
                 // to the GroupSequence defined in the same class
 
                 // Obtain the full class hierarchy
-                final List<Class<?>> classHierarchy = new ArrayList<Class<?>>();
+                final List<Class<?>> classHierarchy = new ArrayList<>();
                 ClassHelper.fillFullClassHierarchyAsList(classHierarchy, context.getMetaBean().getBeanClass());
                 final Class<?> initialOwner = context.getCurrentOwner();
 
@@ -600,21 +598,9 @@ public class ClassValidator implements C
     private void validatePropertyInGroup(final GroupValidationContext<?> context) {
         final Runnable helper;
         if (context.getMetaProperty() == null) {
-            helper = new Runnable() {
-
-                @Override
-                public void run() {
-                    ValidationHelper.validateBean(context);
-                }
-            };
+            helper = () -> ValidationHelper.validateBean(context);
         } else {
-            helper = new Runnable() {
-
-                @Override
-                public void run() {
-                    ValidationHelper.validateProperty(context);
-                }
-            };
+            helper = () -> ValidationHelper.validateProperty(context);
         }
         final List<Group> defaultGroups = expandDefaultGroup(context);
         if (defaultGroups == null) {
@@ -642,8 +628,8 @@ public class ClassValidator implements C
      */
     protected <T> GroupValidationContext<T> createContext(MetaBean metaBean, T object, Class<T> objectClass,
         Class<?>... groups) {
-        final ConstraintValidationListener<T> listener = new ConstraintValidationListener<T>(object, objectClass);
-        final GroupValidationContextImpl<T> context = new GroupValidationContextImpl<T>(listener,
+        final ConstraintValidationListener<T> listener = new ConstraintValidationListener<>(object, objectClass);
+        final GroupValidationContextImpl<T> context = new GroupValidationContextImpl<>(listener,
             factoryContext.getMessageInterpolator(), factoryContext.getTraversableResolver(),
             factoryContext.getParameterNameProvider(), factoryContext.getConstraintValidatorFactory(), metaBean);
         context.setBean(object, metaBean);
@@ -653,8 +639,8 @@ public class ClassValidator implements C
 
     protected <T> GroupValidationContext<T> createInvocableContext(MetaBean metaBean, T object, Class<T> objectClass,
         Class<?>... groups) {
-        final ConstraintValidationListener<T> listener = new ConstraintValidationListener<T>(object, objectClass);
-        final GroupValidationContextImpl<T> context = new GroupValidationContextImpl<T>(listener,
+        final ConstraintValidationListener<T> listener = new ConstraintValidationListener<>(object, objectClass);
+        final GroupValidationContextImpl<T> context = new GroupValidationContextImpl<>(listener,
             factoryContext.getMessageInterpolator(), factoryContext.getTraversableResolver(),
             factoryContext.getParameterNameProvider(), factoryContext.getConstraintValidatorFactory(), metaBean);
         context.setBean(object, metaBean);
@@ -1204,7 +1190,7 @@ public class ClassValidator implements C
 
                     Validation[] validations = meta.getValidations();
                     if (validations == null || validations.length == 0) {
-                        return Collections.<ConstraintViolation<T>> emptySet();
+                        return Collections.emptySet();
                     }
                 }
                 if (!TypeUtils.isAssignable(value == null ? null : value.getClass(), contextTraversal.getType())) {

Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ConfigurationImpl.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ConfigurationImpl.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ConfigurationImpl.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ConfigurationImpl.java Tue May  2 04:53:20 2017
@@ -19,7 +19,6 @@
 package org.apache.bval.jsr;
 
 import java.io.Closeable;
-import java.io.IOException;
 import java.io.InputStream;
 import java.util.Collection;
 import java.util.HashMap;
@@ -97,8 +96,7 @@ public class ConfigurationImpl implement
 
     protected Collection<ExecutableType> executableValidation;
 
-    private Collection<BValExtension.Releasable<?>> releasables =
-        new CopyOnWriteArrayList<BValExtension.Releasable<?>>();
+    private Collection<BValExtension.Releasable<?>> releasables = new CopyOnWriteArrayList<>();
 
     private boolean beforeCdi = false;
 
@@ -109,8 +107,8 @@ public class ConfigurationImpl implement
     private boolean prepared = false;
     // END DEFAULTS
 
-    private Set<InputStream> mappingStreams = new HashSet<InputStream>();
-    private Map<String, String> properties = new HashMap<String, String>();
+    private Set<InputStream> mappingStreams = new HashSet<>();
+    private Map<String, String> properties = new HashMap<>();
     private boolean ignoreXmlConfiguration = false;
 
     private volatile ValidationParser parser;
@@ -452,14 +450,11 @@ public class ConfigurationImpl implement
     }
 
     public Closeable getClosable() {
-        return new Closeable() {
-            @Override
-            public void close() throws IOException {
-                for (final BValExtension.Releasable<?> releasable : releasables) {
-                    releasable.release();
-                }
-                releasables.clear();
+        return () -> {
+            for (final BValExtension.Releasable<?> releasable : releasables) {
+                releasable.release();
             }
+            releasables.clear();
         };
     }
 
@@ -469,8 +464,7 @@ public class ConfigurationImpl implement
             final BValExtension.Releasable<T> releasable = BValExtension.inject(cls);
             releasables.add(releasable);
             return releasable.getInstance();
-        } catch (final Exception e) {
-        } catch (final NoClassDefFoundError error) {
+        } catch (Exception | NoClassDefFoundError e) {
         }
         try {
             return cls.newInstance();

Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintAnnotationAttributes.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintAnnotationAttributes.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintAnnotationAttributes.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintAnnotationAttributes.java Tue May  2 04:53:20 2017
@@ -145,9 +145,9 @@ public enum ConstraintAnnotationAttribut
     }
 
     // this is static but related to Worker
-    private static final ConcurrentMap<Class<?>, Worker<?>> WORKER_CACHE = new ConcurrentHashMap<Class<?>, Worker<?>>();
+    private static final ConcurrentMap<Class<?>, Worker<?>> WORKER_CACHE = new ConcurrentHashMap<>();
     private static final ConcurrentMap<Class<?>, ConcurrentMap<String, Method>> METHOD_BY_NAME_AND_CLASS =
-        new ConcurrentHashMap<Class<?>, ConcurrentMap<String, Method>>();
+        new ConcurrentHashMap<>();
     private static final Method NULL_METHOD;
     static {
         try {
@@ -171,14 +171,8 @@ public enum ConstraintAnnotationAttribut
         }
 
         private Method findMethod(final Class<C> constraintType, final String attributeName) {
-            ConcurrentMap<String, Method> cache = METHOD_BY_NAME_AND_CLASS.get(constraintType);
-            if (cache == null) {
-                cache = new ConcurrentHashMap<String, Method>();
-                final ConcurrentMap<String, Method> old = METHOD_BY_NAME_AND_CLASS.putIfAbsent(constraintType, cache);
-                if (old != null) {
-                    cache = old;
-                }
-            }
+            ConcurrentMap<String, Method> cache =
+                METHOD_BY_NAME_AND_CLASS.computeIfAbsent(constraintType, t -> new ConcurrentHashMap<>());
 
             final Method found = cache.get(attributeName);
             if (found != null) {
@@ -189,11 +183,7 @@ public enum ConstraintAnnotationAttribut
                 cache.putIfAbsent(attributeName, NULL_METHOD);
                 return null;
             }
-            final Method oldMtd = cache.putIfAbsent(attributeName, m);
-            if (oldMtd != null) {
-                return oldMtd;
-            }
-            return m;
+            return cache.computeIfAbsent(attributeName, s -> m);
         }
 
         public boolean isValid() {

Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintCached.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintCached.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintCached.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintCached.java Tue May  2 04:53:20 2017
@@ -29,7 +29,7 @@ import java.util.Map;
  */
 public class ConstraintCached {
     private final Map<Class<? extends Annotation>, Class<? extends ConstraintValidator<?, ?>>[]> classes =
-        new HashMap<Class<? extends Annotation>, Class<? extends ConstraintValidator<?, ?>>[]>();
+        new HashMap<>();
 
     /**
      * Record the set of validator classes for a given constraint annotation.

Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintDefaults.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintDefaults.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintDefaults.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintDefaults.java Tue May  2 04:53:20 2017
@@ -80,28 +80,20 @@ public class ConstraintDefaults {
     private Map<String, Class<? extends ConstraintValidator<?, ?>>[]> loadDefaultConstraints(String resource) {
         final Properties constraintProperties = new Properties();
         final ClassLoader classloader = getClassLoader();
-        final InputStream stream = classloader.getResourceAsStream(resource);
-        if (stream == null) {
-            log.log(Level.WARNING, String.format("Cannot find %s", resource));
-        } else {
-            try {
+        try (final InputStream stream = classloader.getResourceAsStream(resource)) {
+            if (stream == null) {
+                log.log(Level.WARNING, String.format("Cannot find %s", resource));
+            } else {
                 constraintProperties.load(stream);
-            } catch (IOException e) {
-                log.log(Level.SEVERE, String.format("Cannot load %s", resource), e);
-            } finally {
-                try {
-                    stream.close();
-                } catch (final IOException e) {
-                    // no-op
-                }
             }
+        } catch (IOException e) {
+            log.log(Level.SEVERE, String.format("Cannot load %s", resource), e);
         }
 
-        final Map<String, Class<? extends ConstraintValidator<?, ?>>[]> loadedConstraints =
-            new HashMap<String, Class<? extends ConstraintValidator<?, ?>>[]>();
+        final Map<String, Class<? extends ConstraintValidator<?, ?>>[]> loadedConstraints = new HashMap<>();
 
         for (final Map.Entry<Object, Object> entry : constraintProperties.entrySet()) {
-            final List<Class<?>> classes = new LinkedList<Class<?>>();
+            final List<Class<?>> classes = new LinkedList<>();
             for (String className : StringUtils.split((String) entry.getValue(), ',')) {
                 try {
                     classes.add(Reflection.toClass(className.trim(), classloader));

Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintDescriptorImpl.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintDescriptorImpl.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintDescriptorImpl.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintDescriptorImpl.java Tue May  2 04:53:20 2017
@@ -26,6 +26,7 @@ import java.io.Serializable;
 import java.lang.annotation.Annotation;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.Set;
 
 /**
@@ -209,15 +210,7 @@ public class ConstraintDescriptorImpl<T
      * generated hashCode on all fields except hashCode
      */
     private int computeHashCode() {
-        int result = annotation != null ? annotation.hashCode() : 0;
-        result = 31 * result + (groups != null ? groups.hashCode() : 0);
-        result = 31 * result + (payload != null ? payload.hashCode() : 0);
-        result = 31 * result + (constraintValidatorClasses != null ? constraintValidatorClasses.hashCode() : 0);
-        result = 31 * result + (attributes != null ? attributes.hashCode() : 0);
-        result = 31 * result + (composingConstraints != null ? composingConstraints.hashCode() : 0);
-        result = 31 * result + (reportAsSingleViolation ? 1 : 0);
-        result = 31 * result + (validationAppliesTo != null ? validationAppliesTo.hashCode() : 0);
-        result = 31 * result + (template != null ? template.hashCode() : 0);
-        return result;
+        return Objects.hash(annotation, groups, payload, constraintValidatorClasses, attributes, composingConstraints,
+            reportAsSingleViolation, validationAppliesTo, template);
     }
 }

Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintFinderImpl.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintFinderImpl.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintFinderImpl.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintFinderImpl.java Tue May  2 04:53:20 2017
@@ -105,8 +105,7 @@ final class ConstraintFinderImpl impleme
      */
     @Override
     public ElementDescriptor.ConstraintFinder declaredOn(ElementType... elementTypes) {
-        final Set<ConstraintValidation<?>> matchingDescriptors =
-            new HashSet<ConstraintValidation<?>>(constraintDescriptors.size());
+        final Set<ConstraintValidation<?>> matchingDescriptors = new HashSet<>(constraintDescriptors.size());
         for (ElementType each : elementTypes) {
             for (ConstraintValidation<?> descriptor : constraintDescriptors) {
                 if (isInScope(descriptor) && isAtElement(descriptor, each)) {
@@ -162,7 +161,7 @@ final class ConstraintFinderImpl impleme
         if (constraintDescriptors.isEmpty()) {
             return Collections.emptySet();
         }
-        return Collections.<ConstraintDescriptor<?>> unmodifiableSet(constraintDescriptors);
+        return Collections.unmodifiableSet(constraintDescriptors);
     }
 
     /**

Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintValidation.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintValidation.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintValidation.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintValidation.java Tue May  2 04:53:20 2017
@@ -18,27 +18,6 @@
  */
 package org.apache.bval.jsr;
 
-import org.apache.bval.jsr.util.NodeImpl;
-import org.apache.bval.jsr.util.PathImpl;
-import org.apache.bval.model.Validation;
-import org.apache.bval.model.ValidationContext;
-import org.apache.bval.model.ValidationListener;
-import org.apache.bval.util.AccessStrategy;
-import org.apache.bval.util.ObjectUtils;
-import org.apache.bval.util.StringUtils;
-import org.apache.bval.util.reflection.Reflection;
-import org.apache.bval.util.reflection.TypeUtils;
-
-import javax.validation.ConstraintDefinitionException;
-import javax.validation.ConstraintTarget;
-import javax.validation.ConstraintValidator;
-import javax.validation.ConstraintValidatorFactory;
-import javax.validation.Payload;
-import javax.validation.UnexpectedTypeException;
-import javax.validation.ValidationException;
-import javax.validation.constraintvalidation.SupportedValidationTarget;
-import javax.validation.constraintvalidation.ValidationTarget;
-import javax.validation.metadata.ConstraintDescriptor;
 import java.io.Serializable;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Array;
@@ -54,6 +33,28 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.stream.Collectors;
+
+import javax.validation.ConstraintDefinitionException;
+import javax.validation.ConstraintTarget;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorFactory;
+import javax.validation.Payload;
+import javax.validation.UnexpectedTypeException;
+import javax.validation.ValidationException;
+import javax.validation.constraintvalidation.SupportedValidationTarget;
+import javax.validation.constraintvalidation.ValidationTarget;
+import javax.validation.metadata.ConstraintDescriptor;
+
+import org.apache.bval.jsr.util.NodeImpl;
+import org.apache.bval.jsr.util.PathImpl;
+import org.apache.bval.model.Validation;
+import org.apache.bval.model.ValidationContext;
+import org.apache.bval.model.ValidationListener;
+import org.apache.bval.util.AccessStrategy;
+import org.apache.bval.util.ObjectUtils;
+import org.apache.bval.util.reflection.Reflection;
+import org.apache.bval.util.reflection.TypeUtils;
 
 /**
  * Description: Adapter between Constraint (JSR303) and Validation (Core)<br/>
@@ -98,12 +99,12 @@ public class ConstraintValidation<T exte
      * @return {@link ConstraintDescriptor}
      */
     public ConstraintDescriptor<T> asSerializableDescriptor() {
-        return new ConstraintDescriptorImpl<T>(this);
+        return new ConstraintDescriptorImpl<>(this);
     }
 
     void setGroups(final Set<Class<?>> groups) {
         this.groups = groups;
-        ConstraintAnnotationAttributes.GROUPS.put(attributes, groups.toArray(new Class<?>[groups.size()]));
+        ConstraintAnnotationAttributes.GROUPS.put(attributes, groups.toArray(new Class[groups.size()]));
     }
 
     void setGroups(final Class<?>[] groups) {
@@ -132,7 +133,7 @@ public class ConstraintValidation<T exte
      */
     public void addComposed(ConstraintValidation<?> aConstraintValidation) {
         if (composedConstraints == null) {
-            composedConstraints = new HashSet<ConstraintValidation<?>>();
+            composedConstraints = new HashSet<>();
         }
         composedConstraints.add(aConstraintValidation);
     }
@@ -251,12 +252,12 @@ public class ConstraintValidation<T exte
                 getValidatorsTypes(constraintClasses);
             reduceTarget(validatorTypes, access);
 
-            final List<Type> assignableTypes = new ArrayList<Type>(constraintClasses.length);
+            final List<Type> assignableTypes = new ArrayList<>(constraintClasses.length);
             fillAssignableTypes(type, validatorTypes.keySet(), assignableTypes);
             reduceAssignableTypes(assignableTypes);
             checkOneType(assignableTypes, type, owner, annotation, access);
 
-            if ((type.equals(Object.class) || type.equals(Object[].class)) && validatorTypes.containsKey(Object.class)
+            if ((Object.class.equals(type) || Object[].class.equals(type)) && validatorTypes.containsKey(Object.class)
                 && validatorTypes.containsKey(Object[].class)) {
                 throw new ConstraintDefinitionException(
                     "Only a validator for Object or Object[] should be provided for cross-parameter validators");
@@ -331,7 +332,7 @@ public class ConstraintValidation<T exte
             throw new UnexpectedTypeException(
                 String.format("Ambiguous validators for type %s. See: @%s at %s. Validators are: %s",
                     stringForType(targetType), anno.annotationType().getSimpleName(), stringForLocation(owner, access),
-                    StringUtils.join(types, ", ")));
+                    types.stream().map(Object::toString).collect(Collectors.joining(", "))));
         }
     }
 
@@ -400,7 +401,7 @@ public class ConstraintValidation<T exte
                 }
             }
             if (!validatorsTypes.containsKey(validatedType)) {
-                validatorsTypes.put(validatedType, new ArrayList<Class<? extends ConstraintValidator<A, ?>>>());
+                validatorsTypes.put(validatedType, new ArrayList<>());
             }
             validatorsTypes.get(validatedType).add(validatorType);
         }
@@ -472,7 +473,7 @@ public class ConstraintValidation<T exte
      */
     @Override
     public String toString() {
-        return "ConstraintValidation{" + validator + '}';
+        return String.format("%s{%s}",ConstraintValidation.class.getSimpleName(), validator);
     }
 
     /**
@@ -524,9 +525,8 @@ public class ConstraintValidation<T exte
      * {@inheritDoc}
      */
     @Override
-    @SuppressWarnings("unchecked")
     public Set<ConstraintDescriptor<?>> getComposingConstraints() {
-        return composedConstraints == null ? Collections.EMPTY_SET : composedConstraints;
+        return composedConstraints == null ? Collections.emptySet() : Collections.unmodifiableSet(composedConstraints);
     }
 
     /**
@@ -537,7 +537,7 @@ public class ConstraintValidation<T exte
      * @return {@link Set} of {@link ConstraintValidation}
      */
     Set<ConstraintValidation<?>> getComposingValidations() {
-        return composedConstraints == null ? Collections.<ConstraintValidation<?>> emptySet() : composedConstraints;
+        return composedConstraints == null ? Collections.emptySet() : composedConstraints;
     }
 
     /**
@@ -566,8 +566,7 @@ public class ConstraintValidation<T exte
      */
     @Override
     public List<Class<? extends ConstraintValidator<T, ?>>> getConstraintValidatorClasses() {
-        return validatorClasses == null ? Collections.<Class<? extends ConstraintValidator<T, ?>>> emptyList()
-            : Arrays.asList(validatorClasses);
+        return validatorClasses == null ? Collections.emptyList() : Arrays.asList(validatorClasses);
     }
 
     public void setValidationAppliesTo(final ConstraintTarget validationAppliesTo) {

Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintValidationListener.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintValidationListener.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintValidationListener.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintValidationListener.java Tue May  2 04:53:20 2017
@@ -16,19 +16,21 @@
  */
 package org.apache.bval.jsr;
 
-import org.apache.bval.jsr.util.PathImpl;
-import org.apache.bval.model.ValidationContext;
-import org.apache.bval.model.ValidationListener;
+import java.lang.annotation.ElementType;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
 
 import javax.validation.ConstraintViolation;
 import javax.validation.ElementKind;
 import javax.validation.MessageInterpolator;
 import javax.validation.Path;
 import javax.validation.metadata.ConstraintDescriptor;
-import java.lang.annotation.ElementType;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
+
+import org.apache.bval.jsr.util.PathImpl;
+import org.apache.bval.model.ValidationContext;
+import org.apache.bval.model.ValidationListener;
+import org.apache.bval.util.ObjectUtils;
 
 /**
  * Description: JSR-303 {@link ValidationListener} implementation; provides {@link ConstraintViolation}s.<br/>
@@ -36,7 +38,7 @@ import java.util.Set;
  * @version $Rev: 1503686 $ $Date: 2013-07-16 14:38:56 +0200 (mar., 16 juil. 2013) $
  */
 public final class ConstraintValidationListener<T> implements ValidationListener {
-    private final Set<ConstraintViolation<T>> constraintViolations = new HashSet<ConstraintViolation<T>>();
+    private final Set<ConstraintViolation<T>> constraintViolations = new HashSet<>();
     private final T rootBean;
     private final Class<T> rootBeanType;
     // the validation process is single-threaded and it's unlikely to change in the near future (otherwise use AtomicInteger).
@@ -95,13 +97,15 @@ public final class ConstraintValidationL
             if (propPath == null)
                 propPath = gcontext.getPropertyPath();
         } else {
-            if (context.getMetaProperty() == null)
+            if (context.getMetaProperty() == null) {
                 value = context.getBean();
-            else
+            } else {
                 value = context.getPropertyValue();
+            }
             message = messageTemplate;
-            if (propPath == null)
+            if (propPath == null) {
                 propPath = PathImpl.createPathFromString(context.getPropertyName());
+            }
             descriptor = null;
         }
         ElementType elementType = (context.getAccess() != null) ? context.getAccess().getElementType() : null;
@@ -111,6 +115,7 @@ public final class ConstraintValidationL
         Object returnValue;
         T rootBean;
         if (GroupValidationContext.class.isInstance(context)) { // TODO: clean up it but it would need to rework completely our context - get rid of it would be the best
+            @SuppressWarnings("unchecked")
             final GroupValidationContext<T> ctx = GroupValidationContext.class.cast(context);
             final ElementKind elementKind = ctx.getElementKind();
             final Iterator<Path.Node> it = propPath.iterator();
@@ -118,13 +123,15 @@ public final class ConstraintValidationL
 
             returnValue = ctx.getReturnValue();
 
-            if (ElementKind.CONSTRUCTOR.equals(kind)) {
+            if (ElementKind.CONSTRUCTOR == kind) {
                 rootBean = null;
                 leaf = context.getBean();
                 returnValue = this.rootBean; // switch back return value and rootBean
-            } else if (ElementKind.METHOD.equals(kind)) {
-                if (ElementKind.RETURN_VALUE.equals(elementKind)) { // switch back return value and rootBean
-                    rootBean = (T) returnValue;
+            } else if (ElementKind.METHOD == kind) {
+                if (ElementKind.RETURN_VALUE == elementKind) { // switch back return value and rootBean
+                    @SuppressWarnings("unchecked")
+                    T t = (T) returnValue;
+                    rootBean = t;
                     if (kindOf(propPath, ElementKind.RETURN_VALUE)) {
                         leaf = returnValue;
                         returnValue = this.rootBean;
@@ -145,8 +152,8 @@ public final class ConstraintValidationL
                 leaf = context.getBean();
             }
 
-            if (ElementKind.CONSTRUCTOR.equals(kind)
-                && (ElementKind.CROSS_PARAMETER.equals(elementKind) || ElementKind.PARAMETER.equals(elementKind))
+            if (ElementKind.CONSTRUCTOR == kind
+                && (ElementKind.CROSS_PARAMETER == elementKind || ElementKind.PARAMETER == elementKind)
                 && (it.hasNext() && it.next() != null && it.hasNext() && it.next() != null && !it.hasNext())) { // means inherited validation use real value
                 leaf = null;
             }
@@ -159,24 +166,16 @@ public final class ConstraintValidationL
             rootBean = this.rootBean;
         }
 
-        constraintViolations.add(new ConstraintViolationImpl<T>(messageTemplate, message, rootBean, leaf, propPath,
+        constraintViolations.add(new ConstraintViolationImpl<>(messageTemplate, message, rootBean, leaf, propPath,
             value, descriptor, rootBeanType, elementType, returnValue, parameters));
     }
 
     private static boolean kindOf(final Path propPath, final ElementKind... kinds) {
-        final Iterator<Path.Node> node = propPath.iterator();
-        boolean isParam = false;
-        while (node.hasNext()) {
-            final ElementKind current = node.next().getKind();
-            isParam = false;
-            for (final ElementKind k : kinds) {
-                if (k.equals(current)) {
-                    isParam = true;
-                    break;
-                }
-            }
+        Path.Node last = null;
+        for (Path.Node node : propPath) {
+            last = node;
         }
-        return isParam;
+        return last != null && ObjectUtils.arrayContains(kinds, last.getKind());
     }
 
     /**

Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintValidatorContextImpl.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintValidatorContextImpl.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintValidatorContextImpl.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintValidatorContextImpl.java Tue May  2 04:53:20 2017
@@ -39,7 +39,7 @@ import java.util.List;
  * a {@link ConstraintValidation} to its adapted {@link ConstraintValidator}. <br/>
  */
 public class ConstraintValidatorContextImpl implements ConstraintValidatorContext {
-    private final List<ValidationListener.Error> errorMessages = new LinkedList<ValidationListener.Error>();
+    private final List<ValidationListener.Error> errorMessages = new LinkedList<>();
 
     private final ConstraintValidation<?> constraintDescriptor;
     private final GroupValidationContext<?> validationContext;
@@ -126,26 +126,23 @@ public class ConstraintValidatorContextI
         @Override
         public NodeBuilderCustomizableContext addPropertyNode(String name) {
             final NodeImpl node;
-            if (!propertyPath.isRootPath()) {
-                if (propertyPath.getLeafNode().getKind() != null) {
-                    node = new NodeImpl.PropertyNodeImpl(name);
-                    propertyPath.addNode(node);
-                } else {
-                    node = propertyPath.getLeafNode();
-                }
+            if (propertyPath.isRootPath()) {
+                node = new NodeImpl.PropertyNodeImpl(name);
+                propertyPath.addNode(node);
+            } else if (propertyPath.getLeafNode().getKind() == null) {
+                node = propertyPath.getLeafNode();
+                node.setName(name);
+                node.setKind(ElementKind.PROPERTY);
             } else {
                 node = new NodeImpl.PropertyNodeImpl(name);
                 propertyPath.addNode(node);
             }
-            node.setName(name);
-            node.setKind(ElementKind.PROPERTY); // enforce it
             return new NodeBuilderCustomizableContextImpl(parent, messageTemplate, propertyPath);
         }
 
         @Override
         public LeafNodeBuilderCustomizableContext addBeanNode() {
             final NodeImpl node = new NodeImpl.BeanNodeImpl();
-            node.setKind(ElementKind.BEAN);
             propertyPath.addNode(node);
             return new LeafNodeBuilderCustomizableContextImpl(parent, messageTemplate, propertyPath);
         }
@@ -157,7 +154,6 @@ public class ConstraintValidatorContextI
                 parent.validationContext.getParameterNameProvider().getParameterNames(method);
             final NodeImpl node = new NodeImpl.ParameterNodeImpl(parameters.get(index), index);
             node.setParameterIndex(index);
-            node.setKind(ElementKind.PARAMETER);
             if (!propertyPath.isRootPath()) {
                 propertyPath.removeLeafNode();
             }
@@ -185,7 +181,7 @@ public class ConstraintValidatorContextI
                 "At least one custom message must be created if the default error message gets disabled.");
         }
 
-        List<ValidationListener.Error> returnedErrorMessages = new ArrayList<ValidationListener.Error>(errorMessages);
+        List<ValidationListener.Error> returnedErrorMessages = new ArrayList<>(errorMessages);
         if (!defaultDisabled) {
             returnedErrorMessages.add(new ValidationListener.Error(getDefaultConstraintMessageTemplate(),
                 validationContext.getPropertyPath(), null));

Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintValidatorIdentity.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintValidatorIdentity.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintValidatorIdentity.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintValidatorIdentity.java Tue May  2 04:53:20 2017
@@ -19,6 +19,8 @@
 
 package org.apache.bval.jsr;
 
+import java.util.Objects;
+
 import javax.validation.ConstraintValidator;
 import javax.validation.Path;
 
@@ -120,12 +122,7 @@ final class ConstraintValidatorIdentity
      */
     @Override
     public int hashCode() {
-        final int prime = 31;
-        int result = 1;
-        result = prime * result + ((this.bean == null) ? 0 : this.bean.hashCode());
-        result = prime * result + ((this.path == null) ? 0 : this.path.hashCode());
-        result = prime * result + ((this.constraintValidator == null) ? 0 : this.constraintValidator.hashCode());
-        return result;
+        return Objects.hash(bean, path, constraintValidator);
     }
 
 }

Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintViolationImpl.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintViolationImpl.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintViolationImpl.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintViolationImpl.java Tue May  2 04:53:20 2017
@@ -23,6 +23,7 @@ import javax.validation.metadata.Constra
 import java.io.Serializable;
 import java.lang.annotation.ElementType;
 import java.util.Arrays;
+import java.util.Objects;
 
 /**
  * Description: Describe a constraint validation defect.<br/>
@@ -171,45 +172,28 @@ class ConstraintViolationImpl<T> impleme
      */
     @Override
     public String toString() {
-        return "ConstraintViolationImpl{" + "rootBean=" + rootBean + ", propertyPath='" + propertyPath + '\''
-            + ", message='" + message + '\'' + ", leafBean=" + leafBean + ", value=" + value + '}';
+        return String.format("%s{rootBean=%s, propertyPath='%s', message='%s', leafBean=%s, value=%s}",
+            ConstraintViolationImpl.class.getSimpleName(), rootBean, propertyPath, message, leafBean, value);
     }
 
     @Override
     public boolean equals(Object o) {
-        if (this == o)
+        if (this == o) {
             return true;
-        if (o == null || getClass() != o.getClass())
+        }
+        if (o == null || !getClass().equals(o.getClass())) {
             return false;
+        }
 
+        @SuppressWarnings("rawtypes")
         ConstraintViolationImpl that = (ConstraintViolationImpl) o;
 
-        if (constraintDescriptor != null ? !constraintDescriptor.equals(that.constraintDescriptor)
-            : that.constraintDescriptor != null)
-            return false;
-        if (elementType != that.elementType)
-            return false;
-        if (leafBean != null ? !leafBean.equals(that.leafBean) : that.leafBean != null)
-            return false;
-        if (message != null ? !message.equals(that.message) : that.message != null)
-            return false;
-        if (messageTemplate != null ? !messageTemplate.equals(that.messageTemplate) : that.messageTemplate != null)
-            return false;
-        // Probably incorrect - comparing Object[] arrays with Arrays.equals
-        if (!Arrays.equals(parameters, that.parameters))
-            return false;
-        if (propertyPath != null ? !propertyPath.equals(that.propertyPath) : that.propertyPath != null)
-            return false;
-        if (returnValue != null ? !returnValue.equals(that.returnValue) : that.returnValue != null)
-            return false;
-        if (rootBean != null ? !rootBean.equals(that.rootBean) : that.rootBean != null)
-            return false;
-        if (rootBeanClass != null ? !rootBeanClass.equals(that.rootBeanClass) : that.rootBeanClass != null)
-            return false;
-        if (value != null ? !value.equals(that.value) : that.value != null)
-            return false;
-
-        return true;
+        return Objects.equals(constraintDescriptor, that.constraintDescriptor) && elementType == that.elementType
+            && Objects.equals(leafBean, that.leafBean) && Objects.equals(message, that.message)
+            && Objects.equals(messageTemplate, that.messageTemplate) && Arrays.equals(parameters, that.parameters)
+            && Objects.equals(propertyPath, that.propertyPath) && Objects.equals(returnValue, that.returnValue)
+            && Objects.equals(rootBean, that.rootBean) && Objects.equals(rootBeanClass, that.rootBeanClass)
+            && Objects.equals(value, that.value);
     }
 
     @Override

Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/DefaultConstraintValidatorFactory.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/DefaultConstraintValidatorFactory.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/DefaultConstraintValidatorFactory.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/DefaultConstraintValidatorFactory.java Tue May  2 04:53:20 2017
@@ -32,8 +32,7 @@ import java.util.concurrent.CopyOnWriteA
  * Description: create constraint instances with the default / no-arg constructor <br/>
  */
 public class DefaultConstraintValidatorFactory implements ConstraintValidatorFactory, Closeable {
-    private final Collection<BValExtension.Releasable<?>> releasables =
-        new CopyOnWriteArrayList<BValExtension.Releasable<?>>();
+    private final Collection<BValExtension.Releasable<?>> releasables = new CopyOnWriteArrayList<>();
     private volatile Boolean useCdi = null; // store it to avoid NoClassDefFoundError when cdi is not present (it is slow) + lazily (to wait cdi is started)
 
     /**
@@ -49,9 +48,7 @@ public class DefaultConstraintValidatorF
                 if (useCdi == null) {
                     try {
                         useCdi = BValExtension.getBeanManager() != null;
-                    } catch (final NoClassDefFoundError error) {
-                        useCdi = Boolean.FALSE;
-                    } catch (final Exception e) {
+                    } catch (NoClassDefFoundError | Exception error) {
                         useCdi = Boolean.FALSE;
                     }
                 }
@@ -69,10 +66,7 @@ public class DefaultConstraintValidatorF
                         return instance.getInstance();
                     }
                     throw new IllegalStateException("Can't create " + constraintClass.getName());
-                } catch (final Exception e) {
-                    return constraintClass.newInstance();
-                } catch (final NoClassDefFoundError error) {
-                    return constraintClass.newInstance();
+                } catch (Exception | NoClassDefFoundError e) {
                 }
             }
             return constraintClass.newInstance();

Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/DefaultMessageInterpolator.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/DefaultMessageInterpolator.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/DefaultMessageInterpolator.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/DefaultMessageInterpolator.java Tue May  2 04:53:20 2017
@@ -54,10 +54,10 @@ public class DefaultMessageInterpolator
     private Locale defaultLocale;
 
     /** User specified resource bundles hashed against their locale. */
-    private final Map<Locale, ResourceBundle> userBundlesMap = new ConcurrentHashMap<Locale, ResourceBundle>();
+    private final Map<Locale, ResourceBundle> userBundlesMap = new ConcurrentHashMap<>();
 
     /** Builtin resource bundles hashed against their locale. */
-    private final Map<Locale, ResourceBundle> defaultBundlesMap = new ConcurrentHashMap<Locale, ResourceBundle>();
+    private final Map<Locale, ResourceBundle> defaultBundlesMap = new ConcurrentHashMap<>();
 
     private final MessageEvaluator evaluator;
 
@@ -83,12 +83,12 @@ public class DefaultMessageInterpolator
             userBundlesMap.put(defaultLocale, resourceBundle);
         }
 
-        MessageEvaluator ev = null;
+        MessageEvaluator ev;
         try {
             ev = MessageEvaluator.class
                 .cast(getClass().getClassLoader().loadClass("org.apache.bval.el.ELFacade").newInstance());
         } catch (final Throwable e) { // can be exception or error
-            // no-op
+            ev = null;
         }
         evaluator = ev;
     }
@@ -170,47 +170,42 @@ public class DefaultMessageInterpolator
      * @return the resource bundle or <code>null</code> if none is found.
      */
     private ResourceBundle getFileBasedResourceBundle(Locale locale) {
-        ResourceBundle rb = null;
+        ResourceBundle rb;
         final ClassLoader classLoader = Reflection.getClassLoader(DefaultMessageInterpolator.class);
         if (classLoader != null) {
             rb = loadBundle(classLoader, locale, USER_VALIDATION_MESSAGES + " not found by thread local classloader");
-        }
-
+        } else {
         // 2011-03-27 jw: No privileged action required.
         // A class can always access the classloader of itself and of subclasses.
-        if (rb == null) {
             rb = loadBundle(getClass().getClassLoader(), locale,
                 USER_VALIDATION_MESSAGES + " not found by validator classloader");
         }
         if (LOG_FINEST) {
-            if (rb != null) {
-                log.log(Level.FINEST, String.format("%s found", USER_VALIDATION_MESSAGES));
-            } else {
+            if (rb == null) {
                 log.log(Level.FINEST, String.format("%s not found. Delegating to %s", USER_VALIDATION_MESSAGES,
                     DEFAULT_VALIDATION_MESSAGES));
+            } else {
+                log.log(Level.FINEST, String.format("%s found", USER_VALIDATION_MESSAGES));
             }
         }
         return rb;
     }
 
     private ResourceBundle loadBundle(ClassLoader classLoader, Locale locale, String message) {
-        ResourceBundle rb = null;
         try {
-            rb = ResourceBundle.getBundle(USER_VALIDATION_MESSAGES, locale, classLoader);
+            return ResourceBundle.getBundle(USER_VALIDATION_MESSAGES, locale, classLoader);
         } catch (final MissingResourceException e) {
             log.fine(message);
         }
-        return rb;
+        return null;
     }
 
     private String replaceVariables(String message, ResourceBundle bundle, Locale locale, boolean recurse) {
         final Matcher matcher = messageParameterPattern.matcher(message);
         final StringBuffer sb = new StringBuffer(64);
-        String resolvedParameterValue;
         while (matcher.find()) {
             final String parameter = matcher.group(1);
-            resolvedParameterValue = resolveParameter(parameter, bundle, locale, recurse);
-
+            String resolvedParameterValue = resolveParameter(parameter, bundle, locale, recurse);
             matcher.appendReplacement(sb, sanitizeForAppendReplacement(resolvedParameterValue));
         }
         matcher.appendTail(sb);
@@ -242,13 +237,13 @@ public class DefaultMessageInterpolator
     private String resolveParameter(String parameterName, ResourceBundle bundle, Locale locale, boolean recurse) {
         String parameterValue;
         try {
-            if (bundle != null) {
+            if (bundle == null) {
+                parameterValue = parameterName;
+            } else {
                 parameterValue = bundle.getString(removeCurlyBrace(parameterName));
                 if (recurse) {
                     parameterValue = replaceVariables(parameterValue, bundle, locale, recurse);
                 }
-            } else {
-                parameterValue = parameterName;
             }
         } catch (final MissingResourceException e) {
             // return parameter itself

Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/DefaultValidationProviderResolver.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/DefaultValidationProviderResolver.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/DefaultValidationProviderResolver.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/DefaultValidationProviderResolver.java Tue May  2 04:53:20 2017
@@ -38,6 +38,11 @@ public class DefaultValidationProviderRe
     //TODO - Spec recommends caching per classloader
     private static final String SPI_CFG = "META-INF/services/javax.validation.spi.ValidationProvider";
 
+    private static ClassLoader getCurrentClassLoader() {
+        ClassLoader cl = Thread.currentThread().getContextClassLoader();
+        return cl == null ? DefaultValidationProviderResolver.class.getClassLoader() : cl;
+    }
+
     /**
      * {@inheritDoc}
      */
@@ -46,43 +51,28 @@ public class DefaultValidationProviderRe
         List<ValidationProvider<?>> providers = new ArrayList<ValidationProvider<?>>();
         try {
             // get our classloader
-            ClassLoader cl = Thread.currentThread().getContextClassLoader();
-            if (cl == null)
-                cl = DefaultValidationProviderResolver.class.getClassLoader();
+            ClassLoader cl = getCurrentClassLoader();
             // find all service provider cfgs
             Enumeration<URL> cfgs = cl.getResources(SPI_CFG);
             while (cfgs.hasMoreElements()) {
                 final URL url = cfgs.nextElement();
-                BufferedReader br = null;
-                try {
-                    br = new BufferedReader(new InputStreamReader(url.openStream()), 256);
-                    String line = br.readLine();
-                    // cfgs may contain multiple providers and/or comments
-                    while (line != null) {
-                        line = line.trim();
-                        if (!line.startsWith("#")) {
-                            try {
-                                // try loading the specified class
-                                @SuppressWarnings("rawtypes")
-                                final Class<? extends ValidationProvider> providerType =
-                                    cl.loadClass(line).asSubclass(ValidationProvider.class);
-                                // create an instance to return
-                                providers
-                                    .add(Reflection.newInstance(providerType.asSubclass(ValidationProvider.class)));
-
-                            } catch (ClassNotFoundException e) {
-                                throw new ValidationException(
-                                    "Failed to load provider " + line + " configured in file " + url, e);
-                            }
+                try (BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()), 256)) {
+                    br.lines().filter(s -> s.charAt(0) != '#').map(String::trim).forEach(line -> {
+                        // cfgs may contain multiple providers and/or comments
+                        try {
+                            // try loading the specified class
+                            @SuppressWarnings("rawtypes")
+                            final Class<? extends ValidationProvider> providerType =
+                                cl.loadClass(line).asSubclass(ValidationProvider.class);
+                            // create an instance to return
+                            providers.add(Reflection.newInstance(providerType));
+                        } catch (ClassNotFoundException e) {
+                            throw new ValidationException(
+                                "Failed to load provider " + line + " configured in file " + url, e);
                         }
-                        line = br.readLine();
-                    }
+                    });
                 } catch (IOException e) {
                     throw new ValidationException("Error trying to read " + url, e);
-                } finally {
-                    if (br != null) {
-                        br.close();
-                    }
                 }
             }
         } catch (IOException e) {

Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ElementDescriptorImpl.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ElementDescriptorImpl.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ElementDescriptorImpl.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ElementDescriptorImpl.java Tue May  2 04:53:20 2017
@@ -27,19 +27,19 @@ import javax.validation.metadata.GroupCo
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.CopyOnWriteArraySet;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 /**
  * Description: MetaData class<br/>
  */
 public abstract class ElementDescriptorImpl implements ElementDescriptor {
-    private final Set<GroupConversionDescriptor> groupConversions =
-        new CopyOnWriteArraySet<GroupConversionDescriptor>();
+    private final Set<GroupConversionDescriptor> groupConversions = new CopyOnWriteArraySet<>();
     private boolean cascaded;
-    private final Collection<Object> validated = new CopyOnWriteArraySet<Object>();
+    private final Collection<Object> validated = new CopyOnWriteArraySet<>();
 
     /**
      * Get a set of {@link ConstraintDescriptor}s from the specified array of
@@ -49,13 +49,8 @@ public abstract class ElementDescriptorI
      * @return {@link ConstraintDescriptor} set
      */
     protected static Set<ConstraintDescriptor<?>> getConstraintDescriptors(final Validation[] validations) {
-        final Set<ConstraintDescriptor<?>> result = new HashSet<ConstraintDescriptor<?>>(validations.length);
-        for (Validation validation : validations) {
-            if (validation instanceof ConstraintValidation<?>) {
-                result.add((ConstraintValidation<?>) validation);
-            }
-        }
-        return result;
+        return Stream.of(validations).filter(ConstraintValidation.class::isInstance)
+            .<ConstraintDescriptor<?>> map(ConstraintDescriptor.class::cast).collect(Collectors.toSet());
     }
 
     /** the MetaBean of this element */
@@ -66,7 +61,7 @@ public abstract class ElementDescriptorI
 
     private Set<ConstraintDescriptor<?>> constraintDescriptors;
 
-    private final Map<Group, Group> groupMapping = new HashMap<Group, Group>();
+    private final Map<Group, Group> groupMapping = new HashMap<>();
 
     /**
      * Create a new ElementDescriptorImpl instance.
@@ -105,9 +100,9 @@ public abstract class ElementDescriptorI
      * {@inheritDoc}
      */
     @Override
-    @SuppressWarnings({ "unchecked", "rawtypes" })
     public ElementDescriptor.ConstraintFinder findConstraints() {
-        return new ConstraintFinderImpl(metaBean, new HashSet(constraintDescriptors));
+        return new ConstraintFinderImpl(metaBean, constraintDescriptors.stream()
+            .<ConstraintValidation<?>> map(ConstraintValidation.class::cast).collect(Collectors.toSet()));
     }
 
     /**
@@ -115,7 +110,7 @@ public abstract class ElementDescriptorI
      */
     @Override
     public Set<ConstraintDescriptor<?>> getConstraintDescriptors() {
-        return constraintDescriptors.isEmpty() ? Collections.<ConstraintDescriptor<?>> emptySet()
+        return constraintDescriptors.isEmpty() ? Collections.emptySet()
             : Collections.unmodifiableSet(constraintDescriptors);
     }
 

Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/GraphBeanIdentity.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/GraphBeanIdentity.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/GraphBeanIdentity.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/GraphBeanIdentity.java Tue May  2 04:53:20 2017
@@ -18,6 +18,8 @@
  */
 package org.apache.bval.jsr;
 
+import java.util.Objects;
+
 /**
  * Class that stores the needed properties to avoid circular paths when
  * validating an object graph.
@@ -80,32 +82,16 @@ public class GraphBeanIdentity {
      */
     @Override
     public boolean equals(Object obj) {
-
         if (this == obj) {
             return true;
         }
-
-        if (obj == null) {
-            return false;
-        }
-
         if (!(obj instanceof GraphBeanIdentity)) {
             return false;
         }
-
         GraphBeanIdentity other = (GraphBeanIdentity) obj;
 
-        // Bean ref must be the same
-        if (this.bean != other.bean) {
-            return false;
-        }
-
-        // Group ref must be the same
-        if (this.group != other.group) {
-            return false;
-        }
-
-        return true;
+        // Bean ref must be the same; Group ref must be the same
+        return bean == other.bean && group == other.group;
     }
 
     /**
@@ -113,11 +99,7 @@ public class GraphBeanIdentity {
      */
     @Override
     public int hashCode() {
-        final int prime = 31;
-        int result = 1;
-        result = prime * result + ((this.bean == null) ? 0 : this.bean.hashCode());
-        result = prime * result + ((this.group == null) ? 0 : this.group.hashCode());
-        return result;
+        return Objects.hash(bean, group);
     }
 
 }

Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/GroupValidationContextImpl.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/GroupValidationContextImpl.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/GroupValidationContextImpl.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/GroupValidationContextImpl.java Tue May  2 04:53:20 2017
@@ -44,7 +44,8 @@ import java.util.Set;
 /**
  * Description: instance per validation process, not thread-safe<br/>
  */
-final class GroupValidationContextImpl<T> extends BeanValidationContext<ConstraintValidationListener<T>>
+final class GroupValidationContextImpl<T>
+    extends BeanValidationContext<ConstraintValidationListener<T>, GraphBeanIdentity, Set<PathImpl>>
     implements GroupValidationContext<T>, MessageInterpolator.Context {
 
     private final MessageInterpolator messageResolver;
@@ -67,7 +68,7 @@ final class GroupValidationContextImpl<T
      * contains the validation constraints that have already been processed
      * during this validation routine (as part of a previous group match)
      */
-    private HashSet<ConstraintValidatorIdentity> validatedConstraints = new HashSet<ConstraintValidatorIdentity>();
+    private Set<ConstraintValidatorIdentity> validatedConstraints = new HashSet<>();
 
     private ConstraintValidation<?> constraintValidation;
     private final TraversableResolver traversableResolver;
@@ -90,7 +91,7 @@ final class GroupValidationContextImpl<T
     public GroupValidationContextImpl(ConstraintValidationListener<T> listener, MessageInterpolator aMessageResolver,
         TraversableResolver traversableResolver, ParameterNameProvider parameterNameProvider,
         ConstraintValidatorFactory constraintValidatorFactory, MetaBean rootMetaBean) {
-        super(listener, new HashMap<GraphBeanIdentity, Set<PathImpl>>());
+        super(listener, new HashMap<>());
         this.messageResolver = aMessageResolver;
         this.constraintValidatorFactory = constraintValidatorFactory;
         this.traversableResolver = CachingTraversableResolver.cacheFor(traversableResolver);
@@ -166,30 +167,21 @@ final class GroupValidationContextImpl<T
     /**
      * {@inheritDoc} Here, state equates to bean identity + group.
      */
-    @SuppressWarnings("unchecked")
     @Override
     public boolean collectValidated() {
-
         // Combination of bean+group+owner (owner is currently ignored)
-        GraphBeanIdentity gbi = new GraphBeanIdentity(getBean(), getCurrentGroup().getGroup(), getCurrentOwner());
+        final GraphBeanIdentity gbi = new GraphBeanIdentity(getBean(), getCurrentGroup().getGroup(), getCurrentOwner());
 
-        Set<PathImpl> validatedPathsForGBI = (Set<PathImpl>) validatedObjects.get(gbi);
-        if (validatedPathsForGBI == null) {
-            validatedPathsForGBI = new HashSet<PathImpl>();
-            validatedObjects.put(gbi, validatedPathsForGBI);
-        }
+        final Set<PathImpl> validatedPathsForGBI = validatedObjects.computeIfAbsent(gbi, k -> new HashSet<>());
 
         // If any of the paths is a subpath of the current path, there is a
         // circular dependency, so return false
-        for (PathImpl validatedPath : validatedPathsForGBI) {
-            if (path.isSubPathOf(validatedPath)) {
-                return false;
-            }
+        if (validatedPathsForGBI.stream().anyMatch(path::isSubPathOf)) {
+            return false;
         }
 
         // Else, add the currentPath to the set of validatedPaths
-        validatedPathsForGBI.add(PathImpl.copy(path));
-        return true;
+        return validatedPathsForGBI.add(PathImpl.copy(path));
     }
 
     /**
@@ -300,15 +292,11 @@ final class GroupValidationContextImpl<T
      */
     @Override
     public Object getValidatedValue() {
-        if (getMetaProperty() != null) {
-            return getPropertyValue(constraintValidation.getAccess());
-        } else {
-            return getBean();
-        }
+        return getMetaProperty() == null ? getBean() : getPropertyValue(constraintValidation.getAccess());
     }
 
     @Override
-    public <T> T unwrap(Class<T> type) {
+    public <U> U unwrap(Class<U> type) {
         if (type.isInstance(this)) {
             return type.cast(this);
         }

Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/InvocableElementDescriptor.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/InvocableElementDescriptor.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/InvocableElementDescriptor.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/InvocableElementDescriptor.java Tue May  2 04:53:20 2017
@@ -31,12 +31,11 @@ import java.util.Set;
 import java.util.concurrent.CopyOnWriteArraySet;
 
 public class InvocableElementDescriptor extends ElementDescriptorImpl implements ProcedureDescriptor {
-    private static final CopyOnWriteArraySet<ConstraintValidation<?>> NO_CONSTRAINTS =
-        new CopyOnWriteArraySet<ConstraintValidation<?>>();
+    private static final CopyOnWriteArraySet<ConstraintValidation<?>> NO_CONSTRAINTS = new CopyOnWriteArraySet<>();
 
     private ReturnValueDescriptor returnValueDescriptor;
     private CrossParameterDescriptor crossParameterDescriptor;
-    private final List<ParameterDescriptor> parameterDescriptors = new ArrayList<ParameterDescriptor>();
+    private final List<ParameterDescriptor> parameterDescriptors = new ArrayList<>();
 
     protected InvocableElementDescriptor(final MetaBean metaBean, final Class<?> elementClass,
         final Validation[] validations) {
@@ -99,6 +98,7 @@ public class InvocableElementDescriptor
         return new ConstraintFinderImpl(metaBean, NO_CONSTRAINTS);
     }
 
+    @SuppressWarnings("unchecked")
     @Override
     public Set<ConstraintDescriptor<?>> getConstraintDescriptors() {
         return Set.class.cast(NO_CONSTRAINTS);

Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/JsrMetaBeanFactory.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/JsrMetaBeanFactory.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/JsrMetaBeanFactory.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/JsrMetaBeanFactory.java Tue May  2 04:53:20 2017
@@ -18,6 +18,24 @@
  */
 package org.apache.bval.jsr;
 
+import java.lang.annotation.Annotation;
+import java.lang.annotation.ElementType;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.validation.ConstraintDeclarationException;
+import javax.validation.GroupDefinitionException;
+import javax.validation.GroupSequence;
+import javax.validation.groups.ConvertGroup;
+import javax.validation.groups.Default;
+
 import org.apache.bval.MetaBeanFactory;
 import org.apache.bval.jsr.groups.Group;
 import org.apache.bval.jsr.util.ClassHelper;
@@ -36,24 +54,6 @@ import org.apache.bval.util.reflection.R
 import org.apache.commons.weaver.privilizer.Privilizing;
 import org.apache.commons.weaver.privilizer.Privilizing.CallTo;
 
-import javax.validation.ConstraintDeclarationException;
-import javax.validation.GroupDefinitionException;
-import javax.validation.GroupSequence;
-import javax.validation.groups.ConvertGroup;
-import javax.validation.groups.Default;
-
-import java.lang.annotation.Annotation;
-import java.lang.annotation.ElementType;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
 /**
  * Description: process the class annotations for JSR303 constraint validations to build the MetaBean with information
  * from annotations and JSR303 constraint mappings (defined in xml)<br/>
@@ -64,6 +64,11 @@ public class JsrMetaBeanFactory implemen
     // of dubious utility as it's static :/
     protected static final Logger log = Logger.getLogger(JsrMetaBeanFactory.class.getName());
 
+    private static boolean isAccessor(Method m) {
+        return m.getParameterCount() == 0 && !Void.TYPE.equals(m.getReturnType()) && (m.getName().startsWith("get")
+            || m.getName().startsWith("is") && Boolean.TYPE.equals(m.getReturnType()));
+    }
+
     /** {@link javax.validation.ValidatorFactory} used */
     protected final ApacheValidatorFactory factory;
 
@@ -93,7 +98,7 @@ public class JsrMetaBeanFactory implemen
 
             // process class, superclasses and interfaces
             final List<Class<?>> classSequence =
-                ClassHelper.fillFullClassHierarchyAsList(new ArrayList<Class<?>>(), beanClass);
+                ClassHelper.fillFullClassHierarchyAsList(new ArrayList<>(), beanClass);
 
             // start with superclasses and go down the hierarchy so that
             // the child classes are processed last to have the chance to
@@ -130,7 +135,7 @@ public class JsrMetaBeanFactory implemen
                 new AppendValidationToMeta(metabean));
         }
 
-        final Collection<String> missingValid = new ArrayList<String>();
+        final Collection<String> missingValid = new ArrayList<>();
 
         final Field[] fields = Reflection.getDeclaredFields(beanClass);
         for (final Field field : fields) {
@@ -147,23 +152,18 @@ public class JsrMetaBeanFactory implemen
                     new AppendValidationToMeta(metaProperty)) && create) {
                     metabean.putProperty(metaProperty.getName(), null);
                 }
-
                 if (field.getAnnotation(ConvertGroup.class) != null) {
                     missingValid.add(field.getName());
                 }
             }
         }
-        final Method[] methods = Reflection.getDeclaredMethods(beanClass);
-        for (final Method method : methods) {
+        for (final Method method : Reflection.getDeclaredMethods(beanClass)) {
             if (method.isSynthetic() || method.isBridge()) {
                 continue;
             }
-            String propName = null;
-            if (method.getParameterTypes().length == 0) {
-                propName = MethodAccess.getPropertyName(method);
-            }
-            if (propName != null) {
-                if (!factory.getAnnotationIgnores().isIgnoreAnnotations(method)) {
+            if (method.getParameterCount() == 0) {
+                String propName = MethodAccess.getPropertyName(method);
+                if (propName != null && !factory.getAnnotationIgnores().isIgnoreAnnotations(method)) {
                     AccessStrategy access = new MethodAccess(propName, method);
                     MetaProperty metaProperty = metabean.getProperty(propName);
                     boolean create = metaProperty == null;
@@ -208,7 +208,7 @@ public class JsrMetaBeanFactory implemen
             if (access == null) { // class level
                 meta = null;
             } else if (access.getElementType() == ElementType.METHOD
-                && !metaConstraint.getMember().getName().startsWith("get")) { // TODO: better getter test
+                && !isAccessor((Method) metaConstraint.getMember())) {
                 final Method method = Method.class.cast(metaConstraint.getMember());
                 meta = metabean.getMethod(method);
                 final MetaMethod metaMethod;
@@ -220,15 +220,15 @@ public class JsrMetaBeanFactory implemen
                     metaMethod = MetaMethod.class.cast(meta);
                 }
                 final Integer index = metaConstraint.getIndex();
-                if (index != null && index >= 0) {
+                if (index == null || index.intValue() < 0) {
+                    metaMethod.addAnnotation(metaConstraint.getAnnotation());
+                } else {
                     MetaParameter param = metaMethod.getParameter(index);
                     if (param == null) {
                         param = new MetaParameter(metaMethod, index);
                         metaMethod.addParameter(index, param);
                     }
                     param.addAnnotation(metaConstraint.getAnnotation());
-                } else {
-                    metaMethod.addAnnotation(metaConstraint.getAnnotation());
                 }
                 continue;
             } else if (access.getElementType() == ElementType.CONSTRUCTOR) {
@@ -243,15 +243,15 @@ public class JsrMetaBeanFactory implemen
                     metaConstructor = MetaConstructor.class.cast(meta);
                 }
                 final Integer index = metaConstraint.getIndex();
-                if (index != null && index >= 0) {
+                if (index == null || index.intValue() < 0) {
+                    metaConstructor.addAnnotation(metaConstraint.getAnnotation());
+                } else {
                     MetaParameter param = metaConstructor.getParameter(index);
                     if (param == null) {
                         param = new MetaParameter(metaConstructor, index);
                         metaConstructor.addParameter(index, param);
                     }
                     param.addAnnotation(metaConstraint.getAnnotation());
-                } else {
-                    metaConstructor.addAnnotation(metaConstraint.getAnnotation());
                 }
                 continue;
             } else { // property level
@@ -292,16 +292,15 @@ public class JsrMetaBeanFactory implemen
         List<Group> groupSeq = metabean.getFeature(key);
         if (groupSeq == null) {
             groupSeq =
-                metabean.initFeature(key, new ArrayList<Group>(annotation == null ? 1 : annotation.value().length));
+                metabean.initFeature(key, new ArrayList<>(annotation == null ? 1 : annotation.value().length));
         }
         Class<?>[] groupClasses = factory.getDefaultSequence(beanClass);
         if (groupClasses == null || groupClasses.length == 0) {
             if (annotation == null) {
                 groupSeq.add(Group.DEFAULT);
                 return;
-            } else {
-                groupClasses = annotation.value();
             }
+            groupClasses = annotation.value();
         }
         boolean containsDefault = false;
         for (final Class<?> groupClass : groupClasses) {

Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/NodeBuilderCustomizableContextImpl.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/NodeBuilderCustomizableContextImpl.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/NodeBuilderCustomizableContextImpl.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/NodeBuilderCustomizableContextImpl.java Tue May  2 04:53:20 2017
@@ -54,7 +54,6 @@ public class NodeBuilderCustomizableCont
     public ConstraintValidatorContext.ConstraintViolationBuilder.NodeBuilderCustomizableContext addPropertyNode(
         String name) {
         final NodeImpl node = new NodeImpl.PropertyNodeImpl(name);
-        node.setKind(ElementKind.PROPERTY);
         path.addNode(node);
         return this;
     }
@@ -62,7 +61,6 @@ public class NodeBuilderCustomizableCont
     @Override
     public ConstraintValidatorContext.ConstraintViolationBuilder.LeafNodeBuilderCustomizableContext addBeanNode() {
         final NodeImpl node = new NodeImpl.BeanNodeImpl();
-        node.setKind(ElementKind.BEAN);
         path.addNode(node);
         return new LeafNodeBuilderCustomizableContextImpl(context, template, path);
     }

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

Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ParameterAccess.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ParameterAccess.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ParameterAccess.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ParameterAccess.java Tue May  2 04:53:20 2017
@@ -23,6 +23,7 @@ import org.apache.bval.util.AccessStrate
 
 import java.lang.annotation.ElementType;
 import java.lang.reflect.Type;
+import java.util.Objects;
 
 /**
  * Implementation of {@link org.apache.bval.util.AccessStrategy} for method parameters.
@@ -73,15 +74,17 @@ public class ParameterAccess extends Acc
      */
     @Override
     public String getPropertyName() {
-        return "" + paramIdx;
+        return Integer.toString(paramIdx);
     }
 
     @Override
     public boolean equals(Object o) {
-        if (this == o)
+        if (this == o) {
             return true;
-        if (o == null || getClass() != o.getClass())
+        }
+        if (o == null || !getClass().equals(o.getClass())) {
             return false;
+        }
 
         final ParameterAccess that = (ParameterAccess) o;
         return paramIdx == that.paramIdx && paramType.equals(that.paramType);
@@ -89,8 +92,6 @@ public class ParameterAccess extends Acc
 
     @Override
     public int hashCode() {
-        int result = paramType.hashCode();
-        result = 31 * result + paramIdx;
-        return result;
+        return Objects.hash(paramType, paramIdx);
     }
 }

Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ParameterDescriptorImpl.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ParameterDescriptorImpl.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ParameterDescriptorImpl.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/ParameterDescriptorImpl.java Tue May  2 04:53:20 2017
@@ -30,8 +30,7 @@ import java.util.concurrent.CopyOnWriteA
  * Description: {@link javax.validation.metadata.ParameterDescriptor} implementation.<br/>
  */
 public class ParameterDescriptorImpl extends ElementDescriptorImpl implements ParameterDescriptor {
-    private final Set<GroupConversionDescriptor> groupConversions =
-        new CopyOnWriteArraySet<GroupConversionDescriptor>();
+    private final Set<GroupConversionDescriptor> groupConversions = new CopyOnWriteArraySet<>();
     private final String name;
     private int index;
 

Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/PropertyDescriptorImpl.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/PropertyDescriptorImpl.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/PropertyDescriptorImpl.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/PropertyDescriptorImpl.java Tue May  2 04:53:20 2017
@@ -64,7 +64,7 @@ class PropertyDescriptorImpl extends Ele
      */
     @Override
     public String toString() {
-        return "PropertyDescriptorImpl{" + "returnType=" + elementClass + ", propertyPath='" + propertyPath + '\''
-            + '}';
+        return String.format("%s{returnType=%s, propertyPath='%s'}", PropertyDescriptorImpl.class.getSimpleName(),
+            elementClass, propertyPath);
     }
 }

Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/groups/Group.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/groups/Group.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/groups/Group.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/groups/Group.java Tue May  2 04:53:20 2017
@@ -18,6 +18,8 @@
  */
 package org.apache.bval.jsr.groups;
 
+import java.util.Objects;
+
 import javax.validation.groups.Default;
 
 /**
@@ -52,7 +54,7 @@ public final class Group {
      */
     @Override
     public String toString() {
-        return "Group{" + "group=" + group + '}';
+        return String.format("Group{group=%s}", Group.class.getSimpleName(), group);
     }
 
     /**
@@ -71,13 +73,10 @@ public final class Group {
         if (this == o) {
             return true;
         }
-        if (o == null || getClass() != o.getClass()) {
+        if (o == null || !getClass().equals(o.getClass())) {
             return false;
         }
-
-        Group group1 = (Group) o;
-
-        return group != null ? group.equals(group1.group) : group1.group == null;
+        return Objects.equals(group, ((Group) o).group);
     }
 
     /**
@@ -85,6 +84,6 @@ public final class Group {
      */
     @Override
     public int hashCode() {
-        return (group != null ? group.hashCode() : 0);
+        return Objects.hashCode(group);
     }
 }

Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/groups/GroupConversionDescriptorImpl.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/groups/GroupConversionDescriptorImpl.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/groups/GroupConversionDescriptorImpl.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/groups/GroupConversionDescriptorImpl.java Tue May  2 04:53:20 2017
@@ -26,10 +26,9 @@ public class GroupConversionDescriptorIm
 
     public GroupConversionDescriptorImpl(final Group from, final Group to) {
         this.from = from.getGroup();
-        if (this.from.getAnnotation(GroupSequence.class) != null) {
+        if (this.from.isAnnotationPresent(GroupSequence.class)) {
             throw new ConstraintDeclarationException("from() can't get a group sequence");
         }
-
         this.to = to.getGroup();
     }
 

Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/groups/Groups.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/groups/Groups.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/groups/Groups.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/groups/Groups.java Tue May  2 04:53:20 2017
@@ -29,12 +29,12 @@ import java.util.List;
  * @author Roman Stumm
  */
 public class Groups {
-    /** The list of single groups. */
-    final List<Group> groups = new LinkedList<Group>();
-
     /** The list of sequences. */
-    final List<List<Group>> sequences = new LinkedList<List<Group>>();
+    private final List<List<Group>> sequences = new LinkedList<>();
 
+    /** The list of single groups. */
+    final List<Group> groups = new LinkedList<>();
+    
     /**
      * Get the Groups.
      * @return {@link List} of {@link Group}.

Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/groups/GroupsComputer.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/groups/GroupsComputer.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/groups/GroupsComputer.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/groups/GroupsComputer.java Tue May  2 04:53:20 2017
@@ -37,7 +37,7 @@ import java.util.concurrent.ConcurrentHa
  * Implementation is thread-safe.
  */
 public class GroupsComputer {
-    public static final Class<?>[] DEFAULT_GROUP = new Class<?>[] { Default.class };
+    public static final Class<?>[] DEFAULT_GROUP = { Default.class };
 
     /** The default group array used in case any of the validate methods is called without a group. */
     private static final Groups DEFAULT_GROUPS;
@@ -46,7 +46,7 @@ public class GroupsComputer {
     }
 
     /** caching resolved groups in a thread-safe map. */
-    private final Map<Class<?>, List<Group>> resolvedSequences = new ConcurrentHashMap<Class<?>, List<Group>>();
+    private final Map<Class<?>, List<Group>> resolvedSequences = new ConcurrentHashMap<>();
 
     /**
      * Compute groups from an array of group classes.
@@ -72,7 +72,7 @@ public class GroupsComputer {
      * @return {@link Groups}
      */
     protected Groups computeGroups(Collection<Class<?>> groups) {
-        if (groups == null || groups.size() == 0) {
+        if (groups == null || groups.isEmpty()) {
             throw new IllegalArgumentException("At least one group has to be specified.");
         }
 
@@ -80,9 +80,8 @@ public class GroupsComputer {
             if (clazz == null) {
                 throw new IllegalArgumentException("At least one group has to be specified.");
             }
-
             if (!clazz.isInterface()) {
-                throw new ValidationException("A group has to be an interface. " + clazz.getName() + " is not.");
+                throw new ValidationException("A group must be an interface. " + clazz.getName() + " is not.");
             }
         }
 
@@ -114,7 +113,7 @@ public class GroupsComputer {
         if (resolvedSequences.containsKey(clazz)) {
             sequence = resolvedSequences.get(clazz);
         } else {
-            sequence = resolveSequence(clazz, anno, new HashSet<Class<?>>());
+            sequence = resolveSequence(clazz, anno, new HashSet<>());
         }
         chain.insertSequence(sequence);
     }
@@ -123,10 +122,9 @@ public class GroupsComputer {
         Set<Class<?>> processedSequences) {
         if (processedSequences.contains(group)) {
             throw new GroupDefinitionException("Cyclic dependency in groups definition");
-        } else {
-            processedSequences.add(group);
         }
-        List<Group> resolvedGroupSequence = new LinkedList<Group>();
+        processedSequences.add(group);
+        List<Group> resolvedGroupSequence = new LinkedList<>();
         Class<?>[] sequenceArray = sequenceAnnotation.value();
         for (Class<?> clazz : sequenceArray) {
             GroupSequence anno = clazz.getAnnotation(GroupSequence.class);

Modified: bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/parameter/DefaultParameterNameProvider.java
URL: http://svn.apache.org/viewvc/bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/parameter/DefaultParameterNameProvider.java?rev=1793432&r1=1793431&r2=1793432&view=diff
==============================================================================
--- bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/parameter/DefaultParameterNameProvider.java (original)
+++ bval/branches/bv2.x/bval-jsr/src/main/java/org/apache/bval/jsr/parameter/DefaultParameterNameProvider.java Tue May  2 04:53:20 2017
@@ -18,15 +18,21 @@
  */
 package org.apache.bval.jsr.parameter;
 
-import javax.validation.ParameterNameProvider;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Method;
-import java.util.ArrayList;
 import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+
+import javax.validation.ParameterNameProvider;
 
 public class DefaultParameterNameProvider implements ParameterNameProvider {
     private static final String ARG = "arg";
 
+    private static List<String> names(final int length) {
+        return IntStream.range(0, length).mapToObj(i -> ARG + i).collect(Collectors.toList());
+    }
+
     @Override
     public List<String> getParameterNames(Constructor<?> constructor) {
         return names(constructor.getParameterTypes().length);
@@ -36,12 +42,4 @@ public class DefaultParameterNameProvide
     public List<String> getParameterNames(Method method) {
         return names(method.getParameterTypes().length);
     }
-
-    private static List<String> names(final int length) {
-        final List<String> list = new ArrayList<String>();
-        for (int i = 0; i < length; i++) {
-            list.add(ARG + i);
-        }
-        return list;
-    }
 }



Mime
View raw message