package fr.tvbarthel.apps.cameracolorpicker.data;

/**
 * A simple data class representing a color.
 */
public class ColorItem {

    /**
     * The id of the color.
     */
    protected final long mId;

    /**
     * An int representing the value of the color.
     */
    protected int mColor;

    /**
     * A long representing the creation time of the color. (In milliseconds).
     */
    protected final long mCreationTime;

    /**
     * Create a new {@link fr.tvbarthel.apps.cameracolorpicker.data.ColorItem} with an id and a color.
     *
     * @param id    the id of the {@link fr.tvbarthel.apps.cameracolorpicker.data.ColorItem}. Should be unique.
     * @param color the color value.
     */
    public ColorItem(long id, int color) {
        mId = id;
        mColor = color;
        mCreationTime = System.currentTimeMillis();
    }

    /**
     * Create a new {@link fr.tvbarthel.apps.cameracolorpicker.data.ColorItem} with a color.
     * <p/>
     * The {@link fr.tvbarthel.apps.cameracolorpicker.data.ColorItem#mId} is set to the {@link fr.tvbarthel.apps.cameracolorpicker.data.ColorItem#mCreationTime}.
     *
     * @param color the color value.
     */
    public ColorItem(int color) {
        mId = mCreationTime = System.currentTimeMillis();
        mColor = color;
    }

    /**
     * Get the id of the {@link fr.tvbarthel.apps.cameracolorpicker.data.ColorItem}.
     *
     * @return the id of the {@link fr.tvbarthel.apps.cameracolorpicker.data.ColorItem}.
     */
    public long getId() {
        return mId;
    }

    /**
     * Get the value of the {@link fr.tvbarthel.apps.cameracolorpicker.data.ColorItem}.
     *
     * @return an integer representing the color value of the {@link fr.tvbarthel.apps.cameracolorpicker.data.ColorItem}.
     */
    public int getColor() {
        return mColor;
    }

    /**
     * Set the color valur of the {@link fr.tvbarthel.apps.cameracolorpicker.data.ColorItem}.
     *
     * @param color an integer representing the new color value of the {@link fr.tvbarthel.apps.cameracolorpicker.data.ColorItem}.
     */
    public void setColor(int color) {
        mColor = color;
    }

    /**
     * Get the creation time of the {@link fr.tvbarthel.apps.cameracolorpicker.data.ColorItem}.
     *
     * @return a long representing the creation time in milliseconds.
     */
    public long getCreationTime() {
        return mCreationTime;
    }

}

@@ -427,16 +427,161 @@
 nTime;%0A%0A
+    /**%0A     * A human readable string representation of the hexadecimal value of the color.%0A     */%0A    protected transient String mHexString;%0A%0A
     /**%0A
@@ -2272,39 +2272,132 @@
 ) %7B%0A        
-mColor = color;
+if (mColor != color) %7B%0A            mColor = color;%0A            mHexString = makeHexString(mColor);%0A        %7D
 %0A    %7D%0A%0A    
@@ -2613,24 +2613,24 @@
 ionTime() %7B%0A
-
         retu
@@ -2654,10 +2654,708 @@
 %0A    %7D%0A%0A
+    /**%0A     * Get a human readable representation of the hexadecimal value of the color.%0A     *%0A     * @return a human readable representation of the hexadecimal value.%0A     */%0A    public String getHexString() %7B%0A        if (mHexString == null) %7B%0A            mHexString = makeHexString(mColor);%0A        %7D%0A        return mHexString;%0A    %7D%0A%0A    /**%0A     * Make a human readable representation of the hexadecimal value of a color.%0A     *%0A     * @param value the integer representation the color.%0A     * @return a human readable representation of the hexadecimal value.%0A     */%0A    protected static String makeHexString(int value) %7B%0A        return %22#%22 + Integer.toHexString(value).substring(2);%0A    %7D%0A%0A
 %7D%0A

Add a human readable representation of the hexadecimal value of a color