mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-15 00:17:45 +00:00
[jdk21] Remove test for parenthesized pattern (removed in JEP 441)
This commit is contained in:
1 parent
73d2686bc2
commit
cb76e67205
3 files changed
+52
-1
No files matched your search
@@ -0,0 +1,25 @@
|
||||
public class Switch21 {
|
||||
String switchPatternMatching(Object o) {
|
||||
return switch (o) {
|
||||
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 -> o.toString();
|
||||
};
|
||||
}
|
||||
|
||||
String switchNull(Object o) {
|
||||
return switch (o) {
|
||||
case null, default -> "?";
|
||||
};
|
||||
}
|
||||
|
||||
String switchGuardPattern(Object o) {
|
||||
return switch (o) {
|
||||
case String s when s.length() > 1 -> s;
|
||||
case String s -> s;
|
||||
default -> o.toString();
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// version 19:
|
||||
// version 19:20
|
||||
public class Switch19 {
|
||||
String switchPatternMatching(Object o) {
|
||||
return switch (o) {
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
// version 21:
|
||||
public class Switch21 {
|
||||
String switchPatternMatching(Object o) {
|
||||
return switch (o) {
|
||||
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 -> o.toString();
|
||||
};
|
||||
}
|
||||
|
||||
String switchNull(Object o) {
|
||||
return switch (o) {
|
||||
case null, default -> "?";
|
||||
};
|
||||
}
|
||||
|
||||
String switchGuardPattern(Object o) {
|
||||
return switch (o) {
|
||||
case String s when s.length() > 1 -> s;
|
||||
case String s -> s;
|
||||
default -> o.toString();
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user