public void inspectionToConvertInstanceof()

in java-samples/src/main/java/com/jetbrains/inspections/PatternMatchingForInstanceOf.java [22:39]


    public void inspectionToConvertInstanceof(Person person) {
        if (person instanceof Employee) {
            Employee employee = (Employee) person;
            if (employee.isBasedInOffice()) {
                employee.workFromHome();
            }
        }

        if (person instanceof Employee) {
            // 2021.1 / #JDK16 this can be replaced with a pattern variable
            Employee employee = (Employee) person;
            System.out.println(employee);
            employee = new Employee();
            if (employee.isBasedInOffice()) {
                employee.workFromHome();
            }
        }
    }