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