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.language.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 LanguageResKey implements Serializable { private static final long serialVersionUID = 1L; @ToTrim @Column(name = "language_code", length = 5, nullable = false) private String languageCode; @ToTrim @ToUpperCase @Column(name = "key_code", length = 50, nullable = false) private String keyCode; public LanguageResKey() { } public LanguageResKey(String languageCode, String keyCode) { this.languageCode = languageCode; this.keyCode = keyCode; } public String getLanguageCode() { return languageCode; } public String getKeyCode() { return keyCode; } public void setLanguageCode(String languageCode) { this.languageCode = languageCode; } public void setKeyCode(String keyCode) { this.keyCode = keyCode; } public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; final LanguageResKey other = (LanguageResKey) obj; if (this.languageCode == null) { if (other.languageCode != null) return false; } else if (!this.languageCode.equals(other.languageCode)) return false; if (this.keyCode == null) { if (other.keyCode != null) return false; } else if (!this.keyCode.equals(other.keyCode)) return false; return true; } public int hashCode() { HashCodeBuilder hashCode = new HashCodeBuilder(); if (languageCode != null) hashCode.append(languageCode); if (keyCode != null) hashCode.append(keyCode); return hashCode.toHashCode(); } }