Annotation Type Defined


@Documented @TypeQualifier(applicableTo=java.lang.String.class) @Retention(RUNTIME) public @interface Defined
Type qualifier annotation to mark a parameter, an attribute or a return value is expected to be defined, id est non null and not blank. An element annotated with @Defined claims null or blank String value isn't valid to return (for methods), pass to (parameters) or hold in (local variables and fields) and hence a NullPointerException or an IllegalArgumentException should be thrown.

Apart from documentation purposes this annotation is intended to be used by static analysis tools to validate against probable runtime errors or element contract violations.

By defining our own annotations we ensure to be agnostic from any checking library or framework because, despite of the JSR-305, a lot of tiers provide its own incompatible solution.

Author:
mmoquillon
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
     
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    javax.annotation.meta.When
     
  • Element Details

    • when

      javax.annotation.meta.When when
      Default:
      ALWAYS