001: /*
002: * Copyright 2004-2006 the original author or authors.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.compass.sample.library;
018:
019: /**
020: *
021: * @author kimchy
022: */
023: public class Name {
024:
025: private String title;
026:
027: private String firstName;
028:
029: private String lastName;
030:
031: public Name() {
032:
033: }
034:
035: public Name(String title, String firstName, String lastName) {
036: this .title = title;
037: this .firstName = firstName;
038: this .lastName = lastName;
039: }
040:
041: public String getFirstName() {
042: return firstName;
043: }
044:
045: public void setFirstName(String firstName) {
046: this .firstName = firstName;
047: }
048:
049: public String getLastName() {
050: return lastName;
051: }
052:
053: public void setLastName(String lastName) {
054: this .lastName = lastName;
055: }
056:
057: public String getTitle() {
058: return title;
059: }
060:
061: public void setTitle(String title) {
062: this .title = title;
063: }
064:
065: public boolean equals(Object other) {
066: if (this == other) {
067: return true;
068: }
069:
070: if (!(other instanceof Name)) {
071: return false;
072: }
073:
074: Name otherName = (Name) other;
075: if (title != null) {
076: if (!title.equals(otherName.getTitle())) {
077: return false;
078: }
079: }
080: if (firstName != null) {
081: if (!firstName.equals(otherName.getFirstName())) {
082: return false;
083: }
084: }
085: if (lastName != null) {
086: if (!lastName.equals(otherName.getLastName())) {
087: return false;
088: }
089: }
090: return true;
091: }
092:
093: public int hashCode() {
094: int hash = 1;
095: hash = hash * 31 + title == null ? 0 : title.hashCode();
096: hash = hash * 31 + firstName == null ? 0 : firstName.hashCode();
097: hash = hash * 31 + lastName == null ? 0 : lastName.hashCode();
098: return hash;
099: }
100:
101: public String toString() {
102: return title + " " + " " + firstName + " " + lastName;
103: }
104: }
|