Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HV-1942 Update DefaultGroupSequenceProvider add default method provide the class of instance #1310

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ public Optional<ExecutableMetaData> getMetaDataFor(Executable executable) {
@Override
public List<Class<?>> getDefaultGroupSequence(T beanState) {
if ( hasDefaultGroupSequenceProvider() ) {
List<Class<?>> providerDefaultGroupSequence = defaultGroupSequenceProvider.getValidationGroups( beanState );
List<Class<?>> providerDefaultGroupSequence = defaultGroupSequenceProvider.getValidationGroups( beanClass, beanState );
return getValidDefaultGroupSequence( beanClass, providerDefaultGroupSequence );
}

Expand All @@ -335,7 +335,7 @@ public List<Class<?>> getDefaultGroupSequence(T beanState) {
@Override
public Iterator<Sequence> getDefaultValidationSequence(T beanState) {
if ( hasDefaultGroupSequenceProvider() ) {
List<Class<?>> providerDefaultGroupSequence = defaultGroupSequenceProvider.getValidationGroups( beanState );
List<Class<?>> providerDefaultGroupSequence = defaultGroupSequenceProvider.getValidationGroups( beanClass, beanState );
return validationOrderGenerator.getDefaultValidationOrder(
beanClass,
getValidDefaultGroupSequence( beanClass, providerDefaultGroupSequence )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,23 @@
*/
public interface DefaultGroupSequenceProvider<T> {

/**
* This method returns the default group sequence for the given instance.
* <p>
* The object parameter allows to dynamically compose the default group sequence in function of the validated value state.
* </p>
*
* @param clazz the instance class being validated.
iimik marked this conversation as resolved.
Show resolved Hide resolved
* @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.
*/
default List<Class<?>> getValidationGroups(Class<?> clazz, T object) {
return getValidationGroups( object );
}

/**
* This method returns the default group sequence for the given instance.
* <p>
Expand Down