PreconditionsRules
SUGGESTION
Simplification
Suppression
Disable all rules by adding
-XepOpt:Refaster:NamePattern=^(?!(PreconditionsRules.*))
as compiler argument.
Table of contents
CheckArgument
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("CheckArgument")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!(PreconditionsRules\.CheckArgument))
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testCheckArgument() {
- if ("foo".isEmpty()) {
- throw new IllegalArgumentException();
- }
+ checkArgument(!"foo".isEmpty());
}
CheckArgumentWithMessage
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("CheckArgumentWithMessage")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!(PreconditionsRules\.CheckArgumentWithMessage))
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testCheckArgumentWithMessage() {
- if ("foo".isEmpty()) {
- throw new IllegalArgumentException("The string is empty");
- }
+ checkArgument(!"foo".isEmpty(), "The string is empty");
}
CheckElementIndexWithMessage
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("CheckElementIndexWithMessage")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!(PreconditionsRules\.CheckElementIndexWithMessage))
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testCheckElementIndexWithMessage() {
- if (1 < 0 || 1 >= 2) {
- throw new IndexOutOfBoundsException("My index");
- }
+ checkElementIndex(1, 2, "My index");
}
CheckNotNull
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("CheckNotNull")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!(PreconditionsRules\.CheckNotNull))
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testCheckNotNull() {
- if ("foo" == null) {
- throw new NullPointerException();
- }
+ checkNotNull("foo");
}
CheckNotNullWithMessage
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("CheckNotNullWithMessage")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!(PreconditionsRules\.CheckNotNullWithMessage))
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testCheckNotNullWithMessage() {
- if ("foo" == null) {
- throw new NullPointerException("The string is null");
- }
+ checkNotNull("foo", "The string is null");
}
CheckPositionIndex
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("CheckPositionIndex")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!(PreconditionsRules\.CheckPositionIndex))
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testCheckPositionIndex() {
- if (1 < 0 || 1 > 2) {
- throw new IndexOutOfBoundsException();
- }
+ checkPositionIndex(1, 2);
}
CheckPositionIndexWithMessage
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("CheckPositionIndexWithMessage")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!(PreconditionsRules\.CheckPositionIndexWithMessage))
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testCheckPositionIndexWithMessage() {
- if (1 < 0 || 1 > 2) {
- throw new IndexOutOfBoundsException("My position");
- }
+ checkPositionIndex(1, 2, "My position");
}
CheckState
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("CheckState")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!(PreconditionsRules\.CheckState))
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testCheckState() {
- if ("foo".isEmpty()) {
- throw new IllegalStateException();
- }
+ checkState(!"foo".isEmpty());
}
CheckStateWithMessage
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("CheckStateWithMessage")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!(PreconditionsRules\.CheckStateWithMessage))
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testCheckStateWithMessage() {
- if ("foo".isEmpty()) {
- throw new IllegalStateException("The string is empty");
- }
+ checkState(!"foo".isEmpty(), "The string is empty");
}