001/*
002 * (C) Copyright 2011 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.XNode;
023import org.nuxeo.common.xmap.annotation.XObject;
024
025/**
026 * @since 5.5
027 */
028@XObject("presets")
029public class FlavorPresets {
030
031    @XNode("@category")
032    String category;
033
034    @XNode("@src")
035    String src;
036
037    /**
038     * Resolved source content
039     */
040    String content;
041
042    public String getCategory() {
043        return category;
044    }
045
046    public String getSrc() {
047        return src;
048    }
049
050    public void setCategory(String category) {
051        this.category = category;
052    }
053
054    public void setSrc(String src) {
055        this.src = src;
056    }
057
058    public String getContent() {
059        return content;
060    }
061
062    public void setContent(String content) {
063        this.content = content;
064    }
065
066    @Override
067    public FlavorPresets clone() {
068        FlavorPresets clone = new FlavorPresets();
069        clone.setSrc(src);
070        clone.setCategory(category);
071        clone.setContent(content);
072        return clone;
073    }
074
075    @Override
076    public boolean equals(Object obj) {
077        if (!(obj instanceof FlavorPresets)) {
078            return false;
079        }
080        if (obj == this) {
081            return true;
082        }
083        FlavorPresets f = (FlavorPresets) obj;
084        // do not take content into account for overrides
085        return new EqualsBuilder().append(category, f.category).append(src, f.src).isEquals();
086    }
087
088}