001/* 002 * Copyright 2006-2014 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 * https://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 017package org.springframework.batch.sample.domain.person; 018 019import java.util.ArrayList; 020import java.util.List; 021 022import org.springframework.batch.sample.domain.order.Address; 023 024public class Person { 025 private String title = ""; 026 private String firstName = ""; 027 private String last_name = ""; 028 private int age = 0; 029 private Address address = new Address(); 030 private List<Child> children = new ArrayList<Child>(); 031 032 public Person() { 033 children.add(new Child()); 034 children.add(new Child()); 035 } 036 037 /** 038 * @return the address 039 */ 040 public Address getAddress() { 041 return address; 042 } 043 044 /** 045 * @param address the address to set 046 */ 047 public void setAddress(Address address) { 048 this.address = address; 049 } 050 051 /** 052 * @return the age 053 */ 054 public int getAge() { 055 return age; 056 } 057 058 /** 059 * @param age the age to set 060 */ 061 public void setAge(int age) { 062 this.age = age; 063 } 064 065 /** 066 * @return the firstName 067 */ 068 public String getFirstName() { 069 return firstName; 070 } 071 072 /** 073 * @param firstName the firstName to set 074 */ 075 public void setFirstName(String firstName) { 076 this.firstName = firstName; 077 } 078 079 /** 080 * @return the children 081 */ 082 public List<Child> getChildren() { 083 return children; 084 } 085 086 /** 087 * @param children the children to set 088 */ 089 public void setChildren(List<Child> children) { 090 this.children = children; 091 } 092 093 /** 094 * Intentionally non-standard method name for testing purposes 095 * @return the last_name 096 */ 097 public String getLast_name() { 098 return last_name; 099 } 100 101 /** 102 * Intentionally non-standard method name for testing purposes 103 * @param last_name the last_name to set 104 */ 105 public void setLast_name(String last_name) { 106 this.last_name = last_name; 107 } 108 109 /** 110 * @return the person_title 111 */ 112 public String getTitle() { 113 return title; 114 } 115 116 /** 117 * @param title the person title to set 118 */ 119 public void setTitle(String title) { 120 this.title = title; 121 } 122 123 @Override 124 public String toString() { 125 return "Person [address=" + address + ", age=" + age + ", children=" + children + ", firstName=" + firstName 126 + ", last_name=" + last_name + ", title=" + title + "]"; 127 } 128 129 @Override 130 public int hashCode() { 131 final int prime = 31; 132 int result = 1; 133 result = prime * result + ((address == null) ? 0 : address.hashCode()); 134 result = prime * result + age; 135 result = prime * result + ((children == null) ? 0 : children.hashCode()); 136 result = prime * result + ((firstName == null) ? 0 : firstName.hashCode()); 137 result = prime * result + ((last_name == null) ? 0 : last_name.hashCode()); 138 result = prime * result + ((title == null) ? 0 : title.hashCode()); 139 return result; 140 } 141 142 @Override 143 public boolean equals(Object obj) { 144 if (this == obj) { 145 return true; 146 } 147 148 if (obj == null) { 149 return false; 150 } 151 152 if (getClass() != obj.getClass()) { 153 return false; 154 } 155 156 Person other = (Person) obj; 157 158 if (address == null) { 159 if (other.address != null) { 160 return false; 161 } 162 } 163 else if (!address.equals(other.address)) { 164 return false; 165 } 166 167 if (age != other.age) { 168 return false; 169 } 170 171 if (children == null) { 172 if (other.children != null) { 173 return false; 174 } 175 } 176 else if (!children.equals(other.children)) { 177 return false; 178 } 179 180 if (firstName == null) { 181 if (other.firstName != null) { 182 return false; 183 } 184 } 185 else if (!firstName.equals(other.firstName)) { 186 return false; 187 } 188 189 if (last_name == null) { 190 if (other.last_name != null) { 191 return false; 192 } 193 } 194 else if (!last_name.equals(other.last_name)) { 195 return false; 196 } 197 198 if (title == null) { 199 if (other.title != null) { 200 return false; 201 } 202 } 203 else if (!title.equals(other.title)) { 204 return false; 205 } 206 207 return true; 208 } 209}