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");
}RequireNonNull
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("RequireNonNull")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!PreconditionsRules\$RequireNonNull).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
String testRequireNonNull() {
- return checkNotNull("foo");
+ return requireNonNull("foo");
}RequireNonNullStatement
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("RequireNonNullStatement")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!PreconditionsRules\$RequireNonNullStatement).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testRequireNonNullStatement() {
- if ("foo" == null) {
- throw new NullPointerException();
- }
+ requireNonNull("foo");
}RequireNonNullWithMessage
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("RequireNonNullWithMessage")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!PreconditionsRules\$RequireNonNullWithMessage).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
String testRequireNonNullWithMessage() {
- return checkNotNull("foo", "The string is null");
+ return requireNonNull("foo", "The string is null");
}RequireNonNullWithMessageStatement
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("RequireNonNullWithMessageStatement")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!PreconditionsRules\$RequireNonNullWithMessageStatement).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testRequireNonNullWithMessageStatement() {
- if ("foo" == null) {
- throw new NullPointerException("The string is null");
- }
+ requireNonNull("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");
}