bval-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r1643469 - in /bval/branches/bval-11/bval-core/src/main/java/org/apache/bval: ./ model/ routines/ util/
Date Fri, 05 Dec 2014 23:30:10 GMT
Author: mbenson
Date: Fri Dec  5 23:30:09 2014
New Revision: 1643469

URL: http://svn.apache.org/r1643469
Log:
some cleanup

Modified:
    bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/BeanValidationContext.java
    bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/BeanValidator.java
    bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/ConstructorAccess.java
    bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/DynamicMetaBean.java
    bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/MetaBeanCache.java
    bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/MetaBeanManager.java
    bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/ValidationResults.java
    bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/model/FeaturesCapable.java
    bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/model/Meta.java
    bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/model/MetaBean.java
    bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/model/MetaConstructor.java
    bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/model/MetaInvocable.java
    bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/model/MetaMethod.java
    bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/model/MetaParameter.java
    bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/model/MetaProperty.java
    bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/routines/EMailValidationUtils.java
    bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/util/BValVersion.java
    bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/util/FieldAccess.java
    bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/util/MethodAccess.java
    bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/util/PropertyAccess.java
    bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/util/ValidationHelper.java

Modified: bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/BeanValidationContext.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/BeanValidationContext.java?rev=1643469&r1=1643468&r2=1643469&view=diff
==============================================================================
--- bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/BeanValidationContext.java
(original)
+++ bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/BeanValidationContext.java
Fri Dec  5 23:30:09 2014
@@ -156,19 +156,16 @@ public class BeanValidationContext<T ext
      */
     public Object getPropertyValue() {
         if (access == null) { // undefined access strategy
-            return getPropertyValue(
-                  new PropertyAccess(bean.getClass(), metaProperty.getName()));
-        } else {
-            return getPropertyValue(access);
+            return getPropertyValue(new PropertyAccess(bean.getClass(), metaProperty.getName()));
         }
+        return getPropertyValue(access);
     }
 
     /**
      * {@inheritDoc}
      * Caches retrieved value.
      */
