class RecentPalettes {

    public static final String COLORS = "PaletteColors";
    public static final String POSITIONS = "PalettePositions";
    protected static String DEFAULT_NODE_NAME = "prefs";
    private final LinkedList<LinearGradient> gradients;
    private final int maxSize;
    protected String nodeName = null;

    public RecentPalettes() {
        nodeName = "recentrankingpalettes";
        maxSize = 14;
        gradients = new LinkedList<>();
        retrieve();
    }

    public void add(LinearGradient gradient) {
        //Remove the old
        gradients.remove(gradient);

        // add to the top
        gradients.push(new LinearGradient(gradient.getColors(), gradient.getPositions()));
        while (gradients.size() > maxSize) {
            gradients.removeLast();
        }

        store();
    }

    public LinearGradient[] getPalettes() {
        return gradients.toArray(new LinearGradient[0]);
    }

    private void store() {<FILL_FUNCTION_BODY>}

    private void retrieve() {
        gradients.clear();
        Preferences prefs = getPreferences();

        for (int i = 0; i < maxSize; i++) {
            byte[] cols = prefs.getByteArray(COLORS + i, null);
            byte[] poss = prefs.getByteArray(POSITIONS + i, null);
            if (cols != null && poss != null) {
                try {
                    Color[] colors = deserializeColors(cols);
                    float[] posisitons = deserializePositions(poss);
                    LinearGradient linearGradient = new LinearGradient(colors, posisitons);
                    gradients.addLast(linearGradient);
                } catch (Exception e) {
                    Exceptions.printStackTrace(e);
                }
            } else {
                break;
            }
        }
    }

    /**
     * Return the backing store Preferences
     *
     * @return Preferences
     */
    protected final Preferences getPreferences() {
        String name = DEFAULT_NODE_NAME;
        if (nodeName != null) {
            name = nodeName;
        }

        Preferences prefs = NbPreferences.forModule(this.getClass()).node("options").node(name);

        return prefs;
    }

    private byte[] serializePositions(float[] positions) throws Exception {
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        try (ObjectOutputStream out = new ObjectOutputStream(bos)) {
            out.writeObject(positions);
        }
        return bos.toByteArray();
    }

    private float[] deserializePositions(byte[] positions) throws Exception {
        ByteArrayInputStream bis = new ByteArrayInputStream(positions);
        float[] array;
        try (ObjectInputStream in = new ObjectInputStream(bis)) {
            array = (float[]) in.readObject();
        }
        return array;
    }

    private byte[] serializeColors(Color[] colors) throws Exception {
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        try (ObjectOutputStream out = new ObjectOutputStream(bos)) {
            out.writeObject(colors);
        }
        return bos.toByteArray();
    }

    private Color[] deserializeColors(byte[] colors) throws Exception {
        ByteArrayInputStream bis = new ByteArrayInputStream(colors);
        Color[] array;
        try (ObjectInputStream in = new ObjectInputStream(bis)) {
            array = (Color[]) in.readObject();
        }
        return array;
    }
}

        Preferences prefs = getPreferences();

        // clear the backing store
        try {
            prefs.clear();
        } catch (BackingStoreException ex) {
        }

        int i = 0;
        for (LinearGradient gradient : gradients) {
            try {
                prefs.putByteArray(COLORS + i, serializeColors(gradient.getColors()));
                prefs.putByteArray(POSITIONS + i, serializePositions(gradient.getPositions()));
            } catch (Exception e) {
                Exceptions.printStackTrace(e);
            }
            i++;
        }
    
<no_super_class>