Bug 566389

Summary: [12] Convert if statement to switch expression
Product: [Eclipse Project] JDT Reporter: Sarika Sinha <sarika.sinha>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P3 CC: kalyan_prasad, manoj.palat, noopur_gupta
Version: 4.17   
Target Milestone: ---   
Hardware: All   
OS: All   
See Also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=545342
Whiteboard:

Description Sarika Sinha CLA 2020-08-26 02:14:26 EDT
Similar to Bug 545342, it will be good to have a quick assist to convert if statement to switch expression.

public static void foo(int num) {
			int res;
			if (num == 100) {
				res = 1;
			} else if (num == 200) {
				res = 2;
			} else if (num == 300 || num == 3000) {
				res = 3;
			} else if (num == 400) {
				res = 4;
			} else {
				res = -1;
			}
		}
	
		public static void foo1(int num) {
			int res= switch (num) {
			case 100-> 1;
			case 200-> 2;
			case 300,3000-> 3;
			case 400-> 4;
			default -> -1;
			};
		}