Uploaded image for project: 'Log Tool'
  1. Log Tool
  2. LOGTOOL-109

Create @NotNull or @RequiresNonNull annotation to allow null checks with custom exception

This issue belongs to an archived project. You can view it, but you can't modify it. Learn more

XMLWordPrintable

    • Icon: Feature Request Feature Request
    • Resolution: Won't Do
    • Icon: Major Major
    • None
    • None
    • None

      Use an @NotNull or @RequiresNonNull annotation on a method to generate a null check and throw, by default, an IllegalArgumentException if null. Also clean the stack trace.

      Example Interface
      @Message(id = 123, value = "Name cannot be null")
      @NotNull(IllegalArgumentException.class)
      void requireNotNull(String name);
      
      Example Generated Code
      @Override
      public void requireNotNull(final String name) {
          if (name == null) {
              final IllegalArgumentException result = new IllegalArgumentException(String.format(invalidUser$str(), name));
              final StackTraceElement[] st = result.getStackTrace();
              result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
          }
      }
      

      The @Param annotation could be used along with @Pos for formatting possibly.

              Unassigned Unassigned
              jperkins-rhn James Perkins
              Archiver:
              rhn-support-sthamilt Stacey Hamilton

                Created:
                Updated:
                Resolved:
                Archived: