Skip to content

Use pattern matching instead of type casting. #2785

@junghoon-vans

Description

@junghoon-vans

If a type is resolved using the instanceof method, there is no need to explicitly cast the type.
This is thanks to the addition of JEP 394: Pattern Matching for instanceof in Java 16.

For example, a CriteriaFilterProcessor.java might change to the following:

AS-IS

if (value instanceof Box) {
    geoBBox = GeoBox.fromBox((Box) value);
}

TO-BE

if (value instanceof Box box) {
    geoBBox = GeoBox.fromBox(box);
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions