1 /* 2 * Copyright 2009 :torweg free software group 3 * 4 * This program is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 3 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 * 17 */ 18 package org.torweg.pulse.util.entity; 19 20 import javax.persistence.Basic; 21 import javax.persistence.MappedSuperclass; 22 import javax.xml.bind.annotation.XmlElement; 23 24 import org.hibernate.search.annotations.Field; 25 import org.hibernate.search.annotations.Index; 26 import org.hibernate.search.annotations.Store; 27 import org.torweg.pulse.util.INamed; 28 29 /** 30 * a very basic abstract entity containing a name field with a protected setter 31 * only. 32 * <p> 33 * Subclasses depending on a unique name (e.g. 34 * {@link org.torweg.pulse.accesscontrol.User}) can declare the constraint via 35 * {@code @Table(uniqueConstraints = { @UniqueConstraint(columnNames = "name") })}. 36 * 37 * @author Thomas Weber 38 * @version $Revision: 1408 $ 39 */ 40 @MappedSuperclass 41 public class AbstractNamedEntity extends AbstractBasicEntity implements INamed { 42 43 /** 44 * serialVersionUID. 45 */ 46 private static final long serialVersionUID = -7796330939641839277L; 47 48 /** 49 * the name property of the entity. 50 */ 51 @Basic(optional = false) 52 @Field(index = Index.TOKENIZED, store = Store.YES) 53 @XmlElement(name = "name") 54 private String name; 55 56 /** 57 * sets the name of the entity. 58 * 59 * @param n 60 * the name to set 61 * @see org.torweg.pulse.util.INameable#setName(java.lang.String) 62 */ 63 protected void setName(final String n) { 64 this.name = n; 65 } 66 67 /** 68 * returns the name of the entity. 69 * 70 * @return the name 71 * @see org.torweg.pulse.util.INamed#getName() 72 */ 73 public final String getName() { 74 return this.name; 75 } 76 77 } 78