bval-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject [50/51] [abbrv] bval git commit: consolidate ConstraintViolationBuilder implementation
Date Fri, 03 Nov 2017 22:28:15 GMT
consolidate ConstraintViolationBuilder implementation


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

Branch: refs/heads/master
Commit: 11257b799437056d947326ddef790135f99c178e
Parents: ce20815
Author: Matt Benson <mbenson@apache.org>
Authored: Fri May 26 18:33:14 2017 +0000
Committer: Matt Benson <mbenson@apache.org>
Committed: Fri May 26 18:33:14 2017 +0000

----------------------------------------------------------------------
 .../jsr/ConstraintValidatorContextImpl.java     | 23 +-----
 .../jsr/NodeBuilderCustomizableContextImpl.java | 75 -------------------
 .../apache/bval/jsr/NodeContextBuilderImpl.java | 78 --------------------
 .../LeafNodeBuilderCustomizableContextImpl.java | 61 ++++++++-------
 .../util/LeafNodeBuilderDefinedContextImpl.java | 43 -----------
 .../NodeBuilderCustomizableContextImpl.java     | 24 +++---
 .../jsr/util/NodeBuilderDefinedContextImpl.java |  7 +-
 .../bval/jsr/util/NodeContextBuilderImpl.java   |  8 +-
 8 files changed, 54 insertions(+), 265 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/bval/blob/11257b79/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintValidatorContextImpl.java
----------------------------------------------------------------------
diff --git a/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintValidatorContextImpl.java
b/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintValidatorContextImpl.java
index 167dbe2..3599603 100644
--- a/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintValidatorContextImpl.java
+++ b/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintValidatorContextImpl.java
@@ -19,6 +19,7 @@
 package org.apache.bval.jsr;
 
 import org.apache.bval.jsr.util.LeafNodeBuilderCustomizableContextImpl;
+import org.apache.bval.jsr.util.NodeBuilderCustomizableContextImpl;
 import org.apache.bval.jsr.util.NodeBuilderDefinedContextImpl;
 import org.apache.bval.jsr.util.NodeImpl;
 import org.apache.bval.jsr.util.PathImpl;
@@ -26,7 +27,6 @@ import org.apache.bval.model.ValidationListener;
 
 import javax.validation.ConstraintValidator;
 import javax.validation.ConstraintValidatorContext;
-import javax.validation.ElementKind;
 import javax.validation.Path;
 import javax.validation.ValidationException;
 import java.lang.reflect.Method;
@@ -125,28 +125,11 @@ public class ConstraintValidatorContextImpl implements ConstraintValidatorContex
 
         @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();
-                }
-            } else {
-                node = new NodeImpl.PropertyNodeImpl(name);
-                propertyPath.addNode(node);
-            }
-            node.setName(name);
-            node.setKind(ElementKind.PROPERTY); // enforce it
-            return new NodeBuilderCustomizableContextImpl(parent, messageTemplate, propertyPath);
+            return new NodeBuilderCustomizableContextImpl(parent, messageTemplate, propertyPath,
name);
         }
 
         @Override
         public LeafNodeBuilderCustomizableContext addBeanNode() {
-            final NodeImpl node = new NodeImpl.BeanNodeImpl();
-            node.setKind(ElementKind.BEAN);
-            propertyPath.addNode(node);
             return new LeafNodeBuilderCustomizableContextImpl(parent, messageTemplate, propertyPath);
         }
 
@@ -156,8 +139,6 @@ public class ConstraintValidatorContextImpl implements ConstraintValidatorContex
             final List<String> parameters =
                 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();
             }

