bval-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1766445 [3/3] - in /bval/trunk: ./ bundle/ bval-core/ 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/util/ bval-core/src/main/java/org/apache/bval/util/reflec...
Date Mon, 24 Oct 2016 21:02:02 GMT
Modified: bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/groups/Group.java
URL: http://svn.apache.org/viewvc/bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/groups/Group.java?rev=1766445&r1=1766444&r2=1766445&view=diff
==============================================================================
--- bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/groups/Group.java (original)
+++ bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/groups/Group.java Mon Oct 24 21:02:02
2016
@@ -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);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 */
+    public boolean isDefault() {
+        return Default.class.equals(group);
+    }
+
+    /**
+     * {@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;
     }
 
     /**

Modified: bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/resolver/DefaultTraversableResolver.java
URL: http://svn.apache.org/viewvc/bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/resolver/DefaultTraversableResolver.java?rev=1766445&r1=1766444&r2=1766445&view=diff
==============================================================================
--- bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/resolver/DefaultTraversableResolver.java
(original)
+++ bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/resolver/DefaultTraversableResolver.java
Mon Oct 24 21:02:02 2016
@@ -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
     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
 
         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);
         }
     }
 

Modified: bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/util/PathNavigation.java
URL: http://svn.apache.org/viewvc/bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/util/PathNavigation.java?rev=1766445&r1=1766444&r2=1766445&view=diff
==============================================================================
--- bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/util/PathNavigation.java (original)
+++ bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/util/PathNavigation.java Mon Oct
24 21:02:02 2016
@@ -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);

Modified: bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/util/ValidationContextTraversal.java
URL: http://svn.apache.org/viewvc/bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/util/ValidationContextTraversal.java?rev=1766445&r1=1766444&r2=1766445&view=diff
==============================================================================
--- bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/util/ValidationContextTraversal.java
(original)
+++ bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/util/ValidationContextTraversal.java
Mon Oct 24 21:02:02 2016
@@ -27,8 +27,8 @@ import org.apache.bval.util.AccessStrate
 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
     /**
      * 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();

Modified: bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/xml/ValidationMappingParser.java
URL: http://svn.apache.org/viewvc/bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/xml/ValidationMappingParser.java?rev=1766445&r1=1766444&r2=1766445&view=diff
==============================================================================
--- bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/xml/ValidationMappingParser.java
(original)
+++ bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/xml/ValidationMappingParser.java
Mon Oct 24 21:02:02 2016
@@ -50,9 +50,9 @@ import org.apache.bval.jsr.ConstraintAnn
 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<?>>();

Modified: bval/trunk/bval-jsr/src/test/java/org/apache/bval/constraints/HasStringValidator.java
URL: http://svn.apache.org/viewvc/bval/trunk/bval-jsr/src/test/java/org/apache/bval/constraints/HasStringValidator.java?rev=1766445&r1=1766444&r2=1766445&view=diff
==============================================================================
--- bval/trunk/bval-jsr/src/test/java/org/apache/bval/constraints/HasStringValidator.java
(original)
+++ bval/trunk/bval-jsr/src/test/java/org/apache/bval/constraints/HasStringValidator.java
Mon Oct 24 21:02:02 2016
@@ -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 implemen
 
     @Override
     public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext)
{
-        return s == null || ArrayUtils.contains(values, s);
+        return s == null || ObjectUtils.arrayContains(values, s);
     }
 }

Modified: bval/trunk/bval-tck11/work-tests-suite.xml
URL: http://svn.apache.org/viewvc/bval/trunk/bval-tck11/work-tests-suite.xml?rev=1766445&r1=1766444&r2=1766445&view=diff
==============================================================================
--- bval/trunk/bval-tck11/work-tests-suite.xml (original)
+++ bval/trunk/bval-tck11/work-tests-suite.xml Mon Oct 24 21:02:02 2016
@@ -21,9 +21,9 @@ think to add -Dvalidation.provider=org.a
 <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>

Modified: bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanInfos.java
URL: http://svn.apache.org/viewvc/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanInfos.java?rev=1766445&r1=1766444&r2=1766445&view=diff
==============================================================================
--- bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanInfos.java (original)
+++ bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanInfos.java Mon Oct
24 21:02:02 2016
@@ -21,7 +21,7 @@ import com.thoughtworks.xstream.annotati
 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);
             }

Modified: bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaElement.java
URL: http://svn.apache.org/viewvc/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaElement.java?rev=1766445&r1=1766444&r2=1766445&view=diff
==============================================================================
--- bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaElement.java (original)
+++ bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaElement.java Mon Oct
24 21:02:02 2016
@@ -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 XMLF
     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());

Modified: bval/trunk/pom.xml
URL: http://svn.apache.org/viewvc/bval/trunk/pom.xml?rev=1766445&r1=1766444&r2=1766445&view=diff
==============================================================================
--- bval/trunk/pom.xml (original)
+++ bval/trunk/pom.xml Mon Oct 24 21:02:02 2016
@@ -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