Annotation Type MayOptionallyUse


  • @Target(PARAMETER)
    @Retention(SOURCE)
    public @interface MayOptionallyUse
    Indicates that a parameter to a placeholder method is not required to be used in the placeholder's implementation. For example, the pattern
    
     abstract class Utf8Bytes {
      @Placeholder abstract void handleException(
          @MayOptionallyUse UnsupportedEncodingException e);
      @Placeholder abstract void useString(String str);
      @BeforeTemplate void before(byte[] array) {
         try {
           useString(new String(array, "UTF_8"));
         } catch (UnsupportedEncodingException e) {
           handleException(e);
         }
       }
      @AfterTemplate void after(byte[] array) {
         useString(new String(array, StandardCharsets.UTF_8));
       }
     }
     
    would match even if the catch statement were empty, or didn't refer to e.