Package dagger.hilt.processor.internal
Class ProcessorErrors
java.lang.Object
dagger.hilt.processor.internal.ProcessorErrors
Static helper methods for throwing errors during code generation.
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
checkState
(boolean expression, androidx.room.compiler.processing.XElement badElement, 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, String errorMessageTemplate, 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, 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, String errorMessageTemplate, 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, Collection<? extends androidx.room.compiler.processing.XElement> badElements, String errorMessageTemplate, 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 Details
-
checkState
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
- ifexpression
is false
-
checkState
@FormatMethod public static void checkState(boolean expression, @Nullable @FormatString String errorMessageTemplate, @Nullable 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%s
placeholder in the template with an argument. These are matched by position - the first%s
getserrorMessageArgs[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
- ifexpression
is falseNullPointerException
- if the check fails and eithererrorMessageTemplate
orerrorMessageArgs
is null (don't let this happen)
-
checkState
public static void checkState(boolean expression, androidx.room.compiler.processing.XElement badElement, @Nullable 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
- ifexpression
is false
-
checkState
@FormatMethod public static void checkState(boolean expression, androidx.room.compiler.processing.XElement badElement, @Nullable @FormatString String errorMessageTemplate, @Nullable 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%s
placeholder in the template with an argument. These are matched by position - the first%s
getserrorMessageArgs[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
- ifexpression
is falseNullPointerException
- if the check fails and eithererrorMessageTemplate
orerrorMessageArgs
is null (don't let this happen)
-
checkStateX
@FormatMethod public static void checkStateX(boolean expression, Collection<? extends androidx.room.compiler.processing.XElement> badElements, @Nullable @FormatString String errorMessageTemplate, @Nullable 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%s
placeholder in the template with an argument. These are matched by position - the first%s
getserrorMessageArgs[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
- ifexpression
is falseNullPointerException
- if the check fails and eithererrorMessageTemplate
orerrorMessageArgs
is null (don't let this happen)
-