WProperties extends Properties { public void putColorProperty(String key, Color color) { if (isValid(key, color)) { this.put(key, color2Hexadecimal(color, true)); } } WProperties(); @Override synchronized Object setProperty(String key, String value); @Override String getProperty(String key); void resetProperty(String key, String defaultValue); void resetServiceProperty(String key, String defaultValue); void putIntProperty(String key, int value); int getIntProperty(String key, int def); void putLongProperty(String key, long value); long getLongProperty(String key, long def); void putBooleanProperty(String key, boolean value); boolean getBooleanProperty(String key, boolean def); void putFloatProperty(String key, float value); float getFloatProperty(String key, float def); void putDoubleProperty(String key, double value); double getDoubleProperty(String key, double def); Color getColorProperty(String key); void putColorProperty(String key, Color color); void putByteArrayProperty(String key, byte[] value); byte[] getByteArrayProperty(String key, byte[] def); static String color2Hexadecimal(Color c, boolean alpha); static Color hexadecimal2Color(String hexColor); static void setProperty(WProperties properties, String key, Preferences prefNode, String defaultValue);  }
@Test public void testPutColorProperty() { WProperties prop = new WProperties(); prop.putColorProperty("color", COLOR_ALPHA); Assert.assertEquals("different color", COLOR_ALPHA, prop.getColorProperty("color")); prop.putColorProperty("color", Color.GREEN); Assert.assertEquals("different color", Color.GREEN, prop.getColorProperty("color")); prop.putColorProperty("color", null); Assert.assertEquals("different color", Color.GREEN, prop.getColorProperty("color")); }