JavaCompilerCore/resources/syntaxtreegenerator/javFiles/Switch.jav

52 lines
1.0 KiB
Plaintext
Raw Normal View History

import java.lang.Integer;
import java.lang.Boolean;
import java.lang.String;
import java.lang.Object;
class SwitchStatement {
2023-07-11 20:15:35 +00:00
switchStandard(){
str = "SwitchMe";
switch(str){
case String s: return true;
default: return false;
}
}
2023-07-11 20:15:35 +00:00
switchInteger(){
i = 5;
switch(i){
case Integer j:
case String s: i = 6; break;
default: i = 0; break;
}
return (i==0);
}
2023-07-11 20:15:35 +00:00
guardedPattern(){
var i = 1;
switch(i){
case Integer j && j == 1: return true;
default: return false;
}
}
record Coordinates(double x, double y) {}
2023-07-11 20:15:35 +00:00
recordPattern(Object obj){
switch(obj){
case Coordinates(double lat, double lon): return true;
default: return false;
}
}
2023-07-11 20:15:35 +00:00
}
record SwitchExpression(int x, int y){
boolean switchStandard(str){
return switch(str){
case String s -> yield true;
default -> yield false;
};
}
}