http://git-wip-us.apache.org/repos/asf/bval/blob/11257b79/bval-jsr/src/main/java/org/apache/bval/jsr/NodeBuilderCustomizableContextImpl.java
----------------------------------------------------------------------
diff --git a/bval-jsr/src/main/java/org/apache/bval/jsr/NodeBuilderCustomizableContextImpl.java
b/bval-jsr/src/main/java/org/apache/bval/jsr/NodeBuilderCustomizableContextImpl.java
deleted file mode 100644
index 07ed91a..0000000
--- a/bval-jsr/src/main/java/org/apache/bval/jsr/NodeBuilderCustomizableContextImpl.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.bval.jsr;
-
-import org.apache.bval.jsr.util.LeafNodeBuilderCustomizableContextImpl;
-import org.apache.bval.jsr.util.NodeImpl;
-import org.apache.bval.jsr.util.PathImpl;
-
-import javax.validation.ConstraintValidatorContext;
-import javax.validation.ElementKind;
-
-public class NodeBuilderCustomizableContextImpl
-    implements ConstraintValidatorContext.ConstraintViolationBuilder.NodeBuilderCustomizableContext
{
-    private final PathImpl path;
-    private final ConstraintValidatorContextImpl context;
-    private final String template;
-
-    public NodeBuilderCustomizableContextImpl(final ConstraintValidatorContextImpl parent,
final String messageTemplate,
-        final PathImpl propertyPath) {
-        context = parent;
-        template = messageTemplate;
-        path = propertyPath;
-    }
-
-    @Override
-    public ConstraintValidatorContext.ConstraintViolationBuilder.NodeContextBuilder inIterable()
{
-        path.getLeafNode().setInIterable(true);
-        return new NodeContextBuilderImpl(context, template, path);
-    }
-
-    @Override
-    public ConstraintValidatorContext.ConstraintViolationBuilder.NodeBuilderCustomizableContext
addNode(String name) {
-        path.addNode(new NodeImpl(name));
-        return this;
-    }
-
-    @Override
-    public ConstraintValidatorContext.ConstraintViolationBuilder.NodeBuilderCustomizableContext
addPropertyNode(
-        String name) {
-        final NodeImpl node = new NodeImpl.PropertyNodeImpl(name);
-        node.setKind(ElementKind.PROPERTY);
-        path.addNode(node);
-        return this;
-    }
-
-    @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);
-    }
-
-    @Override
-    public ConstraintValidatorContext addConstraintViolation() {
-        context.addError(template, path);
-        return context;
-    }
-}

http://git-wip-us.apache.org/repos/asf/bval/blob/11257b79/bval-jsr/src/main/java/org/apache/bval/jsr/NodeContextBuilderImpl.java
----------------------------------------------------------------------
diff --git a/bval-jsr/src/main/java/org/apache/bval/jsr/NodeContextBuilderImpl.java b/bval-jsr/src/main/java/org/apache/bval/jsr/NodeContextBuilderImpl.java
deleted file mode 100644
index f686a92..0000000
--- a/bval-jsr/src/main/java/org/apache/bval/jsr/NodeContextBuilderImpl.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.bval.jsr;
-
-import org.apache.bval.jsr.util.LeafNodeBuilderCustomizableContextImpl;
-import org.apache.bval.jsr.util.NodeBuilderDefinedContextImpl;
-import org.apache.bval.jsr.util.NodeImpl;
-import org.apache.bval.jsr.util.PathImpl;
-
-import javax.validation.ConstraintValidatorContext;
-import javax.validation.ElementKind;
-
-public class NodeContextBuilderImpl
-    implements ConstraintValidatorContext.ConstraintViolationBuilder.NodeContextBuilder {
-    private final PathImpl path;
-    private final String template;
-    private final ConstraintValidatorContextImpl context;
-
-    public NodeContextBuilderImpl(final ConstraintValidatorContextImpl context, final String
template,
-        final PathImpl path) {
-        this.context = context;
-        this.template = template;
-        this.path = path;
-    }
-
-    @Override
-    public ConstraintValidatorContext.ConstraintViolationBuilder.NodeBuilderDefinedContext
atKey(Object key) {
-        path.getLeafNode().setKey(key);
-        return new NodeBuilderDefinedContextImpl(context, template, path);
-    }
-
-    @Override
-    public ConstraintValidatorContext.ConstraintViolationBuilder.NodeBuilderDefinedContext
atIndex(Integer index) {
-        path.getLeafNode().setIndex(index);
-        return new NodeBuilderDefinedContextImpl(context, template, path);
-    }
-
-    @Override
-    public ConstraintValidatorContext.ConstraintViolationBuilder.NodeBuilderCustomizableContext
addNode(String name) {
-        return new NodeBuilderCustomizableContextImpl(context, template, path).addNode(name);
-    }
-
-    @Override
-    public ConstraintValidatorContext.ConstraintViolationBuilder.NodeBuilderCustomizableContext
addPropertyNode(
-        String name) {
-        return new NodeBuilderCustomizableContextImpl(context, template, path).addPropertyNode(name);
-    }
-
-    @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);
-    }
-
-    @Override
-    public ConstraintValidatorContext addConstraintViolation() {
-        context.addError(template, path);
-        return context;
-    }
-}

