Package dagger.hilt.processor.internal
Class ProcessorErrors
- java.lang.Object
-
- dagger.hilt.processor.internal.ProcessorErrors
-
public final class ProcessorErrors extends java.lang.ObjectStatic helper methods for throwing errors during code generation.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcheckNotErrorKind(javax.lang.model.element.TypeElement element)Ensures that the given element is not an error kind and does not inherit from an error kind.static voidcheckState(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 voidcheckState(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 voidcheckState(boolean expression, java.util.Collection<? extends javax.lang.model.element.Element> badElements, 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 voidcheckState(boolean expression, java.util.Collection<? extends javax.lang.model.element.Element> 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.static voidcheckState(boolean expression, javax.lang.model.element.Element 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 voidcheckState(boolean expression, javax.lang.model.element.Element 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.
-
-
-
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 expressionerrorMessage- the exception message to use if the check fails; will be converted to a string usingString.valueOf(Object)- Throws:
BadInputException- ifexpressionis 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 expressionerrorMessageTemplate- a template for the exception message should the check fail. The message is formed by replacing each%splaceholder in the template with an argument. These are matched by position - the first%sgetserrorMessageArgs[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 usingString.valueOf(Object).- Throws:
BadInputException- ifexpressionis falsejava.lang.NullPointerException- if the check fails and eithererrorMessageTemplateorerrorMessageArgsis null (don't let this happen)
-
checkState
public static void checkState(boolean expression, javax.lang.model.element.Element 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 expressionbadElement- the element that was at faulterrorMessage- the exception message to use if the check fails; will be converted to a string usingString.valueOf(Object)- Throws:
BadInputException- ifexpressionis false
-
checkState
@FormatMethod public static void checkState(boolean expression, javax.lang.model.element.Element 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 expressionbadElement- the element that was at faulterrorMessageTemplate- a template for the exception message should the check fail. The message is formed by replacing each%splaceholder in the template with an argument. These are matched by position - the first%sgetserrorMessageArgs[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 usingString.valueOf(Object).- Throws:
BadInputException- ifexpressionis falsejava.lang.NullPointerException- if the check fails and eithererrorMessageTemplateorerrorMessageArgsis null (don't let this happen)
-
checkState
public static void checkState(boolean expression, java.util.Collection<? extends javax.lang.model.element.Element> badElements, @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 expressionbadElements- the element that were at faulterrorMessage- the exception message to use if the check fails; will be converted to a string usingString.valueOf(Object)- Throws:
BadInputException- ifexpressionis false
-
checkState
@FormatMethod public static void checkState(boolean expression, java.util.Collection<? extends javax.lang.model.element.Element> 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 expressionbadElements- the elements that were at faulterrorMessageTemplate- a template for the exception message should the check fail. The message is formed by replacing each%splaceholder in the template with an argument. These are matched by position - the first%sgetserrorMessageArgs[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 usingString.valueOf(Object).- Throws:
BadInputException- ifexpressionis falsejava.lang.NullPointerException- if the check fails and eithererrorMessageTemplateorerrorMessageArgsis null (don't let this happen)
-
checkNotErrorKind
public static void checkNotErrorKind(javax.lang.model.element.TypeElement element)
Ensures that the given element is not an error kind and does not inherit from an error kind.- Parameters:
element- the element to check- Throws:
ErrorTypeException- ifelementinherits from an error kind.
-
-