git://git.nikiroo.be
/
fanfix.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
stubs for TFileOpenBox, cleanup putStringXY
[fanfix.git]
/
src
/
jexer
/
bits
/
Color.java
diff --git
a/src/jexer/bits/Color.java
b/src/jexer/bits/Color.java
index 707b244b12664aa04a2c691cb73cfa3973d06e27..31be310ad0dd5fd9f1474556e99edf9d8f1a16e9 100644
(file)
--- a/
src/jexer/bits/Color.java
+++ b/
src/jexer/bits/Color.java
@@
-66,26
+66,27
@@
public final class Color {
* @return Color.RED, Color.BLUE, etc.
*/
static Color getColor(final String colorName) {
* @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;
return Color.BLACK;
- case "white":
+ } else if (str.equals("white")) {
return Color.WHITE;
return Color.WHITE;
- case "red":
+ } else if (str.equals("red")) {
return Color.RED;
return Color.RED;
- case "cyan":
+ } else if (str.equals("cyan")) {
return Color.CYAN;
return Color.CYAN;
- case "green":
+ } else if (str.equals("green")) {
return Color.GREEN;
return Color.GREEN;
- case "magenta":
+ } else if (str.equals("magenta")) {
return Color.MAGENTA;
return Color.MAGENTA;
- case "blue":
+ } else if (str.equals("blue")) {
return Color.BLUE;
return Color.BLUE;
- case "yellow":
+ } else if (str.equals("yellow")) {
return Color.YELLOW;
return Color.YELLOW;
- case "brown":
+ } else if (str.equals("brown")) {
return Color.YELLOW;
return Color.YELLOW;
- default:
+ } else {
// Let unknown strings become white
return Color.WHITE;
}
// Let unknown strings become white
return Color.WHITE;
}
@@
-215,6
+216,16
@@
public final class Color {
return (value == that.value);
}
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.
*
/**
* Make human-readable description of this Color.
*
@@
-239,8
+250,9
@@
public final class Color {
return "blue";
case SGRYELLOW:
return "yellow";
return "blue";
case SGRYELLOW:
return "yellow";
+ default:
+ throw new IllegalArgumentException("Invalid Color value: " + value);
}
}
- throw new IllegalArgumentException("Invalid Color value: " + value);
}
}
}
}