bval-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject [22/50] bval git commit: permit overriding of built-in constraint validators per paragraph 2 of BV spec v2 section 8
Date Tue, 16 Oct 2018 17:31:26 GMT
permit overriding of built-in constraint validators per paragraph 2 of BV spec v2 section 8


Project: http://git-wip-us.apache.org/repos/asf/bval/repo
Commit: http://git-wip-us.apache.org/repos/asf/bval/commit/3f67257d
Tree: http://git-wip-us.apache.org/repos/asf/bval/tree/3f67257d
Diff: http://git-wip-us.apache.org/repos/asf/bval/diff/3f67257d

Branch: refs/heads/bv2
Commit: 3f67257d0c36db53d6e9b807cc9d65b1263d001c
Parents: 963ac52
Author: Matt Benson <mbenson@apache.org>
Authored: Wed Apr 4 10:31:33 2018 -0500
Committer: Matt Benson <mbenson@apache.org>
Committed: Tue Oct 16 12:28:20 2018 -0500

----------------------------------------------------------------------
 .../src/main/java/org/apache/bval/jsr/ConstraintCached.java  | 5 +----
 .../bval/jsr/metadata/DualValidationMappingProvider.java     | 8 ++++----
 2 files changed, 5 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/bval/blob/3f67257d/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintCached.java
----------------------------------------------------------------------
diff --git a/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintCached.java b/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintCached.java
index fa9e3df..5dbdef0 100644
--- a/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintCached.java
+++ b/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintCached.java
@@ -139,9 +139,6 @@ public class ConstraintCached {
             }
             configured = new DualValidationMappingProvider(AnnotationDeclaredValidatorMappingProvider.INSTANCE,
custom);
         }
-        // interpret spec as saying that default constraint validators are
-        // always present even when annotation-based validators
-        // have been excluded by custom (i.e. XML) config:
-        return new DualValidationMappingProvider(configured, ConstraintDefaults.INSTANCE);
+        return new DualValidationMappingProvider(ConstraintDefaults.INSTANCE, configured);
     }
 }

http://git-wip-us.apache.org/repos/asf/bval/blob/3f67257d/bval-jsr/src/main/java/org/apache/bval/jsr/metadata/DualValidationMappingProvider.java
----------------------------------------------------------------------
diff --git a/bval-jsr/src/main/java/org/apache/bval/jsr/metadata/DualValidationMappingProvider.java
b/bval-jsr/src/main/java/org/apache/bval/jsr/metadata/DualValidationMappingProvider.java
index e5b5038..ac88d4d 100644
--- a/bval-jsr/src/main/java/org/apache/bval/jsr/metadata/DualValidationMappingProvider.java
+++ b/bval-jsr/src/main/java/org/apache/bval/jsr/metadata/DualValidationMappingProvider.java
@@ -35,16 +35,16 @@ public class DualValidationMappingProvider extends ValidatorMappingProvider
{
     protected <A extends Annotation> ValidatorMapping<A> doGetValidatorMapping(Class<A>
constraintType) {
 
         final ValidatorMapping<A> secondaryMapping = secondaryDelegate.doGetValidatorMapping(constraintType);
+        final ValidatorMapping<A> primaryMapping = primaryDelegate.doGetValidatorMapping(constraintType);
         if (secondaryMapping == null) {
-            return primaryDelegate.doGetValidatorMapping(constraintType);
+            return primaryMapping;
         }
         final AnnotationBehavior annotationBehavior = secondaryMapping.getAnnotationBehavior();
 
-        if (annotationBehavior == AnnotationBehavior.EXCLUDE) {
+        if (primaryMapping == null || annotationBehavior == AnnotationBehavior.EXCLUDE) {
             return secondaryMapping;
         }
-        return ValidatorMapping.merge(
-            Arrays.asList(primaryDelegate.doGetValidatorMapping(constraintType), secondaryMapping),
+        return ValidatorMapping.merge(Arrays.asList(primaryMapping, secondaryMapping),
             AnnotationBehaviorMergeStrategy.consensus());
     }
 }


Mime
View raw message