001 /****************************************************************
002 * Licensed to the Apache Software Foundation (ASF) under one *
003 * or more contributor license agreements. See the NOTICE file *
004 * distributed with this work for additional information *
005 * regarding copyright ownership. The ASF licenses this file *
006 * to you under the Apache License, Version 2.0 (the *
007 * "License"); you may not use this file except in compliance *
008 * with the License. You may obtain a copy of the License at *
009 * *
010 * http://www.apache.org/licenses/LICENSE-2.0 *
011 * *
012 * Unless required by applicable law or agreed to in writing, *
013 * software distributed under the License is distributed on an *
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
015 * KIND, either express or implied. See the License for the *
016 * specific language governing permissions and limitations *
017 * under the License. *
018 ****************************************************************/
019 package org.apache.james.mailbox.jpa.mail.model;
020
021 import javax.persistence.Basic;
022 import javax.persistence.Column;
023 import javax.persistence.Entity;
024 import javax.persistence.GeneratedValue;
025 import javax.persistence.Id;
026 import javax.persistence.Table;
027
028 @Entity(name="UserFlag")
029 @Table(name="JAMES_MAIL_USERFLAG")
030 public class JPAUserFlag {
031
032
033 /** The system unique key */
034 @Id
035 @GeneratedValue
036 @Column(name = "USERFLAG_ID", nullable = true)
037 private long id;
038
039 /** Local part of the name of this property */
040 @Basic(optional = false)
041 @Column(name = "USERFLAG_NAME", nullable = false, length = 500)
042 private String name;
043
044
045 /**
046 * @deprecated enhancement only
047 */
048 @Deprecated
049 public JPAUserFlag() {}
050
051 /**
052 * Constructs a User Flag.
053 * @param name not null
054 */
055 public JPAUserFlag(String name) {
056 super();
057 this.name = name;
058 }
059
060 /**
061 * Constructs a User Flag, cloned from the given.
062 * @param flag not null
063 */
064 public JPAUserFlag(JPAUserFlag flag) {
065 this(flag.getName());
066 }
067
068
069
070 /**
071 * Gets the name.
072 * @return not null
073 */
074 public String getName() {
075 return name;
076 }
077
078 @Override
079 public int hashCode() {
080 final int PRIME = 31;
081 int result = 1;
082 result = PRIME * result + (int) (id ^ (id >>> 32));
083 return result;
084 }
085
086 @Override
087 public boolean equals(Object obj) {
088 if (this == obj)
089 return true;
090 if (obj == null)
091 return false;
092 if (getClass() != obj.getClass())
093 return false;
094 final JPAUserFlag other = (JPAUserFlag) obj;
095 if (id != other.id)
096 return false;
097 return true;
098 }
099
100 /**
101 * Constructs a <code>String</code> with all attributes
102 * in name = value format.
103 *
104 * @return a <code>String</code> representation
105 * of this object.
106 */
107 public String toString() {
108 final String result = "JPAUserFlag ( "
109 + "id = " + this.id + " "
110 + "name = " + this.name
111 + " )";
112
113 return result;
114 }
115
116 }