Skip to content

Commit 500830f

Browse files
committed
HV-2128 Update serialVersionUID for paths/nodes
as they've been updates in the other PR for HV-1831 Signed-off-by: marko-bekhta <[email protected]>
1 parent 09c7ebb commit 500830f

File tree

6 files changed

+44
-7
lines changed

6 files changed

+44
-7
lines changed

documentation/src/test/java/org/hibernate/validator/referenceguide/chapter12/propertypath/PropertyPathTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.hibernate.validator.HibernateValidator;
2020
import org.hibernate.validator.path.PropertyNode;
2121

22+
import org.junit.Assert;
2223
import org.junit.Test;
2324

2425
/**
@@ -60,6 +61,13 @@ public void testPropertyNodeGetValueForSet() {
6061
assertEquals( node.getName(), "name" );
6162
assertEquals( node.as( PropertyNode.class ).getValue(), "Bob" );
6263
//end::include[]
64+
if ( path instanceof org.hibernate.validator.path.Path hvPath ) {
65+
assertEquals( hvPath.getLeafNode().getName(), "name" );
66+
assertEquals( hvPath.getLeafNode().as( PropertyNode.class ).getValue(), "Bob" );
67+
}
68+
else {
69+
Assert.fail( "Unexpected path node type: " + path.getClass().getName() );
70+
}
6371

6472
assertFalse( nodeIterator.hasNext() );
6573
}

engine/src/main/java/org/hibernate/validator/internal/engine/path/MaterializedNode.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55
package org.hibernate.validator.internal.engine.path;
66

7+
import java.io.Serial;
78
import java.io.Serializable;
89
import java.lang.invoke.MethodHandles;
910
import java.util.Arrays;
@@ -31,8 +32,8 @@
3132
public class MaterializedNode
3233
implements PropertyNode, MethodNode, ConstructorNode, BeanNode, ParameterNode, ReturnValueNode, CrossParameterNode, ContainerElementNode,
3334
org.hibernate.validator.path.PropertyNode, org.hibernate.validator.path.ContainerElementNode, Serializable {
34-
// @Serial
35-
// private static final long serialVersionUID = 2075466571633860499L;
35+
@Serial
36+
private static final long serialVersionUID = -7629728442122634981L;
3637
private static final Class<?>[] EMPTY_CLASS_ARRAY = new Class<?>[] { };
3738

3839
private static final Log LOG = LoggerFactory.make( MethodHandles.lookup() );

engine/src/main/java/org/hibernate/validator/internal/engine/path/MaterializedPath.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
88
import java.io.Serializable;
99
import java.util.Iterator;
1010

11-
import jakarta.validation.Path;
11+
import org.hibernate.validator.path.Path;
12+
1213

1314
final class MaterializedPath implements Path, Serializable {
1415

1516
@Serial
16-
private static final long serialVersionUID = -8906501301223202169L;
17+
private static final long serialVersionUID = 1264131890253015968L;
1718

1819
private static final String PROPERTY_PATH_SEPARATOR = ".";
1920

@@ -71,4 +72,9 @@ static String asString(MaterializedNode currentLeafNode) {
7172
}
7273
return builder.toString();
7374
}
75+
76+
@Override
77+
public Node getLeafNode() {
78+
return leafNode;
79+
}
7480
}

engine/src/main/java/org/hibernate/validator/internal/engine/path/MutableNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class MutableNode
4040
implements Path.PropertyNode, Path.MethodNode, Path.ConstructorNode, Path.BeanNode, Path.ParameterNode, Path.ReturnValueNode, Path.CrossParameterNode, Path.ContainerElementNode,
4141
org.hibernate.validator.path.PropertyNode, org.hibernate.validator.path.ContainerElementNode, Serializable {
4242
@Serial
43-
private static final long serialVersionUID = 2075466571633860499L;
43+
private static final long serialVersionUID = 3259464108481054555L;
4444
private static final Class<?>[] EMPTY_CLASS_ARRAY = new Class<?>[] { };
4545

4646
private static final Log LOG = LoggerFactory.make( MethodHandles.lookup() );

engine/src/main/java/org/hibernate/validator/internal/engine/path/MutablePath.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
import java.util.regex.Pattern;
1616

1717
import jakarta.validation.ElementKind;
18-
import jakarta.validation.Path;
1918

2019
import org.hibernate.validator.internal.metadata.aggregated.ExecutableMetaData;
2120
import org.hibernate.validator.internal.util.Contracts;
2221
import org.hibernate.validator.internal.util.logging.Log;
2322
import org.hibernate.validator.internal.util.logging.LoggerFactory;
23+
import org.hibernate.validator.path.Path;
2424

2525
/**
2626
* Internal, mutable implementation of {@code jakarta.validation.Path}.
@@ -31,7 +31,7 @@
3131
*/
3232
public final class MutablePath implements Path, Serializable {
3333
@Serial
34-
private static final long serialVersionUID = 7564511574909882392L;
34+
private static final long serialVersionUID = 2464836778339203598L;
3535
private static final Log LOG = LoggerFactory.make( MethodHandles.lookup() );
3636

3737
private static final String PROPERTY_PATH_SEPARATOR = ".";
@@ -182,6 +182,7 @@ public void removeLeafNode() {
182182
}
183183
}
184184

185+
@Override
185186
public MutableNode getLeafNode() {
186187
return currentLeafNode;
187188
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
* Copyright Red Hat Inc. and Hibernate Authors
4+
*/
5+
package org.hibernate.validator.path;
6+
7+
import org.hibernate.validator.Incubating;
8+
9+
/**
10+
* An extended representation of the validation path, provides Hibernate Validator specific functionality.
11+
*/
12+
@Incubating
13+
public interface Path extends jakarta.validation.Path {
14+
15+
/**
16+
* @return The leaf node of the current path.
17+
* This is a shortcut method to iterating over the path till the last node.
18+
*/
19+
jakarta.validation.Path.Node getLeafNode();
20+
21+
}

0 commit comments

Comments
 (0)