1
2
3
4
5
6 package com.puppycrawl.tools.checkstyle.checks.coding.unnecessarynullcheckwithinstanceof;
7
8 public class InputUnnecessaryNullCheckWithInstanceOfNestedIf {
9 public void nestedIfStatements(Object obj) {
10 if (obj.hashCode() > 0) {
11 if (obj != null && obj instanceof String) {
12 String str = (String) obj;
13 }
14 }
15 if (true) {
16 if (obj.hashCode() > 0) {
17
18 if (obj != null && obj instanceof String) {
19 String str = (String) obj;
20 }
21 }
22 }
23 }
24 public void nestedIfWithMultipleObjects(Object obj1, Object obj2) {
25 if (obj1 != null) {
26 if (obj2 != null && obj2 instanceof String) {
27 String str = (String) obj2;
28 }
29 }
30 }
31 }