001/*
002 * (C) Copyright 2015 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Anahide Tchertchian
018 */
019package org.nuxeo.theme.styling.service.descriptors;
020
021import org.apache.commons.lang3.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 {
033
034    @XNode("@name")
035    protected String name;
036
037    protected String value;
038
039    @XNode("@sizes")
040    protected String sizes;
041
042    public String getName() {
043        return name;
044    }
045
046    public void setName(String name) {
047        this.name = name;
048    }
049
050    public String getValue() {
051        return value;
052    }
053
054    @XContent
055    public void setValue(String value) {
056        if (value != null) {
057            this.value = value.trim();
058        } else {
059            this.value = value;
060        }
061    }
062
063    public String getSizes() {
064        return sizes;
065    }
066
067    public void setSizes(String sizes) {
068        this.sizes = sizes;
069    }
070
071    @Override
072    public IconDescriptor clone() {
073        IconDescriptor clone = new IconDescriptor();
074        clone.name = name;
075        clone.value = value;
076        clone.sizes = sizes;
077        return clone;
078    }
079
080    @Override
081    public boolean equals(Object obj) {
082        if (!(obj instanceof IconDescriptor)) {
083            return false;
084        }
085        if (obj == this) {
086            return true;
087        }
088        IconDescriptor b = (IconDescriptor) obj;
089        return new EqualsBuilder().append(name, b.name).append(value, b.value).append(sizes, b.sizes).isEquals();
090    }
091
092}