Replace the use of switchmaps with direct use of ordinal.
Bug:
Change-Id: Iee5cd16ba848617a7eaac3d55283621c54b36ff1
diff --git a/src/test/examples/switchmaps/Colors.java b/src/test/examples/switchmaps/Colors.java
new file mode 100644
index 0000000..b2c8dc1
--- /dev/null
+++ b/src/test/examples/switchmaps/Colors.java
@@ -0,0 +1,19 @@
+// Copyright (c) 2017, the R8 project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+package switchmaps;
+
+public enum Colors {
+ RED("rar"), BLUE("blew"), GREEN("soylent"), GRAY("fifty");
+
+ private String aField;
+
+ Colors(String string) {
+ aField = string;
+ }
+
+ @Override
+ public String toString() {
+ return aField;
+ }
+}
diff --git a/src/test/examples/switchmaps/Days.java b/src/test/examples/switchmaps/Days.java
new file mode 100644
index 0000000..b484bb5
--- /dev/null
+++ b/src/test/examples/switchmaps/Days.java
@@ -0,0 +1,8 @@
+// Copyright (c) 2017, the R8 project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+package switchmaps;
+
+public enum Days {
+ MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY;
+}
diff --git a/src/test/examples/switchmaps/Switches.java b/src/test/examples/switchmaps/Switches.java
new file mode 100644
index 0000000..bf16856
--- /dev/null
+++ b/src/test/examples/switchmaps/Switches.java
@@ -0,0 +1,66 @@
+// Copyright (c) 2017, the R8 project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+package switchmaps;
+
+public class Switches {
+
+ public static void main(String... args) {
+ for (Days value : Days.values()) {
+ switchWithDefault(value);
+ switchFull(value);
+ }
+ for (Colors color : Colors.values()) {
+ switchOnColors(color);
+ }
+ }
+
+ private static void switchOnColors(Colors color) {
+ System.out.println(color.toString());
+ switch (color) {
+ case GRAY:
+ System.out.println("not really");
+ break;
+ case GREEN:
+ System.out.println("sooo green");
+ break;
+ default:
+ System.out.println("colorful");
+ }
+ }
+
+ private static void switchWithDefault(Days day) {
+ switch (day) {
+ case WEDNESDAY:
+ case FRIDAY:
+ System.out.println("3 or 5");
+ break;
+ case SUNDAY:
+ System.out.println("7");
+ break;
+ default:
+ System.out.println("other");
+ }
+ }
+
+ private static void switchFull(Days day) {
+ switch (day) {
+ case MONDAY:
+ case WEDNESDAY:
+ case THURSDAY:
+ System.out.println("1, 3 or 4");
+ case TUESDAY:
+ case FRIDAY:
+ System.out.println("2 or 5");
+ break;
+ case SUNDAY:
+ System.out.println("7");
+ break;
+ case SATURDAY:
+ System.out.println("6");
+ break;
+ default:
+ System.out.println("other");
+ }
+ }
+}