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 java.io.Serializable; import javax.persistence.Column; import javax.persistence.Embeddable; import net.kamhon.ieagle.vo.annotation.ToTrim; import net.kamhon.ieagle.vo.annotation.ToUpperCase; import org.apache.commons.lang.builder.HashCodeBuilder; @Embeddable public class UserRoleAccessKey implements Serializable { private static final long serialVersionUID = 1L; @Column(name = "role_id", nullable = false) private String roleId; @ToTrim @ToUpperCase @Column(name = "access_code", length = 30, nullable = false) private String accessCode; public UserRoleAccessKey() { } public UserRoleAccessKey(String roleId, String accessCode) { this.roleId = roleId; this.accessCode = accessCode; } public String getRoleId() { return roleId; } public String getAccessCode() { return accessCode; } public void setRoleId(String roleId) { this.roleId = roleId; } public void setAccessCode(String accessCode) { this.accessCode = accessCode; } public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; final UserRoleAccessKey other = (UserRoleAccessKey) obj; if (this.roleId == null) { if (other.roleId != null) return false; } else if (!this.roleId.equals(other.roleId)) return false; if (this.accessCode == null) { if (other.accessCode != null) return false; } else if (!this.accessCode.equals(other.accessCode)) return false; return true; } public int hashCode() { HashCodeBuilder hashCode = new HashCodeBuilder(); if (roleId != null) hashCode.append(roleId); if (accessCode != null) hashCode.append(accessCode); return hashCode.toHashCode(); } }