Skip to content

Commit

Permalink
HV-1942 Update DefaultGroupSequenceProvider add default method provid…
Browse files Browse the repository at this point in the history
…e the class of instance
  • Loading branch information
ilikly committed Mar 16, 2023
1 parent 6a932fe commit eb9c6a7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
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 @@ -39,6 +39,22 @@ public interface DefaultGroupSequenceProvider<T> {
* 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.
* @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>
* The object parameter allows to dynamically compose the default group sequence in function of the validated value state.
* </p>
*
* @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}.
*
Expand Down

0 comments on commit eb9c6a7

Please sign in to comment.