File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -147,4 +147,28 @@ String x = """
147
147
System.out.println(" abc" );
148
148
}
149
149
}" " " ;
150
+ ```
151
+
152
+ ### ` invertEquals `
153
+
154
+ Inverts calls to ` Object.equals(Object) ` and ` String.equalsIgnoreCase(String) ` to avoid useless null pointer exception.
155
+
156
+ The caller must be nullable and the parameter must not be nullable.
157
+
158
+ By avoiding null pointer exceptions, the behavior may change.
159
+
160
+ For example:
161
+
162
+ ``` java
163
+ String message = getMessage();
164
+ boolean result1 = message. equals(" text" );
165
+ boolean result2 = message. equalsIgnoreCase(" text" );
166
+ ```
167
+
168
+ becomes:
169
+
170
+ ``` java
171
+ String message = getMessage();
172
+ boolean result1 = " text" . equals(message);
173
+ boolean result2 = " text" . equalsIgnoreCase(message);
150
174
```
Original file line number Diff line number Diff line change 1008
1008
" qualifyStaticMembers" ,
1009
1009
" addOverride" ,
1010
1010
" addDeprecated" ,
1011
- " stringConcatToTextBlock"
1011
+ " stringConcatToTextBlock" ,
1012
+ " invertEquals"
1012
1013
]
1013
1014
},
1014
1015
"default" : [],
You can’t perform that action at this time.
0 commit comments