001/*
002 * (C) Copyright 2006-2007 Nuxeo SAS <http://nuxeo.com> and others
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the Eclipse Public License v1.0
006 * which accompanies this distribution, and is available at
007 * http://www.eclipse.org/legal/epl-v10.html
008 *
009 * Contributors:
010 *     Jean-Marc Orliaguet, Chalmers
011 *
012 * $Id$
013 */
014
015package org.nuxeo.theme.themes;
016
017import java.util.Arrays;
018import java.util.List;
019
020import org.nuxeo.common.xmap.annotation.XNode;
021import org.nuxeo.common.xmap.annotation.XObject;
022
023@XObject("theme")
024public class ThemeSetEntry {
025
026    @XNode("@name")
027    public String name;
028
029    @XNode("@features")
030    public String features = "";
031
032    public ThemeSetEntry() {
033    }
034
035    public ThemeSetEntry(String name) {
036        this.name = name;
037    }
038
039    public String getName() {
040        return name;
041    }
042
043    public List<String> getFeatures() {
044        return Arrays.asList(features.split(","));
045    }
046
047    public void addFeature(String feature) {
048        if (!getFeatures().contains(feature)) {
049            features += features.concat(",").concat(feature);
050        }
051    }
052
053    public void removeFeature(String feature) {
054        List<String> featuresList = getFeatures();
055        features = "";
056        for (String f : featuresList) {
057            if (!f.equals(feature)) {
058                addFeature(f);
059            }
060        }
061    }
062
063}