Color extends Magnitude<Color> { public String title() { if (color == 0) { return "Black"; } else if (color == 0xffffff) { return "White"; } else { return "#" + Integer.toHexString(color).toUpperCase(); } } Color(final int color); int intValue(); @Override boolean isEqualTo(final Color number); @Override boolean isLessThan(final Color value); String title(); @Override boolean equals(final Object obj); @Override int hashCode(); @Override String toString(); static final Color WHITE; static final Color BLACK; }
@Test public void testToTitle() throws Exception { assertEquals("Black", Color.BLACK.title()); assertEquals("White", Color.WHITE.title()); assertEquals("#FE231D", new Color(0xfe231D).title()); }