Skip to content

Commit

Permalink
refactoring ValidateGroup -> ValidationGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
HedjuHor committed Jan 11, 2018
1 parent 5e4b385 commit 215eb62
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,21 @@
* </p>
* <pre>
*
* {@literal @}ValidateGroup(CarChecks.class)
* {@literal @}ValidationGroup(CarChecks.class)
* {@literal @}Action...
* </pre>
* <p>
* <p>
* Example, Validate with severals special group
* </p>
* <pre>
* {@literal @}ValidateGroup(Default.class, CarChecks.class, DriverChecks.class)
* {@literal @}ValidationGroup(Default.class, CarChecks.class, DriverChecks.class)
* {@literal @}Action...
* </pre>
*/
@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface ValidateGroup {
public @interface ValidationGroup {

Class<?>[] value() default {};
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import org.apache.commons.lang3.reflect.MethodUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts.beanvalidation.constraints.ValidateGroup;
import org.apache.struts.beanvalidation.constraints.ValidationGroup;
import org.apache.struts.beanvalidation.validation.constant.ValidatorConstants;
import org.apache.struts2.interceptor.validation.SkipValidation;

Expand Down Expand Up @@ -109,8 +109,8 @@ protected String doIntercept(ActionInvocation invocation) throws Exception {
}

protected Class<?>[] getValidationGroups(Object action, String methodName) throws NoSuchMethodException {
ValidateGroup validateGroup = MethodUtils.getAnnotation(getActionMethod(action.getClass(), methodName), ValidateGroup.class, true, true);
return validateGroup == null ? new Class[]{} : validateGroup.value();
ValidationGroup validationGroup = MethodUtils.getAnnotation(getActionMethod(action.getClass(), methodName), ValidationGroup.class, true, true);
return validationGroup == null ? new Class[]{} : validationGroup.value();
}

protected void performBeanValidation(Object action, Validator validator, Class<?>[] groups) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import org.apache.struts.beanvalidation.constraints.ValidateGroup;
import org.apache.struts.beanvalidation.constraints.ValidationGroup;
import org.apache.struts.beanvalidation.models.Person;

import javax.validation.Valid;
Expand All @@ -38,32 +38,32 @@ public String actionStandard() {
return SUCCESS;
}

@ValidateGroup
@ValidationGroup
public String actionDefault() {
return SUCCESS;
}

@ValidateGroup(Person.NameChecks.class)
@ValidationGroup(Person.NameChecks.class)
public String actionNameChecks() {
return SUCCESS;
}

@ValidateGroup(Person.StreetChecks.class)
@ValidationGroup(Person.StreetChecks.class)
public String actionStreetChecks() {
return SUCCESS;
}

@ValidateGroup(Person.NameAndStreetChecks.class)
@ValidationGroup(Person.NameAndStreetChecks.class)
public String actionNameAndStreetChecks() {
return SUCCESS;
}

@ValidateGroup({Person.NameChecks.class, Person.FirstNameChecks.class})
@ValidationGroup({Person.NameChecks.class, Person.FirstNameChecks.class})
public String actionMultiGroupsChecks() {
return SUCCESS;
}

@ValidateGroup({Person.LongNameChecks.class})
@ValidationGroup({Person.LongNameChecks.class})
public String actionLongNameChecks() {
return SUCCESS;
}
Expand Down

0 comments on commit 215eb62

Please sign in to comment.