http://git-wip-us.apache.org/repos/asf/bval/blob/11257b79/bval-jsr/src/main/java/org/apache/bval/jsr/util/LeafNodeBuilderCustomizableContextImpl.java
----------------------------------------------------------------------
diff --git a/bval-jsr/src/main/java/org/apache/bval/jsr/util/LeafNodeBuilderCustomizableContextImpl.java
b/bval-jsr/src/main/java/org/apache/bval/jsr/util/LeafNodeBuilderCustomizableContextImpl.java
index fd66c86..efa9aeb 100644
--- a/bval-jsr/src/main/java/org/apache/bval/jsr/util/LeafNodeBuilderCustomizableContextImpl.java
+++ b/bval-jsr/src/main/java/org/apache/bval/jsr/util/LeafNodeBuilderCustomizableContextImpl.java
@@ -21,10 +21,40 @@ package org.apache.bval.jsr.util;
 import org.apache.bval.jsr.ConstraintValidatorContextImpl;
 
 import javax.validation.ConstraintValidatorContext;
-import javax.validation.ElementKind;
+import javax.validation.ConstraintValidatorContext.ConstraintViolationBuilder.LeafNodeBuilderDefinedContext;
+import javax.validation.ConstraintValidatorContext.ConstraintViolationBuilder.LeafNodeContextBuilder;
 
 public class LeafNodeBuilderCustomizableContextImpl
     implements ConstraintValidatorContext.ConstraintViolationBuilder.LeafNodeBuilderCustomizableContext
{
+
+    private final class LeafNodeContextBuilderImpl implements LeafNodeContextBuilder {
+        private final LeafNodeBuilderDefinedContext definedContext = new LeafNodeBuilderDefinedContext()
{
+
+            @Override
+            public ConstraintValidatorContext addConstraintViolation() {
+                return LeafNodeBuilderCustomizableContextImpl.this.addConstraintViolation();
+            }
+        };
+
+        @Override
+        public LeafNodeBuilderDefinedContext atKey(Object key) {
+            node.setKey(key);
+            return definedContext;
+        }
+
+        @Override
+        public LeafNodeBuilderDefinedContext atIndex(
+            Integer index) {
+            node.setIndex(index);
+            return definedContext;
+        }
+
+        @Override
+        public ConstraintValidatorContext addConstraintViolation() {
+            return LeafNodeBuilderCustomizableContextImpl.this.addConstraintViolation();
+        }
+    }
+
     private final ConstraintValidatorContextImpl context;
     private final PathImpl path;
     private final String template;
@@ -35,41 +65,20 @@ public class LeafNodeBuilderCustomizableContextImpl
         context = parent;
         template = messageTemplate;
         path = propertyPath;
-        node = new NodeImpl((String) null);
-        node.setKind(ElementKind.BEAN);
+        node = new NodeImpl.BeanNodeImpl();
     }
 
     @Override
-    public ConstraintValidatorContext.ConstraintViolationBuilder.LeafNodeContextBuilder inIterable()
{
-        path.getLeafNode().setInIterable(true);
+    public LeafNodeContextBuilder inIterable() {
+        node.setInIterable(true);
         return new LeafNodeContextBuilderImpl();
     }
 
     @Override
     public ConstraintValidatorContext addConstraintViolation() {
+        path.addNode(node);
         context.addError(template, path);
         return context;
     }
 
-    private class LeafNodeContextBuilderImpl
-        implements ConstraintValidatorContext.ConstraintViolationBuilder.LeafNodeContextBuilder
{
-        @Override
-        public ConstraintValidatorContext.ConstraintViolationBuilder.LeafNodeBuilderDefinedContext
atKey(Object key) {
-            path.getLeafNode().setKey(key);
-            return new LeafNodeBuilderDefinedContextImpl(context, template, path);
-        }
-
-        @Override
-        public ConstraintValidatorContext.ConstraintViolationBuilder.LeafNodeBuilderDefinedContext
atIndex(
-            Integer index) {
-            path.getLeafNode().setIndex(index);
-            return new LeafNodeBuilderDefinedContextImpl(context, template, path);
-        }
-
-        @Override
-        public ConstraintValidatorContext addConstraintViolation() {
-            context.addError(template, path);
-            return context;
-        }
-    }
 }

