-
Notifications
You must be signed in to change notification settings - Fork 575
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HV-1942 Allow a single impl of a DefaultGroupSequenceProvider to be u…
…sed on a wider range of types Since the existing assumption is that the provider is specific to a single type and cannot be placed on multiple types
- Loading branch information
1 parent
70fc56a
commit 4d09a41
Showing
18 changed files
with
272 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,28 +11,45 @@ | |
/** | ||
* This class defines the dynamic group sequence provider contract. | ||
* <p> | ||
* In order to redefine dynamically the default group sequence for a type T, the {@link org.hibernate.validator.group.GroupSequenceProvider} annotation | ||
* must be placed on T, specifying as its value a concrete implementation of {@code DefaultGroupSequenceProvider}, which | ||
* must be parametrized with the type T. | ||
* </p> | ||
* In order to dynamically redefine the default group sequence for a type {@code T}, | ||
* the {@link org.hibernate.validator.group.GroupSequenceProvider} annotation | ||
* must be placed on {@code T}, specifying as its value a concrete implementation of {@code DefaultGroupSequenceProvider}, which | ||
* must be parametrized with that same type {@code T}, its subclass {@code Y} ({@code T t; t instanceof Y == true } | ||
* or an interface {@code I} that is common to the beans on for which this sequence provider is expected to be applied to. | ||
* <p> | ||
* If during the validation process the {@code Default} group is validated for T, the actual validated instance | ||
* If during the validation process the {@code Default} group is validated for {@code T}, the actual validated instance | ||
* is passed to the {@code DefaultGroupSequenceProvider} to determine the default group sequence. | ||
* </p> | ||
* <p> | ||
* Note: | ||
* <ul> | ||
* <li>Implementations must provide a public default constructor.</li> | ||
* <li>Implementations must be thread-safe.</li> | ||
* <li>Implementations must return a valid default group sequence, | ||
* i.e. the returned sequence <b>must</b> contain the bean type itself, | ||
* which represents the {@link jakarta.validation.groups.Default default group}.</li> | ||
* </ul> | ||
* | ||
* @param <T> The type for which an implementation is defined. | ||
* | ||
* @author Kevin Pollet <[email protected]> (C) 2011 SERLI | ||
* @author Hardy Ferentschik | ||
*/ | ||
public interface DefaultGroupSequenceProvider<T> { | ||
|
||
/** | ||
* This method returns the default group sequence for the given {@code klass} bean type and {@code object} instance. | ||
* <p> | ||
* The object parameter allows to dynamically compose the default group sequence based on the state of the validated value. | ||
* | ||
* @param klass the type of the bean for which the group sequence is requested. | ||
* @param object the instance under validation. This value <b>can</b> be {@code null}, e.g. in case this method was called as part of | ||
* {@linkplain jakarta.validation.Validator#validateValue(Class, String, Object, Class[]) Validator#validateValue}. | ||
* @return a list of classes specifying the default group sequence. The same constraints to the redefined group list | ||
* apply as for lists defined via {@code GroupSequence}. In particular the list has to contain the type T. | ||
*/ | ||
default List<Class<?>> getValidationGroups(Class<?> klass, T object) { | ||
return getValidationGroups( object ); | ||
} | ||
|
||
/** | ||
* This method returns the default group sequence for the given instance. | ||
* <p> | ||
|
@@ -41,9 +58,12 @@ public interface DefaultGroupSequenceProvider<T> { | |
* | ||
* @param object the instance being validated. This value can be {@code null} in case this method was called as part of | ||
* {@linkplain jakarta.validation.Validator#validateValue(Class, String, Object, Class[]) Validator#validateValue}. | ||
* | ||
* @return a list of classes specifying the default group sequence. The same constraints to the redefined group list | ||
* apply as for lists defined via {@code GroupSequence}. In particular the list has to contain the type T. | ||
* apply as for lists defined via {@code GroupSequence}. In particular the list has to contain the type T. | ||
* @deprecated Use the {@link #getValidationGroups(Class, Object)} instead. | ||
*/ | ||
List<Class<?>> getValidationGroups(T object); | ||
@Deprecated(forRemoval = true, since = "9.0.0") | ||
default List<Class<?>> getValidationGroups(T object) { | ||
throw new AssertionError( "Unexpected call to get the validation group sequence. " + "The variant receiving the bean type must be used by Hibernate Validator" ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.