Class ProcessorErrors


  • public final class ProcessorErrors
    extends java.lang.Object
    Static helper methods for throwing errors during code generation.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void checkState​(boolean expression, androidx.room.compiler.processing.XElement badElement, java.lang.Object errorMessage)
      Ensures the truth of an expression involving the state of the calling instance, but not involving any parameters to the calling method.
      static void checkState​(boolean expression, androidx.room.compiler.processing.XElement badElement, java.lang.String errorMessageTemplate, java.lang.Object... errorMessageArgs)
      Ensures the truth of an expression involving the state of the calling instance, but not involving any parameters to the calling method.
      static void checkState​(boolean expression, java.lang.Object errorMessage)
      Ensures the truth of an expression involving the state of the calling instance, but not involving any parameters to the calling method.
      static void checkState​(boolean expression, java.lang.String errorMessageTemplate, java.lang.Object... errorMessageArgs)
      Ensures the truth of an expression involving the state of the calling instance, but not involving any parameters to the calling method.
      static void checkStateX​(boolean expression, java.util.Collection<? extends androidx.room.compiler.processing.XElement> badElements, java.lang.String errorMessageTemplate, java.lang.Object... errorMessageArgs)
      Ensures the truth of an expression involving the state of the calling instance, but not involving any parameters to the calling method.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • checkState

        public static void checkState​(boolean expression,
                                      @Nullable
                                      java.lang.Object errorMessage)
        Ensures the truth of an expression involving the state of the calling instance, but not involving any parameters to the calling method.
        Parameters:
        expression - a boolean expression
        errorMessage - the exception message to use if the check fails; will be converted to a string using String.valueOf(Object)
        Throws:
        BadInputException - if expression is false
      • checkState

        @FormatMethod
        public static void checkState​(boolean expression,
                                      @Nullable @FormatString
                                      java.lang.String errorMessageTemplate,
                                      @Nullable
                                      java.lang.Object... errorMessageArgs)
        Ensures the truth of an expression involving the state of the calling instance, but not involving any parameters to the calling method.
        Parameters:
        expression - a boolean expression
        errorMessageTemplate - a template for the exception message should the check fail. The message is formed by replacing each %s placeholder in the template with an argument. These are matched by position - the first %s gets errorMessageArgs[0], etc. Unmatched arguments will be appended to the formatted message in square braces. Unmatched placeholders will be left as-is.
        errorMessageArgs - the arguments to be substituted into the message template. Arguments are converted to strings using String.valueOf(Object).
        Throws:
        BadInputException - if expression is false
        java.lang.NullPointerException - if the check fails and either errorMessageTemplate or errorMessageArgs is null (don't let this happen)
      • checkState

        public static void checkState​(boolean expression,
                                      androidx.room.compiler.processing.XElement badElement,
                                      @Nullable
                                      java.lang.Object errorMessage)
        Ensures the truth of an expression involving the state of the calling instance, but not involving any parameters to the calling method.
        Parameters:
        expression - a boolean expression
        badElement - the element that was at fault
        errorMessage - the exception message to use if the check fails; will be converted to a string using String.valueOf(Object)
        Throws:
        BadInputException - if expression is false
      • checkState

        @FormatMethod
        public static void checkState​(boolean expression,
                                      androidx.room.compiler.processing.XElement badElement,
                                      @Nullable @FormatString
                                      java.lang.String errorMessageTemplate,
                                      @Nullable
                                      java.lang.Object... errorMessageArgs)
        Ensures the truth of an expression involving the state of the calling instance, but not involving any parameters to the calling method.

        e.g. checkState(foo.isABar(), "Failed because of %s is not a bar", foo);

        Parameters:
        expression - a boolean expression
        badElement - the element that was at fault
        errorMessageTemplate - a template for the exception message should the check fail. The message is formed by replacing each %s placeholder in the template with an argument. These are matched by position - the first %s gets errorMessageArgs[0], etc. Unmatched arguments will be appended to the formatted message in square braces. Unmatched placeholders will be left as-is.
        errorMessageArgs - the arguments to be substituted into the message template. Arguments are converted to strings using String.valueOf(Object).
        Throws:
        BadInputException - if expression is false
        java.lang.NullPointerException - if the check fails and either errorMessageTemplate or errorMessageArgs is null (don't let this happen)
      • checkStateX

        @FormatMethod
        public static void checkStateX​(boolean expression,
                                       java.util.Collection<? extends androidx.room.compiler.processing.XElement> badElements,
                                       @Nullable @FormatString
                                       java.lang.String errorMessageTemplate,
                                       @Nullable
                                       java.lang.Object... errorMessageArgs)
        Ensures the truth of an expression involving the state of the calling instance, but not involving any parameters to the calling method.
        Parameters:
        expression - a boolean expression
        badElements - the elements that were at fault
        errorMessageTemplate - a template for the exception message should the check fail. The message is formed by replacing each %s placeholder in the template with an argument. These are matched by position - the first %s gets errorMessageArgs[0], etc. Unmatched arguments will be appended to the formatted message in square braces. Unmatched placeholders will be left as-is.
        errorMessageArgs - the arguments to be substituted into the message template. Arguments are converted to strings using String.valueOf(Object).
        Throws:
        BadInputException - if expression is false
        java.lang.NullPointerException - if the check fails and either errorMessageTemplate or errorMessageArgs is null (don't let this happen)