Java tutorial
/* * Copyright 2012 Eng Kam Hon (kamhon@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package net.kamhon.ieagle.function.user.vo; import javax.persistence.Access; import javax.persistence.AccessType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.Table; import net.kamhon.ieagle.FrameworkConst; import net.kamhon.ieagle.vo.Manipulateable; import net.kamhon.ieagle.vo.annotation.ToTrim; import net.kamhon.ieagle.vo.annotation.ToUpperCase; import org.apache.commons.lang.builder.HashCodeBuilder; import org.hibernate.annotations.GenericGenerator; @Entity @Table(name = "app_user_role") @Access(AccessType.FIELD) public class UserRole extends net.kamhon.ieagle.vo.VoBase implements Manipulateable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(generator = "system-uuid") @GenericGenerator(name = "system-uuid", strategy = "uuid") @Column(name = "role_id", nullable = false, length = 32) private String roleId; @ToTrim @ToUpperCase @Column(name = "role_name", length = 50) private String roleName; @ToTrim @ToUpperCase @Column(name = "role_desc", length = 100) private String roleDesc; @Column(name = "comp_id", length = 32) private String compId; @ToUpperCase @ToTrim @Column(name = "user_type", length = 20, nullable = false) protected String userType; @ToTrim @ToUpperCase @Column(name = "status", length = 1) private String status; public UserRole() { } public UserRole(String roleId) { this.roleId = roleId; } public UserRole(boolean defaultValue) { if (defaultValue) { compId = FrameworkConst.DEFAULT_COMPANY; userType = "HQ"; status = FrameworkConst.STATUS_APPROVED; } } public String getUserType() { return userType; } public void setUserType(String userType) { this.userType = userType; } public String getRoleId() { return roleId; } public String getRoleName() { return roleName; } public String getRoleDesc() { return roleDesc; } public String getStatus() { return status; } public void setRoleId(String roleId) { this.roleId = roleId; } public void setRoleName(String roleName) { this.roleName = roleName; } public void setRoleDesc(String roleDesc) { this.roleDesc = roleDesc; } public String getCompId() { return compId; } public void setCompId(String compId) { this.compId = compId; } public void setStatus(String status) { this.status = status; } public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; final UserRole other = (UserRole) obj; if (this.roleId == null) { if (other.roleId != null) return false; } else if (!this.roleId.equals(other.roleId)) return false; return true; } public int hashCode() { HashCodeBuilder hashCode = new HashCodeBuilder(); if (roleId != null) hashCode.append(roleId); return hashCode.toHashCode(); } public boolean isApproveable() { return false; } public boolean isDeleteable() { return true; } public boolean isEditable() { return true; } }