bval-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject [24/51] [abbrv] bval git commit: BVAL-151 trim down external dependencies
Date Fri, 03 Nov 2017 22:27:49 GMT
http://git-wip-us.apache.org/repos/asf/bval/blob/8dabb264/bval-jsr/src/main/java/org/apache/bval/jsr/groups/Group.java
----------------------------------------------------------------------
diff --git a/bval-jsr/src/main/java/org/apache/bval/jsr/groups/Group.java b/bval-jsr/src/main/java/org/apache/bval/jsr/groups/Group.java
index bdd8cc9..a5c595e 100644
--- a/bval-jsr/src/main/java/org/apache/bval/jsr/groups/Group.java
+++ b/bval-jsr/src/main/java/org/apache/bval/jsr/groups/Group.java
@@ -18,10 +18,10 @@
  */
 package org.apache.bval.jsr.groups;
 
-import org.apache.commons.lang3.ObjectUtils;
 
 import javax.validation.groups.Default;
 
+
 /**
  * Immutable object that wraps an interface representing a single group.
  */
@@ -61,16 +61,21 @@ public final class Group {
      * Learn whether the group represented is the default group.
      * @return boolean
      */
-	public boolean isDefault() {
-		return Default.class.equals(group);
-	}
+    public boolean isDefault() {
+        return Default.class.equals(group);
+    }
 
-	/**
-	 * {@inheritDoc}
-	 */
+    /**
+     * {@inheritDoc}
+     */
     @Override
-    public boolean equals(final Object o) {
-        return this == o || o instanceof Group && ObjectUtils.equals(group, ((Group)
o).group);
+    public boolean equals(Object o) {
+        if (this == o) { return true; }
+        if (o == null || getClass() != o.getClass()) { return false; }
+
+        Group group1 = (Group) o;
+
+        return group != null ? group.equals(group1.group) : group1.group == null;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/bval/blob/8dabb264/bval-jsr/src/main/java/org/apache/bval/jsr/resolver/DefaultTraversableResolver.java
----------------------------------------------------------------------
diff --git a/bval-jsr/src/main/java/org/apache/bval/jsr/resolver/DefaultTraversableResolver.java
b/bval-jsr/src/main/java/org/apache/bval/jsr/resolver/DefaultTraversableResolver.java
index 8cdbc00..e4cd2a2 100644
--- a/bval-jsr/src/main/java/org/apache/bval/jsr/resolver/DefaultTraversableResolver.java
+++ b/bval-jsr/src/main/java/org/apache/bval/jsr/resolver/DefaultTraversableResolver.java
@@ -17,7 +17,6 @@
 package org.apache.bval.jsr.resolver;
 
 import org.apache.bval.util.reflection.Reflection;
-import org.apache.commons.lang3.ClassUtils;
 import org.apache.commons.weaver.privilizer.Privilizing;
 import org.apache.commons.weaver.privilizer.Privilizing.CallTo;
 
@@ -79,7 +78,7 @@ public class DefaultTraversableResolver implements TraversableResolver,
CachingR
     private void initJpa() {
         final ClassLoader classLoader = Reflection.getClassLoader(DefaultTraversableResolver.class);
         try {
-            Reflection.getClass(classLoader, PERSISTENCE_UTIL_CLASSNAME);
+            Reflection.toClass(PERSISTENCE_UTIL_CLASSNAME, classLoader);
             if (LOG_FINEST) {
                 log.log(Level.FINEST, String.format("Found %s on classpath.", PERSISTENCE_UTIL_CLASSNAME));
             }
@@ -90,14 +89,13 @@ public class DefaultTraversableResolver implements TraversableResolver,
CachingR
 
         try {
             Class<? extends TraversableResolver> jpaAwareResolverClass =
-              (Class<? extends TraversableResolver>)
-                ClassUtils.getClass(classLoader, JPA_AWARE_TRAVERSABLE_RESOLVER_CLASSNAME,
true);
+              (Class<? extends TraversableResolver>) Reflection.toClass(JPA_AWARE_TRAVERSABLE_RESOLVER_CLASSNAME,
classLoader);
             jpaTR = jpaAwareResolverClass.newInstance();
             if (LOG_FINEST) {
                 log.log(Level.FINEST, String.format("Instantiated an instance of %s.", JPA_AWARE_TRAVERSABLE_RESOLVER_CLASSNAME));
             }
         } catch (final Exception e) {
-			log.log(Level.WARNING, String.format("Unable to load or instantiate JPA aware resolver
%s. All properties will per default be traversable.", JPA_AWARE_TRAVERSABLE_RESOLVER_CLASSNAME),
e);
+            log.log(Level.WARNING, String.format("Unable to load or instantiate JPA aware
resolver %s. All properties will per default be traversable.", JPA_AWARE_TRAVERSABLE_RESOLVER_CLASSNAME),
e);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/bval/blob/8dabb264/bval-jsr/src/main/java/org/apache/bval/jsr/util/PathNavigation.java
----------------------------------------------------------------------
diff --git a/bval-jsr/src/main/java/org/apache/bval/jsr/util/PathNavigation.java b/bval-jsr/src/main/java/org/apache/bval/jsr/util/PathNavigation.java
index 585fd87..1975301 100644
--- a/bval-jsr/src/main/java/org/apache/bval/jsr/util/PathNavigation.java
+++ b/bval-jsr/src/main/java/org/apache/bval/jsr/util/PathNavigation.java
@@ -16,8 +16,6 @@
  */
 package org.apache.bval.jsr.util;
 
-import org.apache.commons.lang3.StringEscapeUtils;
-
 import javax.validation.ValidationException;
 import java.io.StringWriter;
 import java.text.ParsePosition;
@@ -166,7 +164,7 @@ public class PathNavigation {
 
     /**
      * Handles an index/key. If the text contained between [] is surrounded by a pair of
" or ', it will be treated as a
-     * string which may contain Java escape sequences.
+     * string which may contain Java escape sequences. This function is only available if
commons-lang3 is available on the classpath!
      * 
      * @param path
      * @param pos
@@ -219,15 +217,20 @@ public class PathNavigation {
                     pos.next();
                     return w.toString();
                 }
-                int codePoints = StringEscapeUtils.UNESCAPE_JAVA.translate(path, here, w);
-                if (codePoints == 0) {
-                    w.write(Character.toChars(Character.codePointAt(path, here)));
-                    pos.next();
-                } else {
-                    for (int i = 0; i < codePoints; i++) {
-                        pos.plus(Character.charCount(Character.codePointAt(path, pos.getIndex())));
+                try {
+                    int codePoints = org.apache.commons.lang3.StringEscapeUtils.UNESCAPE_JAVA.translate(path,
here, w);
+                    if (codePoints == 0) {
+                        w.write(Character.toChars(Character.codePointAt(path, here)));
+                        pos.next();
+                    } else {
+                        for (int i = 0; i < codePoints; i++) {
+                            pos.plus(Character.charCount(Character.codePointAt(path, pos.getIndex())));
+                        }
                     }
                 }
+                catch (Exception e) {
+                    throw new RuntimeException("Java escaping in quotes is only supported
with Apache commons-lang3 on the classpath!");
+                }
             }
             // if reached, reset due to no ending quote found
             pos.setIndex(start);

http://git-wip-us.apache.org/repos/asf/bval/blob/8dabb264/bval-jsr/src/main/java/org/apache/bval/jsr/util/ValidationContextTraversal.java
----------------------------------------------------------------------
diff --git a/bval-jsr/src/main/java/org/apache/bval/jsr/util/ValidationContextTraversal.java
b/bval-jsr/src/main/java/org/apache/bval/jsr/util/ValidationContextTraversal.java
index 4a8bf02..27b1ca8 100644
--- a/bval-jsr/src/main/java/org/apache/bval/jsr/util/ValidationContextTraversal.java
+++ b/bval-jsr/src/main/java/org/apache/bval/jsr/util/ValidationContextTraversal.java
@@ -27,8 +27,8 @@ import org.apache.bval.util.AccessStrategy;
 import org.apache.bval.util.IndexedAccess;
 import org.apache.bval.util.KeyedAccess;
 import org.apache.bval.util.PropertyAccess;
-import org.apache.commons.lang3.ObjectUtils;
-import org.apache.commons.lang3.reflect.TypeUtils;
+import org.apache.bval.util.ObjectUtils;
+import org.apache.bval.util.reflection.TypeUtils;
 
 import java.lang.annotation.ElementType;
 import java.lang.reflect.Type;
@@ -160,8 +160,6 @@ public class ValidationContextTraversal extends CallbackProcedure {
     /**
      * If we currently have a property, navigate the context such that the property becomes
the bean, in preparation for
      * another property.
-     * 
-     * @param validationContext
      */
     public void moveDownIfNecessary() {
         MetaProperty mp = validationContext.getMetaProperty();

http://git-wip-us.apache.org/repos/asf/bval/blob/8dabb264/bval-jsr/src/main/java/org/apache/bval/jsr/xml/ValidationMappingParser.java
----------------------------------------------------------------------
diff --git a/bval-jsr/src/main/java/org/apache/bval/jsr/xml/ValidationMappingParser.java b/bval-jsr/src/main/java/org/apache/bval/jsr/xml/ValidationMappingParser.java
index f5d1a54..7e3ad46 100644
--- a/bval-jsr/src/main/java/org/apache/bval/jsr/xml/ValidationMappingParser.java
+++ b/bval-jsr/src/main/java/org/apache/bval/jsr/xml/ValidationMappingParser.java
@@ -50,9 +50,9 @@ import org.apache.bval.jsr.ConstraintAnnotationAttributes;
 import org.apache.bval.jsr.util.IOs;
 import org.apache.bval.util.FieldAccess;
 import org.apache.bval.util.MethodAccess;
+import org.apache.bval.util.ObjectUtils;
+import org.apache.bval.util.StringUtils;
 import org.apache.bval.util.reflection.Reflection;
-import org.apache.commons.lang3.ArrayUtils;
-import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.weaver.privilizer.Privileged;
 import org.apache.commons.weaver.privilizer.Privilizing;
 import org.apache.commons.weaver.privilizer.Privilizing.CallTo;
@@ -268,7 +268,7 @@ public class ValidationMappingParser {
         if (returnType.equals(Class.class)) {
             ClassLoader cl = Reflection.getClassLoader(ValidationMappingParser.class);
             try {
-                return Reflection.getClass(cl, toQualifiedClassName(value, defaultPackage));
+                return Reflection.toClass(toQualifiedClassName(value, defaultPackage), cl);
             } catch (Exception e) {
                 throw new ValidationException(e);
             }
@@ -327,7 +327,7 @@ public class ValidationMappingParser {
 
     private Class<?>[] getGroups(GroupsType groupsType, String defaultPackage) {
         if (groupsType == null) {
-            return ArrayUtils.EMPTY_CLASS_ARRAY;
+            return ObjectUtils.EMPTY_CLASS_ARRAY;
         }
 
         List<Class<?>> groupList = new ArrayList<Class<?>>();

http://git-wip-us.apache.org/repos/asf/bval/blob/8dabb264/bval-jsr/src/test/java/org/apache/bval/constraints/HasStringValidator.java
----------------------------------------------------------------------
diff --git a/bval-jsr/src/test/java/org/apache/bval/constraints/HasStringValidator.java b/bval-jsr/src/test/java/org/apache/bval/constraints/HasStringValidator.java
index ba293be..868a16e 100644
--- a/bval-jsr/src/test/java/org/apache/bval/constraints/HasStringValidator.java
+++ b/bval-jsr/src/test/java/org/apache/bval/constraints/HasStringValidator.java
@@ -18,11 +18,11 @@
  */
 package org.apache.bval.constraints;
 
-import org.apache.commons.lang3.ArrayUtils;
-
 import javax.validation.ConstraintValidator;
 import javax.validation.ConstraintValidatorContext;
 
+import org.apache.bval.util.ObjectUtils;
+
 /**
  * Description: <br/>
  */
@@ -36,6 +36,6 @@ public class HasStringValidator implements ConstraintValidator<HasValue,
String>
 
     @Override
     public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext)
{
-        return s == null || ArrayUtils.contains(values, s);
+        return s == null || ObjectUtils.arrayContains(values, s);
     }
 }

http://git-wip-us.apache.org/repos/asf/bval/blob/8dabb264/bval-tck11/work-tests-suite.xml
----------------------------------------------------------------------
diff --git a/bval-tck11/work-tests-suite.xml b/bval-tck11/work-tests-suite.xml
index bfe3037..6d25c5b 100644
--- a/bval-tck11/work-tests-suite.xml
+++ b/bval-tck11/work-tests-suite.xml
@@ -21,9 +21,9 @@ think to add -Dvalidation.provider=org.apache.bval.jsr303.ApacheValidationProvid
 <suite name="tmp" verbose="1">
   <test name="tmp">
     <classes>
-      <class name="org.hibernate.beanvalidation.tck.tests.integration.cdi.executable.ExecutableValidationTest">
+      <class name="org.hibernate.beanvalidation.tck.tests.constraints.customconstraint.CustomConstraintValidatorTest">
         <methods>
-
+          <include name="testIsValidIsCalledForEachValidation"/>
         </methods>
       </class>
     </classes>

http://git-wip-us.apache.org/repos/asf/bval/blob/8dabb264/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanInfos.java
----------------------------------------------------------------------
diff --git a/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanInfos.java b/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanInfos.java
index 3c4a165..ac8ed2f 100644
--- a/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanInfos.java
+++ b/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanInfos.java
@@ -21,7 +21,7 @@ import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
 import com.thoughtworks.xstream.annotations.XStreamImplicit;
 import com.thoughtworks.xstream.annotations.XStreamOmitField;
 import org.apache.bval.model.Validation;
-import org.apache.commons.lang3.ClassUtils;
+import org.apache.bval.util.reflection.Reflection;
 
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -107,7 +107,7 @@ public class XMLMetaBeanInfos {
         for (XMLMetaValidator xv : validators) {
             if (xv.getJava() != null) {
                 Validation validation =
-                        (Validation) ClassUtils.getClass(xv.getJava()).newInstance();
+                        (Validation) Reflection.toClass(xv.getJava()).newInstance();
                 xv.setValidation(validation);
                 map.put(xv.getId(), xv);
             }

http://git-wip-us.apache.org/repos/asf/bval/blob/8dabb264/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaElement.java
----------------------------------------------------------------------
diff --git a/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaElement.java b/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaElement.java
index 997d0d4..09da499 100644
--- a/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaElement.java
+++ b/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaElement.java
@@ -18,7 +18,7 @@ package org.apache.bval.xml;
 
 import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
 import org.apache.bval.model.MetaProperty;
-import org.apache.commons.lang3.ClassUtils;
+import org.apache.bval.util.reflection.Reflection;
 
 import static org.apache.bval.model.Features.Property.DENIED;
 import static org.apache.bval.model.Features.Property.HIDDEN;
@@ -124,7 +124,7 @@ public class XMLMetaElement extends XMLFeaturesCapable {
     public void mergeInto(MetaProperty prop) throws ClassNotFoundException {
         mergeFeaturesInto(prop);
         if (getType() != null && getType().length() > 0) {
-            prop.setType(ClassUtils.getClass(getType())); // enhancement: or use getGenericType()
?
+            prop.setType(Reflection.toClass(getType())); // enhancement: or use getGenericType()
?
         }
         if (getHidden() != null) {
             prop.putFeature(HIDDEN, getHidden().booleanValue());

http://git-wip-us.apache.org/repos/asf/bval/blob/8dabb264/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index fc2d6fb..39ce3e3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -321,6 +321,7 @@
                 <groupId>org.apache.commons</groupId>
                 <artifactId>commons-lang3</artifactId>
                 <version>3.5</version>
+                <optional>true</optional>
             </dependency>
             <dependency>
                 <groupId>commons-beanutils</groupId>


Mime
View raw message