@Result annotation could use the compiler to enforce strong restriction
-----------------------------------------------------------------------

                 Key: WW-2577
                 URL: https://issues.apache.org/struts/browse/WW-2577
             Project: Struts 2
          Issue Type: Improvement
          Components: Core Actions
            Reporter: Brad Cupit
            Priority: Trivial


Note: this would be extremely easy to fix

The @Result annotation could have more restrictions that use the compiler to 
enforce certain behaviors.

1) Add @Target(ElementType.TYPE)
the documentation says not to put the annotation on methods, as it only works 
on classes. This update makes it a compile error if the action is put on 
anything other than a class

2) make type() a Class<? extends Result>
the type() field is of type Class, but by making it of type Class<? extends 
Result> it enforces that the type implement the Result interface. The advantage 
here is much weaker than in the first option, however it would self-document 
the code so anyone writing a custom 'type' would know to implement the Result 
interface.

The final code would look like this:

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface Result {
        String name() default Action.SUCCESS;
        Class<? extends Result> type() default NullResult.class;
        String value();
        String[] params() default {};
}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to