-    public Object getPropertyValue(AccessStrategy access)
-          throws IllegalArgumentException, IllegalStateException {
+    public Object getPropertyValue(AccessStrategy access) throws IllegalArgumentException,
IllegalStateException {
         if (propertyValue == UNKNOWN || (this.access != access && !fixed)) {
             propertyValue = access.get(bean);
             this.access = access;
@@ -293,8 +290,8 @@ public class BeanValidationContext<T ext
      * {@inheritDoc}
      */
     public String toString() {
-        return "BeanValidationContext{ bean=" + bean + ", metaProperty=" + metaProperty +
-              ", propertyValue=" + propertyValue + '}';
+        return "BeanValidationContext{ bean=" + bean + ", metaProperty=" + metaProperty +
", propertyValue="
+            + propertyValue + '}';
     }
 
     /**

Modified: bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/BeanValidator.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/BeanValidator.java?rev=1643469&r1=1643468&r2=1643469&view=diff
==============================================================================
--- bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/BeanValidator.java (original)
+++ bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/BeanValidator.java Fri Dec
 5 23:30:09 2014
@@ -107,8 +107,9 @@ public class BeanValidator<T extends Val
             for (int i = 0; i < parameters.length; i++) {
                 for (Annotation anno : annotations[i]) {
                     if (anno instanceof Validate) {
-                        if (context == null)
+                        if (context == null) {
                             context = createContext();
+                        }
                         if (determineMetaBean((Validate) anno, parameters[i], context)) {
                             ValidationHelper.validateContext(context, new BeanValidatorCallback(context),
                                 treatMapsLikeBeans);
@@ -117,7 +118,7 @@ public class BeanValidator<T extends Val
                     }
                 }
             }
-            return context != null ? context.getListener() : null;
+            return context == null ? null : context.getListener();
         }
         return null;
     }
@@ -133,17 +134,17 @@ public class BeanValidator<T extends Val
      */
     protected <VL extends ValidationListener> boolean determineMetaBean(Validate validate,
Object parameter,
         ValidationContext<VL> context) {
-        if (validate.value().length() == 0) {
-            if (parameter == null)
+        if (validate.value().isEmpty()) {
+            if (parameter == null) {
                 return false;
+            }
             Class<?> beanClass;
-            if (parameter instanceof Collection<?>) { // do not validate empty
-                                                      // collection
+            if (parameter instanceof Collection<?>) { // do not validate empty collection
                 Collection<?> coll = ((Collection<?>) parameter);
-                if (coll.isEmpty())
+                if (coll.isEmpty()) {
                     return false;
-                beanClass = coll.iterator().next().getClass(); // get first
-                                                               // object
+                }
+                beanClass = coll.iterator().next().getClass(); // get first object
             } else if (parameter.getClass().isArray()) {
                 beanClass = parameter.getClass().getComponentType();
             } else {
@@ -214,8 +215,7 @@ public class BeanValidator<T extends Val
      */
     protected <VL extends ValidationListener> void validateRelatedBean(ValidationContext<VL>
context, MetaProperty prop) {
         AccessStrategy[] access = prop.getFeature(Features.Property.REF_CASCADE);
-        if (access == null && prop.getMetaBean() != null) { // single property
-                                                            // access strategy
+        if (access == null && prop.getMetaBean() != null) { // single property access
strategy
             // save old values from context
             final Object bean = context.getBean();
             final MetaBean mbean = context.getMetaBean();

Modified: bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/ConstructorAccess.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/ConstructorAccess.java?rev=1643469&r1=1643468&r2=1643469&view=diff
==============================================================================
--- bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/ConstructorAccess.java (original)
+++ bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/ConstructorAccess.java Fri
Dec  5 23:30:09 2014
@@ -58,8 +58,12 @@ public class ConstructorAccess extends A
     }
 
     public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
 
         final ConstructorAccess that = (ConstructorAccess) o;
         return constructor.equals(that.constructor);

Modified: bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/DynamicMetaBean.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/DynamicMetaBean.java?rev=1643469&r1=1643468&r2=1643469&view=diff
==============================================================================
--- bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/DynamicMetaBean.java (original)
+++ bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/DynamicMetaBean.java Fri
Dec  5 23:30:09 2014
@@ -43,7 +43,6 @@ public final class DynamicMetaBean exten
      */
     @Override
     public MetaBean resolveMetaBean(Object bean) {
-        return bean instanceof Class<?> ?
-                finder.findForClass((Class<?>) bean) : finder.findForClass(bean.getClass());
+        return bean instanceof Class<?> ? finder.findForClass((Class<?>) bean)
: finder.findForClass(bean.getClass());
     }
 }

Modified: bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/MetaBeanCache.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/MetaBeanCache.java?rev=1643469&r1=1643468&r2=1643469&view=diff
==============================================================================
--- bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/MetaBeanCache.java (original)
+++ bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/MetaBeanCache.java Fri Dec
 5 23:30:09 2014
@@ -92,8 +92,7 @@ public class MetaBeanCache implements Me
      */
     public void cache(MetaBean beanInfo) {
         cacheById.put(beanInfo.getId(), beanInfo);
-        if (beanInfo.getBeanClass() != null &&
-                beanInfo.getId().equals(beanInfo.getBeanClass().getName())) {
+        if (beanInfo.getBeanClass() != null && beanInfo.getId().equals(beanInfo.getBeanClass().getName()))
{
             cacheByClass.putIfAbsent(beanInfo.getBeanClass(), beanInfo);
         }
     }
@@ -104,8 +103,7 @@ public class MetaBeanCache implements Me
      */
     public void removeFromCache(MetaBean beanInfo) {
         cacheById.remove(beanInfo.getId());
-        if (beanInfo.getBeanClass() != null &&
-                beanInfo.getId().equals(beanInfo.getBeanClass().getName())) {
+        if (beanInfo.getBeanClass() != null && beanInfo.getId().equals(beanInfo.getBeanClass().getName()))
{
             cacheByClass.remove(beanInfo.getBeanClass());
         }
     }

Modified: bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/MetaBeanManager.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/MetaBeanManager.java?rev=1643469&r1=1643468&r2=1643469&view=diff
==============================================================================
--- bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/MetaBeanManager.java (original)
+++ bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/MetaBeanManager.java Fri
Dec  5 23:30:09 2014
@@ -140,11 +140,12 @@ public class MetaBeanManager implements
      */
     protected void computeRelatedMetaBean(MetaProperty prop, String beanRef) {
         Class<?> beanType = prop.getFeature(REF_BEAN_TYPE);
-        if (beanType != null) {
+        if (beanType == null) {
+            if (prop.getFeature(REF_CASCADE) != null) { // dynamic type resolution:
+                prop.setMetaBean(new DynamicMetaBean(this));
+            }
+        } else {
             prop.setMetaBean(findForClass(beanType));
-        } else if (prop.getFeature(REF_CASCADE) != null) { // dynamic type
-                                                           // resolution:
-            prop.setMetaBean(new DynamicMetaBean(this));
         }
     }
 

Modified: bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/ValidationResults.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/ValidationResults.java?rev=1643469&r1=1643468&r2=1643469&view=diff
==============================================================================
--- bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/ValidationResults.java (original)
+++ bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/ValidationResults.java Fri
Dec  5 23:30:09 2014
@@ -103,7 +103,9 @@ public class ValidationResults implement
      * @see {@link Error#getReason()}
      */
     protected void addToReasonBucket(Error error) {
-        if (error.getReason() == null) return;
+        if (error.getReason() == null) {
+            return;
+        }
 
         List<Error> errors = errorsByReason.get(error.getReason());
         if (errors == null) {
@@ -119,7 +121,9 @@ public class ValidationResults implement
      * @see {@link Error#getOwner()}
      */
     protected void addToOwnerBucket(Error error) {
-        if (error.getOwner() == null) return;
+        if (error.getOwner() == null) {
+            return;
+        }
 
         Map<String, List<Error>> errors = errorsByOwner.get(error.getOwner());
         if (errors == null) {
@@ -140,7 +144,9 @@ public class ValidationResults implement
      * @return map
      */
     public Map<String, List<Error>> getErrorsByReason() {
-        if (errorsByReason == null) return Collections.emptyMap();
+        if (errorsByReason == null) {
+            return Collections.emptyMap();
+        }
         return errorsByReason;
     }
 
@@ -151,7 +157,9 @@ public class ValidationResults implement
      * @return map
      */
     public Map<Object, Map<String, List<Error>>> getErrorsByOwner() {
-        if (errorsByOwner == null) return Collections.emptyMap();
+        if (errorsByOwner == null) {
+            return Collections.emptyMap();
+        }
         return errorsByOwner;
     }
 
@@ -160,14 +168,19 @@ public class ValidationResults implement
      * @return true when there are NO errors in this validation result
      */
     public boolean isEmpty() {
-        if (errorsByReason == null ||
-              (errorsByReason.isEmpty() && errorsByOwner.isEmpty())) return true;
+        if (errorsByReason == null || (errorsByReason.isEmpty() && errorsByOwner.isEmpty()))
{
+            return true;
+        }
         for (List<Error> list : errorsByReason.values()) {
-            if (!list.isEmpty()) return false;
+            if (!list.isEmpty()) {
+                return false;
+            }
         }
         for (Map<String, List<Error>> map : errorsByOwner.values()) {
             for (List<Error> list : map.values()) {
-                if (!list.isEmpty()) return false;
+                if (!list.isEmpty()) {
+                    return false;
+                }
             }
         }
         return true;
@@ -180,7 +193,8 @@ public class ValidationResults implement
      * @see {@link Error#getReason()}
      */
     public boolean hasErrorForReason(String reason) {
-        if (errorsByReason == null) return false;
+        if (errorsByReason == null)
+            return false;
         List<Error> errors = errorsByReason.get(reason);
         return errors != null && !errors.isEmpty();
     }
@@ -193,18 +207,23 @@ public class ValidationResults implement
      * @return boolean
      */
     public boolean hasError(Object bean, String propertyName) {
-        if (errorsByOwner == null) return false;
+        if (errorsByOwner == null) {
+            return false;
+        }
         Map<String, List<Error>> errors = errorsByOwner.get(bean);
-        if (errors == null) return false;
-        if (propertyName != null) {
-            List<Error> list = errors.get(propertyName);
-            return list != null && !list.isEmpty();
-        } else {
+        if (errors == null) {
+            return false;
+        }
+        if (propertyName == null) {
             for (List<Error> list : errors.values()) {
-                if (!list.isEmpty()) return true;
+                if (!list.isEmpty()) {
+                    return true;
+                }
             }
             return false;
         }
+        List<Error> list = errors.get(propertyName);
+        return list != null && !list.isEmpty();
     }
 
     /**

Modified: bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/model/FeaturesCapable.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/model/FeaturesCapable.java?rev=1643469&r1=1643468&r2=1643469&view=diff
==============================================================================
--- bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/model/FeaturesCapable.java
(original)
+++ bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/model/FeaturesCapable.java
Fri Dec  5 23:30:09 2014
@@ -91,11 +91,9 @@ public abstract class FeaturesCapable im
     }
 
     public <T> T initFeature(final String key, final T value) {
-        final T old = (T) features.putIfAbsent(key, value);
-        if (old != null) {
-            return old;
-        }
-        return value;
+        @SuppressWarnings("unchecked")
+        final T faster = (T) features.putIfAbsent(key, value);
+        return faster == null ? value : faster;
     }
 
     /**
@@ -169,11 +167,13 @@ public abstract class FeaturesCapable im
      * @return true if found
      */
     public boolean hasValidation(Validation aValidation) {
-        if (validations == null)
+        if (validations == null) {
             return false;
+        }
         for (Validation validation : validations) {
-            if (validation.equals(aValidation))
+            if (validation.equals(aValidation)) {
                 return true;
+            }
         }
         return false;
     }

Modified: bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/model/Meta.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/model/Meta.java?rev=1643469&r1=1643468&r2=1643469&view=diff
==============================================================================
--- bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/model/Meta.java (original)
+++ bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/model/Meta.java Fri Dec
 5 23:30:09 2014
@@ -18,7 +18,9 @@
  */
 package org.apache.bval.model;
 
-public class Meta extends FeaturesCapable {
+public abstract class Meta extends FeaturesCapable {
+    private static final long serialVersionUID = 1L;
+
     protected MetaBean parentMetaBean;
 
     public MetaBean getParentMetaBean() {

Modified: bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/model/MetaBean.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/model/MetaBean.java?rev=1643469&r1=1643468&r2=1643469&view=diff
==============================================================================
--- bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/model/MetaBean.java (original)
+++ bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/model/MetaBean.java Fri
Dec  5 23:30:09 2014
@@ -263,17 +263,11 @@ public class MetaBean extends FeaturesCa
     }
 
     public MetaMethod getMethod(final Method method) {
-        if (methods == null) {
-            return null;
-        }
-        return methods.get(method);
+        return methods == null ? null : methods.get(method);
     }
 
     public MetaConstructor getConstructor(final Constructor<?> constructor) {
-        if (constructors == null) {
-            return null;
-        }
-        return constructors.get(constructor);
+        return constructors == null ? null : constructors.get(constructor);
     }
 
     protected static class FieldComparator implements Comparator<String> {
@@ -311,10 +305,10 @@ public class MetaBean extends FeaturesCa
 
         private int fieldIndex(final String o2) {
             final Integer idx = fields.get(o2);
-            if (idx != null) {
-                return idx;
+            if (idx == null) {
+                return Integer.MIN_VALUE; // to avoid collision and false positive in get()
due to equals
             }
-            return Integer.MIN_VALUE; // to avoid collision and false positive in get() due
to equals
+            return idx;
         }
     }
 
@@ -337,10 +331,7 @@ public class MetaBean extends FeaturesCa
             }
 
             final int i = o1.getName().compareTo(o2.getName());
-            if (i != 0) {
-                return i;
-            }
-            return methods.get(o1) - methods.get(o2);
+            return i == 0 ? methods.get(o1) - methods.get(o2) : i;
         }
     }
 
@@ -359,10 +350,7 @@ public class MetaBean extends FeaturesCa
             }
 
             final int i = o1.getName().compareTo(o2.getName());
-            if (i != 0) {
-                return i;
-            }
-            return constructors.get(o1) - constructors.get(o2);
+            return i == 0 ? constructors.get(o1) - constructors.get(o2) : i;
         }
     }
 }

Modified: bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/model/MetaConstructor.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/model/MetaConstructor.java?rev=1643469&r1=1643468&r2=1643469&view=diff
==============================================================================
--- bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/model/MetaConstructor.java
(original)
+++ bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/model/MetaConstructor.java
Fri Dec  5 23:30:09 2014
@@ -19,6 +19,8 @@ package org.apache.bval.model;
 import java.lang.reflect.Constructor;
 
 public class MetaConstructor extends MetaInvocable {
+    private static final long serialVersionUID = 1L;
+
     private final Constructor<?> constructor;
 
     public MetaConstructor(final MetaBean metabean, final Constructor<?> constructor)
{

Modified: bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/model/MetaInvocable.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/model/MetaInvocable.java?rev=1643469&r1=1643468&r2=1643469&view=diff
==============================================================================
--- bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/model/MetaInvocable.java
(original)
+++ bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/model/MetaInvocable.java
Fri Dec  5 23:30:09 2014
@@ -16,15 +16,15 @@
  */
 package org.apache.bval.model;
 
-import java.lang.annotation.Annotation;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
 
-public abstract class MetaInvocable extends Meta {
+public abstract class MetaInvocable extends MetaAnnotated {
+    private static final long serialVersionUID = 1L;
+
     private Map<Integer, MetaParameter> parameters = new HashMap<Integer, MetaParameter>();
-    private Annotation[] annotations = new Annotation[0];
 
     public Collection<MetaParameter> getParameters() {
         return new ArrayList<MetaParameter>(parameters.values());
@@ -34,17 +34,6 @@ public abstract class MetaInvocable exte
         parameters.put(idx, param);
     }
 
-    public Annotation[] getAnnotations() {
-        return annotations;
-    }
-
-    public void addAnnotation(final Annotation annotation) {
-        final Annotation[] a = new Annotation[annotations.length + 1];
-        System.arraycopy(annotations, 0, a, 0, annotations.length);
-        a[a.length - 1] = annotation;
-        this.annotations = a;
-    }
-
     public MetaParameter getParameter(final Integer index) {
         return parameters.get(index);
     }

Modified: bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/model/MetaMethod.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/model/MetaMethod.java?rev=1643469&r1=1643468&r2=1643469&view=diff
==============================================================================
--- bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/model/MetaMethod.java (original)
+++ bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/model/MetaMethod.java Fri
Dec  5 23:30:09 2014
@@ -19,6 +19,8 @@ package org.apache.bval.model;
 import java.lang.reflect.Method;
 
 public class MetaMethod extends MetaInvocable {
+    private static final long serialVersionUID = 1L;
+
     private final Method method;
 
     public MetaMethod(final MetaBean parent, final Method method) {

Modified: bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/model/MetaParameter.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/model/MetaParameter.java?rev=1643469&r1=1643468&r2=1643469&view=diff
==============================================================================
--- bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/model/MetaParameter.java
(original)
+++ bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/model/MetaParameter.java
Fri Dec  5 23:30:09 2014
@@ -16,12 +16,11 @@
  */
 package org.apache.bval.model;
 
-import java.lang.annotation.Annotation;
+public class MetaParameter extends MetaAnnotated {
+    private static final long serialVersionUID = 1L;
 
-public class MetaParameter extends Meta {
     private final MetaInvocable invocable;
     private final Integer index;
-    private Annotation[] annotations = new Annotation[0];
 
     public MetaParameter(final MetaInvocable metaMethod, final Integer index) {
         this.invocable = metaMethod;
@@ -36,14 +35,8 @@ public class MetaParameter extends Meta
         return index;
     }
 
-    public Annotation[] getAnnotations() {
-        return annotations;
-    }
-
-    public void addAnnotation(final Annotation annotation) {
-        final Annotation[] a = new Annotation[annotations.length + 1];
-        System.arraycopy(annotations, 0, a, 0, annotations.length);
-        a[a.length - 1] = annotation;
-        this.annotations = a;
+    @Override
+    public MetaBean getParentMetaBean() {
+        return invocable.getParentMetaBean();
     }
 }

Modified: bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/model/MetaProperty.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/model/MetaProperty.java?rev=1643469&r1=1643468&r2=1643469&view=diff
==============================================================================
--- bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/model/MetaProperty.java
(original)
+++ bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/model/MetaProperty.java
Fri Dec  5 23:30:09 2014
@@ -27,8 +27,7 @@ import java.lang.reflect.Type;
  * @see Validation
  * @see MetaBean
  */
-public class MetaProperty extends Meta
-      implements Cloneable, Features.Property {
+public class MetaProperty extends Meta implements Cloneable, Features.Property {
     private static final long serialVersionUID = 1L;
 
     private String name;
@@ -95,13 +94,11 @@ public class MetaProperty extends Meta
      * @return Class, <code>null</code> if cannot be determined
      */
     public Class<?> getTypeClass() {
-        Type targetType = type instanceof DynaType ? ((DynaType) type)
-                .getRawType() : type;
+        Type targetType = type instanceof DynaType ? ((DynaType) type).getRawType() : type;
         if (targetType == null) {
             return null;
         }
-        Type assigningType = getParentMetaBean() == null ? null
-                : getParentMetaBean().getBeanClass();
+        Type assigningType = getParentMetaBean() == null ? null : getParentMetaBean().getBeanClass();
         return TypeUtils.getRawType(targetType, assigningType);
     }
 

Modified: bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/routines/EMailValidationUtils.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/routines/EMailValidationUtils.java?rev=1643469&r1=1643468&r2=1643469&view=diff
==============================================================================
--- bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/routines/EMailValidationUtils.java
(original)
+++ bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/routines/EMailValidationUtils.java
Fri Dec  5 23:30:09 2014
@@ -60,15 +60,17 @@ public class EMailValidationUtils {
     // TODO it would seem to make sense to move or reduce the visibility of this
     // method as it is more general than email.
     public static boolean isValid(Object value, Pattern aPattern) {
-        if (value == null)
+        if (value == null) {
             return true;
-        if (!(value instanceof CharSequence))
+        }
+        if (!(value instanceof CharSequence)) {
             return false;
+        }
         CharSequence seq = (CharSequence) value;
-        if (seq.length() == 0)
+        if (seq.length() == 0) {
             return true;
-        Matcher m = aPattern.matcher(seq);
-        return m.matches();
+        }
+        return aPattern.matcher(seq).matches();
     }
 
 }

Modified: bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/util/BValVersion.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/util/BValVersion.java?rev=1643469&r1=1643468&r2=1643469&view=diff
==============================================================================
--- bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/util/BValVersion.java (original)
+++ bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/util/BValVersion.java Fri
Dec  5 23:30:09 2014
@@ -24,6 +24,7 @@ import java.util.Properties;
 import java.util.StringTokenizer;
 
 import org.apache.bval.util.reflection.Reflection;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.weaver.privilizer.Privilizing;
 import org.apache.commons.weaver.privilizer.Privilizing.CallTo;
 
@@ -55,8 +56,7 @@ public class BValVersion {
     static {
         Properties revisionProps = new Properties();
         try {
-            InputStream in = BValVersion.class.getResourceAsStream
-                ("/META-INF/org.apache.bval.revision.properties");
+            InputStream in = BValVersion.class.getResourceAsStream("/META-INF/org.apache.bval.revision.properties");
             if (in != null) {
                 try {
                     revisionProps.load(in);
@@ -93,7 +93,7 @@ public class BValVersion {
         }
 
         String revision = revisionProps.getProperty("svn.revision");
-        if (revision == null || "".equals(revision.trim())) {
+        if (StringUtils.isBlank(revision)) {
             revision = "unknown";
         } else {
             tok = new StringTokenizer(revision, ":");
@@ -104,8 +104,9 @@ public class BValVersion {
                 } catch (Exception e) {
                 }
             }
-            if (strTok != null)
+            if (strTok != null) {
                 revision = strTok;
+            }
         }
 
         MAJOR_RELEASE = major;

Modified: bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/util/FieldAccess.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/util/FieldAccess.java?rev=1643469&r1=1643468&r2=1643469&view=diff
==============================================================================
--- bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/util/FieldAccess.java (original)
+++ bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/util/FieldAccess.java Fri
Dec  5 23:30:09 2014
@@ -88,8 +88,12 @@ public class FieldAccess extends AccessS
      * {@inheritDoc}
      */
     public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
 
         FieldAccess that = (FieldAccess) o;
 

Modified: bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/util/MethodAccess.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/util/MethodAccess.java?rev=1643469&r1=1643468&r2=1643469&view=diff
==============================================================================
--- bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/util/MethodAccess.java (original)
+++ bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/util/MethodAccess.java Fri
Dec  5 23:30:09 2014
@@ -123,8 +123,12 @@ public class MethodAccess extends Access
      * {@inheritDoc}
      */
     public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
 
         MethodAccess that = (MethodAccess) o;
 

Modified: bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/util/PropertyAccess.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/util/PropertyAccess.java?rev=1643469&r1=1643468&r2=1643469&view=diff
==============================================================================
--- bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/util/PropertyAccess.java
(original)
+++ bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/util/PropertyAccess.java
Fri Dec  5 23:30:09 2014
@@ -205,10 +205,12 @@ public class PropertyAccess extends Acce
      * {@inheritDoc}
      */
     public boolean equals(Object o) {
-        if (this == o)
+        if (this == o) {
             return true;
-        if (o == null || getClass() != o.getClass())
+        }
+        if (o == null || getClass() != o.getClass()) {
             return false;
+        }
 
         PropertyAccess that = (PropertyAccess) o;
 

Modified: bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/util/ValidationHelper.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/util/ValidationHelper.java?rev=1643469&r1=1643468&r2=1643469&view=diff
==============================================================================
--- bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/util/ValidationHelper.java
(original)
+++ bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/util/ValidationHelper.java
Fri Dec  5 23:30:09 2014
@@ -28,7 +28,6 @@ import org.apache.bval.model.ValidationL
 import java.util.List;
 import java.util.Map;
 
-
 /**
  * Stateless helper methods used by the validators.
  * 
@@ -110,10 +109,10 @@ public class ValidationHelper {
                 if (each == null) {
                     continue; // Null values are not validated
                 }
-                if (dyn != null) {
-                    context.setBean(each, dyn.resolveMetaBean(each));
-                } else {
+                if (dyn == null) {
                     context.setBean(each);
+                } else {
+                    context.setBean(each, dyn.resolveMetaBean(each));
                 }
                 s.validate();
             }
@@ -149,10 +148,10 @@ public class ValidationHelper {
                 if (each == null) {
                     continue; // Null values are not validated
                 }
-                if (dyn != null) {
-                    context.setBean(each, dyn.resolveMetaBean(each));
-                } else {
+                if (dyn == null) {
                     context.setBean(each);
+                } else {
+                    context.setBean(each, dyn.resolveMetaBean(each));
                 }
                 s.validate();
             }



Mime
View raw message