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 UserDetailsAccessExKey implements Serializable { private static final long serialVersionUID = 1L; @Column(name = "user_id", nullable = false) private String userId; @ToTrim @ToUpperCase @Column(name = "access_ex_code", length = 30, nullable = false) private String accessExCode; public UserDetailsAccessExKey() { } public String getUserId() { return userId; } public String getAccessExCode() { return accessExCode; } public void setUserId(String userId) { this.userId = userId; } public void setAccessExCode(String accessExCode) { this.accessExCode = accessExCode; } public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; final UserDetailsAccessExKey other = (UserDetailsAccessExKey) obj; if (this.userId == null) { if (other.userId != null) return false; } else if (!this.userId.equals(other.userId)) return false; if (this.accessExCode == null) { if (other.accessExCode != null) return false; } else if (!this.accessExCode.equals(other.accessExCode)) return false; return true; } public int hashCode() { HashCodeBuilder hashCode = new HashCodeBuilder(); if (userId != null) hashCode.append(userId); if (accessExCode != null) hashCode.append(accessExCode); return hashCode.toHashCode(); } }