001/*
002 * (C) Copyright 2010-2013 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.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 *     Olivier Grisel
016 */
017package org.nuxeo.ecm.platform.suggestbox.service.descriptors;
018
019import org.nuxeo.common.xmap.annotation.XNode;
020import org.nuxeo.common.xmap.annotation.XObject;
021
022/**
023 * XMap descriptor for registering suggester names in a suggesterGroup contribution.
024 *
025 * @author ataillefer
026 */
027@XObject("suggesterName")
028public class SuggesterGroupItemDescriptor implements Cloneable {
029
030    @XNode("")
031    protected String name;
032
033    @XNode("@appendBefore")
034    protected String appendBefore;
035
036    @XNode("@appendAfter")
037    protected String appendAfter;
038
039    @XNode("@remove")
040    protected boolean remove;
041
042    // default constructor
043    public SuggesterGroupItemDescriptor() {
044    }
045
046    public SuggesterGroupItemDescriptor(String name) {
047        this.name = name;
048    }
049
050    public String getName() {
051        return name;
052    }
053
054    public String getAppendBefore() {
055        return appendBefore;
056    }
057
058    public String getAppendAfter() {
059        return appendAfter;
060    }
061
062    public boolean isRemove() {
063        return remove;
064    }
065
066    /*
067     * Override the Object.clone to make it public
068     */
069    @Override
070    public Object clone() throws CloneNotSupportedException {
071        return super.clone();
072    }
073
074    @Override
075    public boolean equals(Object other) {
076
077        if (other == this) {
078            return true;
079        }
080        if (other == null || !(other instanceof SuggesterGroupItemDescriptor)) {
081            return false;
082        }
083
084        String otherName = ((SuggesterGroupItemDescriptor) other).getName();
085        return name == null && otherName == null || name != null && name.equals(otherName);
086    }
087
088    @Override
089    public String toString() {
090        return name;
091    }
092}