+
+ /**
+ * Comparison check. All fields must match to return true.
+ *
+ * @param rhs another Color instance
+ * @return true if all fields are equal
+ */
+ @Override
+ public boolean equals(final Object rhs) {
+ if (!(rhs instanceof Color)) {
+ return false;
+ }
+
+ Color that = (Color) rhs;
+ 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.
+ *
+ * @return displayable String "red", "blue", etc.
+ */
+ @Override
+ public String toString() {
+ switch (value) {
+ case SGRBLACK:
+ return "black";
+ case SGRWHITE:
+ return "white";
+ case SGRRED:
+ return "red";
+ case SGRCYAN:
+ return "cyan";
+ case SGRGREEN:
+ return "green";
+ case SGRMAGENTA:
+ return "magenta";
+ case SGRBLUE:
+ return "blue";
+ case SGRYELLOW:
+ return "yellow";
+ default:
+ throw new IllegalArgumentException("Invalid Color value: " + value);
+ }
+ }
+