// a form bean class, even if it's not annotated as such.
MethodDeclaration[] methods = CompilerUtils.getClassMethods( jclass, null );
for ( int i = 0; i < methods.length; i++ )
{
MethodDeclaration method = methods[i];
isFormBeanClass |=
checkValidationAnnotation( method, VALIDATABLE_PROPERTY_TAG_NAME, validatablePropertyGrammar );
// We don't currently support validation rule annotations directly on getter methods.
/*
hasOne |= checkValidationAnnotation( method, LOCALE_RULES_ATTR, _validationLocaleRulesGrammar );
hasOne |= checkValidationAnnotation( method, VALIDATE_REQUIRED_TAG_NAME, _baseValidationRuleGrammar );
hasOne |= checkValidationAnnotation( method, VALIDATE_RANGE_TAG_NAME, _validateRangeGrammar );
hasOne |= checkValidationAnnotation( method, VALIDATE_MIN_LENGTH_TAG_NAME, _baseValidationRuleGrammar );
hasOne |= checkValidationAnnotation( method, VALIDATE_MAX_LENGTH_TAG_NAME, _baseValidationRuleGrammar );
hasOne |= checkValidationAnnotation( method, VALIDATE_CREDIT_CARD_TAG_NAME, _baseValidationRuleGrammar );
hasOne |= checkValidationAnnotation( method, VALIDATE_EMAIL_TAG_NAME, _baseValidationRuleGrammar );
hasOne |= checkValidationAnnotation( method, VALIDATE_MASK_TAG_NAME, _baseValidationRuleGrammar );
hasOne |= checkValidationAnnotation( method, VALIDATE_DATE_TAG_NAME, _baseValidationRuleGrammar );
hasOne |= checkValidationAnnotation( method, VALIDATE_TYPE_TAG_NAME, _validateTypeGrammar );
*/
}
CoreAnnotationProcessorEnv env = getEnv();
// Make sure ActionForm subclasses are public static, and that they have default constructors.
if ( isFormBeanClass || CompilerUtils.isAssignableFrom( STRUTS_FORM_CLASS_NAME, jclass, env ) )
{
if ( jclass.getDeclaringType() != null && ! jclass.hasModifier( Modifier.STATIC ) )
{
getDiagnostics().addError( jclass, "error.form-not-static" );
}
if ( ! jclass.hasModifier( Modifier.PUBLIC ) )
{
getDiagnostics().addError( jclass, "error.form-not-public" );
}
if ( ! CompilerUtils.hasDefaultConstructor( jclass ) )
{
getDiagnostics().addError( jclass, "error.form-no-default-constructor" );
}
}
// Check to see if this class extends the (deprecated) FormData class and overrides its validate() method.
// If so, then declarative validation annotations won't work unless the override calls super.validate().
// Print a warning describing this behavior and suggesting implementing Validatable instead.
methods = jclass.getMethods();
if (CompilerUtils.isAssignableFrom(PAGEFLOW_FORM_CLASS_NAME, jclass, env)) {
for (int i = 0; i < methods.length; i++) {
MethodDeclaration method = methods[i];
if (method.getSimpleName().equals("validate")) {
ParameterDeclaration[] params = method.getParameters();
if (params.length == 2) {
TypeInstance param1Type = params[0].getType();
TypeInstance param2Type = params[1].getType();