class Switches {

    void method1(String input) {
        var value = switch (input) {
            case "a" -> 1;
            case "b" -> 2;
            default -> 0;
        };
        System.out.println(value);
    }

    void method11(String input) {
        var value = switch (input) {
            case "a" -> {
                yield 1;
            }
            case "b" -> {
                yield 2;
            }
            default -> {
                yield 0;
            }
        };
        System.out.println(value);
    }

    void method2(Object obj) {
        var result = switch (obj) {
            case Integer i -> String.format("int %d", i);
            case Long l    -> String.format("long %d", l);
            case Double d  -> String.format("double %f", d);
            case String s  -> String.format("String %s", s);
            default        -> obj.toString();
        };
        System.out.println(result);
    }

    void method3(Object obj) {
        var result = switch (obj) {
            case Integer _ -> "int";
            case Long _    -> "long";
            case Double _  -> "double";
            case String _  -> "string";
            default        -> "other";
        };
    }

    record Point(int x, int y) {}

    void method4(Point point) {

        var result = switch (point) {
            case Point(var x, var y) when y == 0 -> processX(x);
            case Point(var x, var y) -> processXY(x, y);
        };
    }

    int processX(int x) {
        return 0;
    }

    int processXY(int x, int y) {
        return 0;
    }

    void method5(Object obj) {
        var result = switch (obj) {
            case null      -> "null";
            case Integer i -> String.format("int %d", i);
            case Long l    -> String.format("long %d", l);
            case Double d  -> String.format("double %f", d);
            case String s  -> String.format("String %s", s);
            default        -> obj.toString();
        };
    }
}