http://git-wip-us.apache.org/repos/asf/bval/blob/11257b79/bval-jsr/src/main/java/org/apache/bval/jsr/util/LeafNodeBuilderDefinedContextImpl.java
----------------------------------------------------------------------
diff --git a/bval-jsr/src/main/java/org/apache/bval/jsr/util/LeafNodeBuilderDefinedContextImpl.java
b/bval-jsr/src/main/java/org/apache/bval/jsr/util/LeafNodeBuilderDefinedContextImpl.java
deleted file mode 100644
index 75251fd..0000000
--- a/bval-jsr/src/main/java/org/apache/bval/jsr/util/LeafNodeBuilderDefinedContextImpl.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.bval.jsr.util;
-
-import org.apache.bval.jsr.ConstraintValidatorContextImpl;
-
-import javax.validation.ConstraintValidatorContext;
-
-public class LeafNodeBuilderDefinedContextImpl
-    implements ConstraintValidatorContext.ConstraintViolationBuilder.LeafNodeBuilderDefinedContext
{
-    private final ConstraintValidatorContextImpl context;
-    private final String template;
-    private final PathImpl path;
-
-    public LeafNodeBuilderDefinedContextImpl(final ConstraintValidatorContextImpl context,
final String tpl,
-        final PathImpl path) {
-        this.context = context;
-        this.template = tpl;
-        this.path = path;
-    }
-
-    @Override
-    public ConstraintValidatorContext addConstraintViolation() {
-        context.addError(template, path);
-        return context;
-    }
-}

http://git-wip-us.apache.org/repos/asf/bval/blob/11257b79/bval-jsr/src/main/java/org/apache/bval/jsr/util/NodeBuilderCustomizableContextImpl.java
----------------------------------------------------------------------
diff --git a/bval-jsr/src/main/java/org/apache/bval/jsr/util/NodeBuilderCustomizableContextImpl.java
b/bval-jsr/src/main/java/org/apache/bval/jsr/util/NodeBuilderCustomizableContextImpl.java
index 1d33eb2..ca058fc 100644
--- a/bval-jsr/src/main/java/org/apache/bval/jsr/util/NodeBuilderCustomizableContextImpl.java
+++ b/bval-jsr/src/main/java/org/apache/bval/jsr/util/NodeBuilderCustomizableContextImpl.java
@@ -26,7 +26,7 @@ import javax.validation.ElementKind;
 /**
  * Description: implementation of {@link javax.validation.ConstraintValidatorContext.ConstraintViolationBuilder.NodeBuilderCustomizableContext}.<br/>
  */
-final class NodeBuilderCustomizableContextImpl
+public final class NodeBuilderCustomizableContextImpl
     implements ConstraintValidatorContext.ConstraintViolationBuilder.NodeBuilderCustomizableContext
{
     private final ConstraintValidatorContextImpl parent;
     private final String messageTemplate;
@@ -40,13 +40,19 @@ final class NodeBuilderCustomizableContextImpl
      * @param path
      * @param name
      */
-    NodeBuilderCustomizableContextImpl(ConstraintValidatorContextImpl contextImpl, String
template, PathImpl path,
+    public NodeBuilderCustomizableContextImpl(ConstraintValidatorContextImpl contextImpl,
String template, PathImpl path,
         String name) {
         parent = contextImpl;
         messageTemplate = template;
         propertyPath = path;
-        node = new NodeImpl(name);
-        node.setKind(ElementKind.PROPERTY);
+
+        if (propertyPath.isRootPath() || propertyPath.getLeafNode().getKind() != null) {
+            node = new NodeImpl.PropertyNodeImpl(name);
+        } else {
+            node = propertyPath.removeLeafNode();
+            node.setName(name);
+            node.setKind(ElementKind.PROPERTY); // enforce it
+        }
     }
 
     /**
@@ -54,7 +60,6 @@ final class NodeBuilderCustomizableContextImpl
      */
     @Override
     public ConstraintValidatorContext.ConstraintViolationBuilder.NodeContextBuilder inIterable()
{
-        // Modifies the "previous" node in the path
         node.setInIterable(true);
         return new NodeContextBuilderImpl(parent, messageTemplate, propertyPath, node);
     }
@@ -64,9 +69,7 @@ final class NodeBuilderCustomizableContextImpl
      */
     @Override
     public ConstraintValidatorContext.ConstraintViolationBuilder.NodeBuilderCustomizableContext
addNode(String name) {
-        propertyPath.addNode(node);
-        node = new NodeImpl(name);
-        return this; // Re-use this instance
+        return addPropertyNode(name);
     }
 
     @Override
@@ -74,15 +77,12 @@ final class NodeBuilderCustomizableContextImpl
         String name) {
         propertyPath.addNode(node);
         node = new NodeImpl.PropertyNodeImpl(name);
-        node.setKind(ElementKind.PROPERTY);
-        return null;
+        return this;
     }
 
     @Override
     public ConstraintValidatorContext.ConstraintViolationBuilder.LeafNodeBuilderCustomizableContext
addBeanNode() {
         propertyPath.addNode(node);
-        node = new NodeImpl((String) null);
-        node.setKind(ElementKind.BEAN);
         return new LeafNodeBuilderCustomizableContextImpl(parent, messageTemplate, propertyPath);
     }
 

http://git-wip-us.apache.org/repos/asf/bval/blob/11257b79/bval-jsr/src/main/java/org/apache/bval/jsr/util/NodeBuilderDefinedContextImpl.java
----------------------------------------------------------------------
diff --git a/bval-jsr/src/main/java/org/apache/bval/jsr/util/NodeBuilderDefinedContextImpl.java
b/bval-jsr/src/main/java/org/apache/bval/jsr/util/NodeBuilderDefinedContextImpl.java
index 7a4d131..5ce20b5 100644
--- a/bval-jsr/src/main/java/org/apache/bval/jsr/util/NodeBuilderDefinedContextImpl.java
+++ b/bval-jsr/src/main/java/org/apache/bval/jsr/util/NodeBuilderDefinedContextImpl.java
@@ -21,7 +21,6 @@ package org.apache.bval.jsr.util;
 import org.apache.bval.jsr.ConstraintValidatorContextImpl;
 
 import javax.validation.ConstraintValidatorContext;
-import javax.validation.ElementKind;
 
 /**
  * Description: Implementation of {@link NodeBuilderDefinedContext}.<br/>
@@ -49,8 +48,7 @@ public final class NodeBuilderDefinedContextImpl
      */
     @Override
     public ConstraintValidatorContext.ConstraintViolationBuilder.NodeBuilderCustomizableContext
addNode(String name) {
-        // Node not yet added, wait until more information is provided
-        return new NodeBuilderCustomizableContextImpl(parent, messageTemplate, propertyPath,
name);
+        return addPropertyNode(name);
     }
 
     @Override
@@ -61,9 +59,6 @@ public final class NodeBuilderDefinedContextImpl
 
     @Override
     public ConstraintValidatorContext.ConstraintViolationBuilder.LeafNodeBuilderCustomizableContext
addBeanNode() {
-        final NodeImpl node = new NodeImpl((String) null);
-        node.setKind(ElementKind.BEAN);
-        propertyPath.addNode(node);
         return new LeafNodeBuilderCustomizableContextImpl(parent, messageTemplate, propertyPath);
     }
 

http://git-wip-us.apache.org/repos/asf/bval/blob/11257b79/bval-jsr/src/main/java/org/apache/bval/jsr/util/NodeContextBuilderImpl.java
----------------------------------------------------------------------
diff --git a/bval-jsr/src/main/java/org/apache/bval/jsr/util/NodeContextBuilderImpl.java b/bval-jsr/src/main/java/org/apache/bval/jsr/util/NodeContextBuilderImpl.java
index 1e0d6d4..80e5b8f 100644
--- a/bval-jsr/src/main/java/org/apache/bval/jsr/util/NodeContextBuilderImpl.java
+++ b/bval-jsr/src/main/java/org/apache/bval/jsr/util/NodeContextBuilderImpl.java
@@ -72,19 +72,19 @@ final class NodeContextBuilderImpl implements ConstraintValidatorContext.Constra
      */
     @Override
     public ConstraintValidatorContext.ConstraintViolationBuilder.NodeBuilderCustomizableContext
addNode(String name) {
-        propertyPath.addNode(node);
-        return new NodeBuilderCustomizableContextImpl(parent, messageTemplate, propertyPath,
name);
+        return addPropertyNode(name);
     }
 
     @Override
     public ConstraintValidatorContext.ConstraintViolationBuilder.NodeBuilderCustomizableContext
addPropertyNode(
         String name) {
-        propertyPath.addProperty(name);
-        return new NodeBuilderCustomizableContextImpl(parent, messageTemplate, propertyPath,
node.getName());
+        propertyPath.addNode(node);
+        return new NodeBuilderCustomizableContextImpl(parent, messageTemplate, propertyPath,
name);
     }
 
     @Override
     public ConstraintValidatorContext.ConstraintViolationBuilder.LeafNodeBuilderCustomizableContext
addBeanNode() {
+        propertyPath.addNode(node);
         return new LeafNodeBuilderCustomizableContextImpl(parent, messageTemplate, propertyPath);
     }
 


Mime
View raw message