Exemplo n.º 1
0
 /** Some validations, not exhaustive. */
 @Value.Check
 protected void validate() {
   if (hasInclude() && !isTopLevel()) {
     report()
         .annotationNamed(IncludeMirror.simpleName())
         .error("@%s could not be used on nested types.", IncludeMirror.simpleName());
   }
   if (isEnclosing() && !isTopLevel()) {
     report()
         .annotationNamed(EnclosingMirror.simpleName())
         .error("@%s should only be used on a top-level types.", EnclosingMirror.simpleName());
   }
   if (isImmutable() && element().getKind() == ElementKind.ENUM) {
     report()
         .annotationNamed(ImmutableMirror.simpleName())
         .error("@%s is not supported on enums", ImmutableMirror.simpleName());
   }
   if (isModifiable() && (isEnclosed() || isEnclosing())) {
     report()
         .annotationNamed(ModifiableMirror.simpleName())
         .error(
             "@%s could not be used with or within @%s",
             ModifiableMirror.simpleName(), EnclosingMirror.simpleName());
   }
 }
Exemplo n.º 2
0
 @Value.Lazy
 public boolean isModifiable() {
   return ModifiableMirror.isPresent(element());
 }