package dfa;
public class SwitchPrimitivePatternList {
public static void main(String[] args) {
testChar();
testByte();
testShort();
testInt();
testLong();
testFloat();
testDouble();
testCharObject();
testByteObject();
testShortObject();
testIntObject();
testLongObject();
testFloatObject();
testDoubleObject();
}
private static void testCharObject() {
Character i = 0;
switch (i) {
case char d -> System.out.println("1");
case byte d -> System.out.println("1");//error
case short d -> System.out.println("1");//error
case int d -> System.out.println("1");
case long d -> System.out.println("1");
case float d -> System.out.println("1");
case double d -> System.out.println("1");
}
}
private static void testByteObject() {
Byte i = 0;
switch (i) {
case char d -> System.out.println("1");//error
case byte d -> System.out.println("1");
case short d -> System.out.println("1");
case int d -> System.out.println("1");
case long d -> System.out.println("1");
case float d -> System.out.println("1");
case double d -> System.out.println("1");
}
}
private static void testShortObject() {
Short i = 0;
switch (i) {
case char d -> System.out.println("1");//error
case byte d -> System.out.println("1");//error
case short d -> System.out.println("1");
case int d -> System.out.println("1");
case long d -> System.out.println("1");
case float d -> System.out.println("1");
case double d -> System.out.println("1");
}
}
private static void testIntObject() {
Integer i = 0;
switch (i) {
case char d -> System.out.println("1");//error
case byte d -> System.out.println("1");//error
case short d -> System.out.println("1");//error
case int d -> System.out.println("1");
case long d -> System.out.println("1");
case float d -> System.out.println("1");
case double d -> System.out.println("1");
}
}
private static void testLongObject() {
Long i = 0L;
switch (i) {
case char d -> System.out.println("1");//error
case byte d -> System.out.println("1");//error
case short d -> System.out.println("1");//error
case int d -> System.out.println("1");//error
case long d -> System.out.println("1");
case float d -> System.out.println("1");
case double d -> System.out.println("1");
}
}
private static void testFloatObject() {
Float i = 0F;
switch (i) {
case char d -> System.out.println("1");//error
case byte d -> System.out.println("1");//error
case short d -> System.out.println("1");//error
case int d -> System.out.println("1");//error
case long d -> System.out.println("1");//error
case float d -> System.out.println("1");
case double d -> System.out.println("1");
}
}
private static void testDoubleObject() {
Double i = 0.0;
switch (i) {
case char d -> System.out.println("1");//error
case byte d -> System.out.println("1");//error
case short d -> System.out.println("1");//error
case int d -> System.out.println("1");//error
case long d -> System.out.println("1");//error
case float d -> System.out.println("1");//error
case double d -> System.out.println("1");
}
}
private static void testChar() {
char i = 0;
switch (i) {
case char d -> System.out.println("1");//error
case byte d -> System.out.println("1");
case short d -> System.out.println("1");
case int d -> System.out.println("1"); //error
case long d -> System.out.println("1");//error
case float d -> System.out.println("1");//error
case double d -> System.out.println("1");//error
}
}
private static void testByte() {
byte i = 0;
switch (i) {
case char d -> System.out.println("1");
case byte d -> System.out.println("1");//error
case short d -> System.out.println("1");//error
case int d -> System.out.println("1");//error
case long d -> System.out.println("1");//error
case float d -> System.out.println("1");//error
case double d -> System.out.println("1");//error
}
}
private static void testShort() {
short i = 0;
switch (i) {
case char d -> System.out.println("1");
case byte d -> System.out.println("1");
case short d -> System.out.println("1");//error
case int d -> System.out.println("1");//error
case long d -> System.out.println("1");//error
case float d -> System.out.println("1");//error
case double d -> System.out.println("1");//error
}
}
private static void testInt() {
int i = 0;
switch (i) {
case char d -> System.out.println("1");
case byte d -> System.out.println("1");
case short d -> System.out.println("1");
case int d -> System.out.println("1");//error
case long d -> System.out.println("1");//error
case float d -> System.out.println("1");
case double d -> System.out.println("1");//error
}
}
private static void testLong() {
long i = 0;
switch (i) {
case char d -> System.out.println("1");
case byte d -> System.out.println("1");
case short d -> System.out.println("1");
case int d -> System.out.println("1");
case long d -> System.out.println("1");
case float d -> System.out.println("1");
case double d -> System.out.println("1");
}
}
private static void testFloat() {
float i = 0;
switch (i) {
case char d -> System.out.println("1");
case byte d -> System.out.println("1");
case short d -> System.out.println("1");
case int d -> System.out.println("1");
case long d -> System.out.println("1");
case float d -> System.out.println("1");//error
case double d -> System.out.println("1");//error
case Float f -> System.out.println();//error
}
}
private static void testDouble() {
double i = 0;
switch (i) {
case char d -> System.out.println("1");
case byte d -> System.out.println("1");
case short d -> System.out.println("1");
case int d -> System.out.println("1");
case long d -> System.out.println("1");
case float d -> System.out.println("1");
case double d -> System.out.println("1");
}
}
}