001/*
002 * (C) Copyright 2015 Nuxeo SA (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl-2.1.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Anahide Tchertchian
016 */
017package org.nuxeo.theme.styling.service.descriptors;
018
019import java.io.Serializable;
020
021import org.apache.commons.lang.builder.EqualsBuilder;
022import org.nuxeo.common.xmap.annotation.XContent;
023import org.nuxeo.common.xmap.annotation.XNode;
024import org.nuxeo.common.xmap.annotation.XObject;
025
026/**
027 * Descriptor for icon elements.
028 *
029 * @since 7.4
030 */
031@XObject("icon")
032public class IconDescriptor implements Serializable {
033
034    private static final long serialVersionUID = 1L;
035
036    @XNode("@name")
037    protected String name;
038
039    protected String value;
040
041    @XNode("@sizes")
042    protected String sizes;
043
044    public String getName() {
045        return name;
046    }
047
048    public void setName(String name) {
049        this.name = name;
050    }
051
052    public String getValue() {
053        return value;
054    }
055
056    @XContent
057    public void setValue(String value) {
058        if (value != null) {
059            this.value = value.trim();
060        } else {
061            this.value = value;
062        }
063    }
064
065    public String getSizes() {
066        return sizes;
067    }
068
069    public void setSizes(String sizes) {
070        this.sizes = sizes;
071    }
072
073    @Override
074    public IconDescriptor clone() {
075        IconDescriptor clone = new IconDescriptor();
076        clone.name = name;
077        clone.value = value;
078        clone.sizes = sizes;
079        return clone;
080    }
081
082    @Override
083    public boolean equals(Object obj) {
084        if (!(obj instanceof IconDescriptor)) {
085            return false;
086        }
087        if (obj == this) {
088            return true;
089        }
090        IconDescriptor b = (IconDescriptor) obj;
091        return new EqualsBuilder().append(name, b.name).append(value, b.value).append(sizes, b.sizes).isEquals();
092    }
093
094}