stubs for TFileOpenBox, cleanup putStringXY
[fanfix.git] / src / jexer / bits / Color.java
index 707b244b12664aa04a2c691cb73cfa3973d06e27..31be310ad0dd5fd9f1474556e99edf9d8f1a16e9 100644 (file)
@@ -66,26 +66,27 @@ public final class Color {
      * @return Color.RED, Color.BLUE, etc.
      */
     static Color getColor(final String colorName) {
-        switch (colorName.toLowerCase()) {
-        case "black":
+        String str = colorName.toLowerCase();
+
+        if (str.equals("black")) {
             return Color.BLACK;
-        case "white":
+        } else if (str.equals("white")) {
             return Color.WHITE;
-        case "red":
+        } else if (str.equals("red")) {
             return Color.RED;
-        case "cyan":
+        } else if (str.equals("cyan")) {
             return Color.CYAN;
-        case "green":
+        } else if (str.equals("green")) {
             return Color.GREEN;
-        case "magenta":
+        } else if (str.equals("magenta")) {
             return Color.MAGENTA;
-        case "blue":
+        } else if (str.equals("blue")) {
             return Color.BLUE;
-        case "yellow":
+        } else if (str.equals("yellow")) {
             return Color.YELLOW;
-        case "brown":
+        } else if (str.equals("brown")) {
             return Color.YELLOW;
-        default:
+        } else {
             // Let unknown strings become white
             return Color.WHITE;
         }
@@ -215,6 +216,16 @@ public final class Color {
         return (value == that.value);
     }
 
+    /**
+     * Hashcode uses all fields in equals().
+     *
+     * @return the hash
+     */
+    @Override
+    public int hashCode() {
+        return value;
+    }
+
     /**
      * Make human-readable description of this Color.
      *
@@ -239,8 +250,9 @@ public final class Color {
             return "blue";
         case SGRYELLOW:
             return "yellow";
+        default:
+            throw new IllegalArgumentException("Invalid Color value: " + value);
         }
-        throw new IllegalArgumentException("Invalid Color value: " + value);
     }
 
 }