From e1fe74b3f9a9eec74c3c8a888954a85611a3d0ee Mon Sep 17 00:00:00 2001 From: dsyer Date: Wed, 30 Dec 2009 11:04:11 +0000 Subject: [PATCH] BATCH-1470: remove commons-lang dependency --- spring-batch-core/pom.xml | 5 - .../dao/MapExecutionContextDao.java | 2 +- .../repository/dao/MapJobExecutionDao.java | 2 +- .../repository/dao/MapStepExecutionDao.java | 2 +- .../batch/core/ExitStatusTests.java | 2 +- .../batch/core/JobExecutionTests.java | 2 +- .../batch/core/JobInstanceTests.java | 4 +- .../batch/core/JobParametersTests.java | 2 +- .../batch/core/StepExecutionTests.java | 2 +- .../batch/core/resource/Foo.java | 38 ++- spring-batch-infrastructure-tests/pom.xml | 5 - .../batch/io/oxm/domain/Trade.java | 117 ++++--- spring-batch-infrastructure/pom.xml | 5 - .../batch/item/xml/StaxEventItemWriter.java | 8 +- .../batch/support/SerializationUtils.java | 78 +++++ .../batch/item/ExecutionContextTests.java | 34 +- .../batch/item/file/transform/Name.java | 39 ++- .../batch/item/sample/Customer.java | 53 +++- .../batch/item/sample/Foo.java | 41 ++- .../batch/item/sample/LineItem.java | 50 ++- .../batch/item/sample/Order.java | 62 +++- .../batch/item/sample/Shipper.java | 42 ++- spring-batch-parent/pom.xml | 2 +- spring-batch-samples/pom.xml | 4 - .../sample/common/StagingItemReader.java | 2 +- .../sample/common/StagingItemWriter.java | 2 +- .../batch/sample/domain/football/Game.java | 34 +- .../sample/domain/football/PlayerSummary.java | 31 +- .../batch/sample/domain/order/Address.java | 177 ++++++----- .../sample/domain/order/BillingInfo.java | 82 +++-- .../batch/sample/domain/order/Customer.java | 214 ++++++++----- .../batch/sample/domain/order/LineItem.java | 40 ++- .../batch/sample/domain/order/Order.java | 297 +++++++++++------- .../sample/domain/order/ShippingInfo.java | 94 ++++-- .../domain/order/internal/xml/Customer.java | 87 ++--- .../domain/order/internal/xml/Order.java | 72 ++--- .../batch/sample/domain/person/Child.java | 38 ++- .../batch/sample/domain/person/Person.java | 91 +++++- .../sample/domain/trade/CustomerDebit.java | 39 ++- .../batch/sample/domain/trade/Trade.java | 64 ++-- 40 files changed, 1343 insertions(+), 622 deletions(-) create mode 100644 spring-batch-infrastructure/src/main/java/org/springframework/batch/support/SerializationUtils.java diff --git a/spring-batch-core/pom.xml b/spring-batch-core/pom.xml index e02738d4d..fd57e796d 100644 --- a/spring-batch-core/pom.xml +++ b/spring-batch-core/pom.xml @@ -45,11 +45,6 @@ commons-io test - - commons-lang - commons-lang - true - commons-dbcp commons-dbcp diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapExecutionContextDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapExecutionContextDao.java index 54248be6e..80a9c0961 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapExecutionContextDao.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapExecutionContextDao.java @@ -18,10 +18,10 @@ package org.springframework.batch.core.repository.dao; import java.util.Map; -import org.apache.commons.lang.SerializationUtils; import org.springframework.batch.core.JobExecution; import org.springframework.batch.core.StepExecution; import org.springframework.batch.item.ExecutionContext; +import org.springframework.batch.support.SerializationUtils; import org.springframework.batch.support.transaction.TransactionAwareProxyFactory; /** diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapJobExecutionDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapJobExecutionDao.java index 531041532..fcbf67c7f 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapJobExecutionDao.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapJobExecutionDao.java @@ -24,9 +24,9 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.apache.commons.lang.SerializationUtils; import org.springframework.batch.core.JobExecution; import org.springframework.batch.core.JobInstance; +import org.springframework.batch.support.SerializationUtils; import org.springframework.batch.support.transaction.TransactionAwareProxyFactory; import org.springframework.dao.OptimisticLockingFailureException; import org.springframework.util.Assert; diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapStepExecutionDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapStepExecutionDao.java index b6ee7084c..4beab61a1 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapStepExecutionDao.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapStepExecutionDao.java @@ -21,10 +21,10 @@ import java.util.Comparator; import java.util.List; import java.util.Map; -import org.apache.commons.lang.SerializationUtils; import org.springframework.batch.core.Entity; import org.springframework.batch.core.JobExecution; import org.springframework.batch.core.StepExecution; +import org.springframework.batch.support.SerializationUtils; import org.springframework.batch.support.transaction.TransactionAwareProxyFactory; import org.springframework.dao.OptimisticLockingFailureException; import org.springframework.util.Assert; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/ExitStatusTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/ExitStatusTests.java index 615900d9e..fd82afddc 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/ExitStatusTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/ExitStatusTests.java @@ -19,8 +19,8 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import org.apache.commons.lang.SerializationUtils; import org.junit.Test; +import org.springframework.batch.support.SerializationUtils; /** * @author Dave Syer diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/JobExecutionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/JobExecutionTests.java index 26b6b2342..62fa51346 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/JobExecutionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/JobExecutionTests.java @@ -25,8 +25,8 @@ import java.util.Arrays; import java.util.Date; import java.util.List; -import org.apache.commons.lang.SerializationUtils; import org.junit.Test; +import org.springframework.batch.support.SerializationUtils; /** * @author Dave Syer diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/JobInstanceTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/JobInstanceTests.java index 9f2215c66..a1c9d504a 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/JobInstanceTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/JobInstanceTests.java @@ -15,10 +15,10 @@ */ package org.springframework.batch.core; -import org.apache.commons.lang.SerializationUtils; - import junit.framework.TestCase; +import org.springframework.batch.support.SerializationUtils; + /** * @author dsyer * diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/JobParametersTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/JobParametersTests.java index 0ab95a8d4..11323a5c8 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/JobParametersTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/JobParametersTests.java @@ -10,7 +10,7 @@ import java.util.Map.Entry; import junit.framework.TestCase; -import org.apache.commons.lang.SerializationUtils; +import org.springframework.batch.support.SerializationUtils; /** * @author Lucas Ward diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/StepExecutionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/StepExecutionTests.java index 8f5ee9ec5..0636b119c 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/StepExecutionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/StepExecutionTests.java @@ -26,11 +26,11 @@ import java.util.Date; import java.util.HashSet; import java.util.Set; -import org.apache.commons.lang.SerializationUtils; import org.junit.Before; import org.junit.Test; import org.springframework.batch.core.step.StepSupport; import org.springframework.batch.item.ExecutionContext; +import org.springframework.batch.support.SerializationUtils; /** * @author Dave Syer diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/resource/Foo.java b/spring-batch-core/src/test/java/org/springframework/batch/core/resource/Foo.java index 2b07f9c5f..072530a86 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/resource/Foo.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/resource/Foo.java @@ -1,7 +1,5 @@ package org.springframework.batch.core.resource; -import org.apache.commons.lang.builder.EqualsBuilder; -import org.apache.commons.lang.builder.HashCodeBuilder; /** * Simple domain object for testing purposes. @@ -42,13 +40,37 @@ public class Foo { public String toString() { return "Foo[id=" +id +",name=" + name + ",value=" + value + "]"; } - - public boolean equals(Object obj) { - return EqualsBuilder.reflectionEquals(this, obj); - } - + + @Override public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + final int prime = 31; + int result = 1; + result = prime * result + id; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + value; + return result; } + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Foo other = (Foo) obj; + if (id != other.id) + return false; + if (name == null) { + if (other.name != null) + return false; + } + else if (!name.equals(other.name)) + return false; + if (value != other.value) + return false; + return true; + } + } diff --git a/spring-batch-infrastructure-tests/pom.xml b/spring-batch-infrastructure-tests/pom.xml index 97ffae0ff..d78211da6 100644 --- a/spring-batch-infrastructure-tests/pom.xml +++ b/spring-batch-infrastructure-tests/pom.xml @@ -60,11 +60,6 @@ commons-io test - - commons-lang - commons-lang - test - org.apache.derby derby diff --git a/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/io/oxm/domain/Trade.java b/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/io/oxm/domain/Trade.java index 2c1294699..6fc755b58 100644 --- a/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/io/oxm/domain/Trade.java +++ b/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/io/oxm/domain/Trade.java @@ -2,30 +2,29 @@ package org.springframework.batch.io.oxm.domain; import java.math.BigDecimal; -import org.apache.commons.lang.builder.EqualsBuilder; -import org.apache.commons.lang.builder.HashCodeBuilder; - - /** * @author Rob Harrop */ public class Trade { - private String isin = ""; - private long quantity = 0; - private BigDecimal price = new BigDecimal(0); - private String customer = ""; + private String isin = ""; - public Trade() { - } - - public Trade(String isin, long quantity, BigDecimal price, String customer){ - this.isin = isin; - this.quantity = quantity; - this.price = price; - this.customer = customer; - } + private long quantity = 0; - public void setCustomer(String customer) { + private BigDecimal price = new BigDecimal(0); + + private String customer = ""; + + public Trade() { + } + + public Trade(String isin, long quantity, BigDecimal price, String customer) { + this.isin = isin; + this.quantity = quantity; + this.price = price; + this.customer = customer; + } + + public void setCustomer(String customer) { this.customer = customer; } @@ -42,31 +41,67 @@ public class Trade { } public String getIsin() { - return isin; - } - - public BigDecimal getPrice() { - return price; - } - - public long getQuantity() { - return quantity; - } - - public String getCustomer() { - return customer; - } - - public String toString() { - return "Trade: [isin=" + this.isin + ",quantity=" + this.quantity + ",price=" - + this.price + ",customer=" + this.customer + "]"; - } - - public boolean equals(Object o) { - return EqualsBuilder.reflectionEquals(this, o); + return isin; } + public BigDecimal getPrice() { + return price; + } + + public long getQuantity() { + return quantity; + } + + public String getCustomer() { + return customer; + } + + public String toString() { + return "Trade: [isin=" + this.isin + ",quantity=" + this.quantity + ",price=" + this.price + ",customer=" + + this.customer + "]"; + } + + @Override public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + final int prime = 31; + int result = 1; + result = prime * result + ((customer == null) ? 0 : customer.hashCode()); + result = prime * result + ((isin == null) ? 0 : isin.hashCode()); + result = prime * result + ((price == null) ? 0 : price.hashCode()); + result = prime * result + (int) (quantity ^ (quantity >>> 32)); + return result; } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Trade other = (Trade) obj; + if (customer == null) { + if (other.customer != null) + return false; + } + else if (!customer.equals(other.customer)) + return false; + if (isin == null) { + if (other.isin != null) + return false; + } + else if (!isin.equals(other.isin)) + return false; + if (price == null) { + if (other.price != null) + return false; + } + else if (!price.equals(other.price)) + return false; + if (quantity != other.quantity) + return false; + return true; + } + } diff --git a/spring-batch-infrastructure/pom.xml b/spring-batch-infrastructure/pom.xml index 64a06307e..ee304fb8d 100644 --- a/spring-batch-infrastructure/pom.xml +++ b/spring-batch-infrastructure/pom.xml @@ -78,11 +78,6 @@ log4j test - - commons-lang - commons-lang - true - commons-io commons-io diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/StaxEventItemWriter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/StaxEventItemWriter.java index 45ca9858c..37499a37d 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/StaxEventItemWriter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/StaxEventItemWriter.java @@ -32,7 +32,6 @@ import javax.xml.stream.XMLEventWriter; import javax.xml.stream.XMLOutputFactory; import javax.xml.stream.XMLStreamException; -import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.batch.item.ExecutionContext; @@ -52,6 +51,7 @@ import org.springframework.oxm.XmlMappingException; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; import org.springframework.util.CollectionUtils; +import org.springframework.util.StringUtils; import org.springframework.xml.transform.StaxResult; /** @@ -431,7 +431,7 @@ public class StaxEventItemWriter extends ExecutionContextUserSupport implemen // write root tag writer.add(factory.createStartElement(getRootTagNamespacePrefix(), getRootTagNamespace(), getRootTagName())); - if (!StringUtils.isBlank(getRootTagNamespace())) { + if (StringUtils.hasText(getRootTagNamespace())) { writer.add(factory.createNamespace(getRootTagNamespacePrefix(), getRootTagNamespace())); } @@ -458,8 +458,8 @@ public class StaxEventItemWriter extends ExecutionContextUserSupport implemen // writer.writeEndDocument(); <- this doesn't work after restart // we need to write end tag of the root element manually - - String nsPrefix = StringUtils.isBlank(getRootTagNamespacePrefix()) ? "" : getRootTagNamespacePrefix() + ":"; + + String nsPrefix = !StringUtils.hasText(getRootTagNamespacePrefix()) ? "" : getRootTagNamespacePrefix() + ":"; try { bufferedWriter.write(""); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/SerializationUtils.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/SerializationUtils.java new file mode 100644 index 000000000..756f03a5c --- /dev/null +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/SerializationUtils.java @@ -0,0 +1,78 @@ +/* + * Copyright 2006-2010 the original author or authors. + * + * 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 org.springframework.batch.support; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; + + +/** + * Static utility to help with serialization. + * + * @author Dave Syer + * + */ +public class SerializationUtils { + + /** + * Serialize the object provided. + * + * @param object the object to serialize + * @return an array of bytes representing the object in a portable fashion + */ + public static byte[] serialize(Object object) { + + if (object==null) { + return null; + } + + ByteArrayOutputStream stream = new ByteArrayOutputStream(); + try { + new ObjectOutputStream(stream).writeObject(object); + } catch (IOException e) { + throw new IllegalStateException("Could not serialize object of type: "+object.getClass(), e); + } + + return stream.toByteArray(); + + } + + /** + * @param bytes a serialized object created + * @return the result of deserializing the bytes + */ + public static Object deserialize(byte[] bytes) { + + if (bytes==null) { + return null; + } + + try { + return new ObjectInputStream(new ByteArrayInputStream(bytes)).readObject(); + } + catch (IOException e) { + throw new IllegalStateException("Could not deserialize object", e); + } + catch (ClassNotFoundException e) { + throw new IllegalStateException("Could not deserialize object type", e); + } + + } + +} diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/ExecutionContextTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/ExecutionContextTests.java index 6b71beed2..719596c5c 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/ExecutionContextTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/ExecutionContextTests.java @@ -15,15 +15,17 @@ */ package org.springframework.batch.item; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.io.Serializable; -import static org.junit.Assert.*; - -import org.apache.commons.lang.SerializationUtils; -import org.apache.commons.lang.builder.EqualsBuilder; -import org.apache.commons.lang.builder.HashCodeBuilder; import org.junit.Before; import org.junit.Test; +import org.springframework.batch.support.SerializationUtils; /** * @author Lucas Ward @@ -172,12 +174,26 @@ public class ExecutionContextTests { int value; - public boolean equals(Object obj) { - return EqualsBuilder.reflectionEquals(this, obj); + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + value; + return result; } - public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + TestSerializable other = (TestSerializable) obj; + if (value != other.value) + return false; + return true; } } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/transform/Name.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/transform/Name.java index b440f893d..4a37322d3 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/transform/Name.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/transform/Name.java @@ -1,6 +1,5 @@ package org.springframework.batch.item.file.transform; -import org.apache.commons.lang.builder.EqualsBuilder; public class Name { private String first; @@ -41,7 +40,41 @@ public class Name { this.born = born; } - public boolean equals(Object o) { - return EqualsBuilder.reflectionEquals(this, o); + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + born; + result = prime * result + ((first == null) ? 0 : first.hashCode()); + result = prime * result + ((last == null) ? 0 : last.hashCode()); + return result; } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Name other = (Name) obj; + if (born != other.born) + return false; + if (first == null) { + if (other.first != null) + return false; + } + else if (!first.equals(other.first)) + return false; + if (last == null) { + if (other.last != null) + return false; + } + else if (!last.equals(other.last)) + return false; + return true; + } + + } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/sample/Customer.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/sample/Customer.java index 71276499d..bb0cc5945 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/sample/Customer.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/sample/Customer.java @@ -16,9 +16,6 @@ package org.springframework.batch.item.sample; -import org.apache.commons.lang.builder.EqualsBuilder; -import org.apache.commons.lang.builder.HashCodeBuilder; -import org.apache.commons.lang.builder.ToStringBuilder; /** * An XML customer. @@ -76,15 +73,51 @@ public class Customer { this.poo = poo; } - public boolean equals(Object obj) { - return EqualsBuilder.reflectionEquals(obj, this); - } - + @Override public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + final int prime = 31; + int result = 1; + result = prime * result + ((address == null) ? 0 : address.hashCode()); + result = prime * result + age; + result = prime * result + moo; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + poo; + return result; } - public String toString() { - return ToStringBuilder.reflectionToString(this); + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Customer other = (Customer) obj; + if (address == null) { + if (other.address != null) + return false; + } + else if (!address.equals(other.address)) + return false; + if (age != other.age) + return false; + if (moo != other.moo) + return false; + if (name == null) { + if (other.name != null) + return false; + } + else if (!name.equals(other.name)) + return false; + if (poo != other.poo) + return false; + return true; } + + @Override + public String toString() { + return "Customer [address=" + address + ", age=" + age + ", name=" + name + "]"; + } + } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/sample/Foo.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/sample/Foo.java index 96dd9ae1f..9688f920a 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/sample/Foo.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/sample/Foo.java @@ -1,11 +1,8 @@ package org.springframework.batch.item.sample; -import org.apache.commons.lang.builder.EqualsBuilder; -import org.apache.commons.lang.builder.HashCodeBuilder; - import javax.persistence.Entity; -import javax.persistence.Table; import javax.persistence.Id; +import javax.persistence.Table; /** * Simple domain object for testing purposes. @@ -54,14 +51,38 @@ public class Foo { return "Foo[id=" +id +",name=" + name + ",value=" + value + "]"; } - public boolean equals(Object obj) { - return EqualsBuilder.reflectionEquals(this, obj); - } - + @Override public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + final int prime = 31; + int result = 1; + result = prime * result + id; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + value; + return result; } - + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Foo other = (Foo) obj; + if (id != other.id) + return false; + if (name == null) { + if (other.name != null) + return false; + } + else if (!name.equals(other.name)) + return false; + if (value != other.value) + return false; + return true; + } + public void fail() throws Exception { throw new Exception(FAILURE_MESSAGE); } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/sample/LineItem.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/sample/LineItem.java index 6f7cb1f85..3c9d9d1dc 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/sample/LineItem.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/sample/LineItem.java @@ -16,9 +16,6 @@ package org.springframework.batch.item.sample; -import org.apache.commons.lang.builder.EqualsBuilder; -import org.apache.commons.lang.builder.HashCodeBuilder; -import org.apache.commons.lang.builder.ToStringBuilder; /** * An XML line-item. @@ -66,15 +63,48 @@ public class LineItem { this.quantity = quantity; } - public boolean equals(Object obj) { - return EqualsBuilder.reflectionEquals(obj, this); - } - + @Override public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + final int prime = 31; + int result = 1; + result = prime * result + ((description == null) ? 0 : description.hashCode()); + long temp; + temp = Double.doubleToLongBits(perUnitOunces); + result = prime * result + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(price); + result = prime * result + (int) (temp ^ (temp >>> 32)); + result = prime * result + quantity; + return result; } - + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + LineItem other = (LineItem) obj; + if (description == null) { + if (other.description != null) + return false; + } + else if (!description.equals(other.description)) + return false; + if (Double.doubleToLongBits(perUnitOunces) != Double.doubleToLongBits(other.perUnitOunces)) + return false; + if (Double.doubleToLongBits(price) != Double.doubleToLongBits(other.price)) + return false; + if (quantity != other.quantity) + return false; + return true; + } + + @Override public String toString() { - return ToStringBuilder.reflectionToString(this); + return "LineItem [description=" + description + ", perUnitOunces=" + perUnitOunces + ", price=" + price + + ", quantity=" + quantity + "]"; } + } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/sample/Order.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/sample/Order.java index ed847cbe3..7f0d4a067 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/sample/Order.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/sample/Order.java @@ -19,10 +19,6 @@ package org.springframework.batch.item.sample; import java.util.Date; import java.util.List; -import org.apache.commons.lang.builder.EqualsBuilder; -import org.apache.commons.lang.builder.HashCodeBuilder; -import org.apache.commons.lang.builder.ToStringBuilder; - /** * An XML order. * @@ -68,16 +64,58 @@ public class Order { public void setShipper(Shipper shipper) { this.shipper = shipper; } - - public boolean equals(Object obj) { - return EqualsBuilder.reflectionEquals(obj, this); - } - + + @Override public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + final int prime = 31; + int result = 1; + result = prime * result + ((customer == null) ? 0 : customer.hashCode()); + result = prime * result + ((date == null) ? 0 : date.hashCode()); + result = prime * result + ((lineItems == null) ? 0 : lineItems.hashCode()); + result = prime * result + ((shipper == null) ? 0 : shipper.hashCode()); + return result; } - + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Order other = (Order) obj; + if (customer == null) { + if (other.customer != null) + return false; + } + else if (!customer.equals(other.customer)) + return false; + if (date == null) { + if (other.date != null) + return false; + } + else if (!date.equals(other.date)) + return false; + if (lineItems == null) { + if (other.lineItems != null) + return false; + } + else if (!lineItems.equals(other.lineItems)) + return false; + if (shipper == null) { + if (other.shipper != null) + return false; + } + else if (!shipper.equals(other.shipper)) + return false; + return true; + } + + @Override public String toString() { - return ToStringBuilder.reflectionToString(this); + return "Order [customer=" + customer + ", date=" + date + ", lineItems=" + lineItems + ", shipper=" + shipper + + "]"; } + } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/sample/Shipper.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/sample/Shipper.java index be79908a6..3d2fd8866 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/sample/Shipper.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/sample/Shipper.java @@ -16,9 +16,6 @@ package org.springframework.batch.item.sample; -import org.apache.commons.lang.builder.EqualsBuilder; -import org.apache.commons.lang.builder.HashCodeBuilder; -import org.apache.commons.lang.builder.ToStringBuilder; /** * An XML shipper. @@ -46,15 +43,40 @@ public class Shipper { this.perOunceRate = perOunceRate; } - public boolean equals(Object obj) { - return EqualsBuilder.reflectionEquals(obj, this); - } - + @Override public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + long temp; + temp = Double.doubleToLongBits(perOunceRate); + result = prime * result + (int) (temp ^ (temp >>> 32)); + return result; } - + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Shipper other = (Shipper) obj; + if (name == null) { + if (other.name != null) + return false; + } + else if (!name.equals(other.name)) + return false; + if (Double.doubleToLongBits(perOunceRate) != Double.doubleToLongBits(other.perOunceRate)) + return false; + return true; + } + + @Override public String toString() { - return ToStringBuilder.reflectionToString(this); + return "Shipper [name=" + name + ", perOunceRate=" + perOunceRate + "]"; } + } diff --git a/spring-batch-parent/pom.xml b/spring-batch-parent/pom.xml index a50729902..bb313483c 100644 --- a/spring-batch-parent/pom.xml +++ b/spring-batch-parent/pom.xml @@ -363,7 +363,7 @@ commons-lang commons-lang - 2.1 + PLEASE DON'T USE COMMONS LANG true diff --git a/spring-batch-samples/pom.xml b/spring-batch-samples/pom.xml index 9ae292320..c8a857d18 100644 --- a/spring-batch-samples/pom.xml +++ b/spring-batch-samples/pom.xml @@ -111,10 +111,6 @@ commons-dbcp commons-dbcp - - commons-lang - commons-lang - com.thoughtworks.xstream xstream diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/StagingItemReader.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/StagingItemReader.java index 56bb2981f..de46ddc30 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/StagingItemReader.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/StagingItemReader.java @@ -23,7 +23,6 @@ import java.util.List; import javax.sql.DataSource; -import org.apache.commons.lang.SerializationUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.batch.core.ExitStatus; @@ -31,6 +30,7 @@ import org.springframework.batch.core.StepExecution; import org.springframework.batch.core.StepExecutionListener; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ReaderNotOpenException; +import org.springframework.batch.support.SerializationUtils; import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.InitializingBean; import org.springframework.dao.DataAccessException; diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/StagingItemWriter.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/StagingItemWriter.java index cb61337c8..c2b02fe44 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/StagingItemWriter.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/StagingItemWriter.java @@ -22,11 +22,11 @@ import java.sql.SQLException; import java.util.List; import java.util.ListIterator; -import org.apache.commons.lang.SerializationUtils; import org.springframework.batch.core.ExitStatus; import org.springframework.batch.core.StepExecution; import org.springframework.batch.core.StepExecutionListener; import org.springframework.batch.item.ItemWriter; +import org.springframework.batch.support.SerializationUtils; import org.springframework.jdbc.core.BatchPreparedStatementSetter; import org.springframework.jdbc.core.support.JdbcDaoSupport; import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer; diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/football/Game.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/football/Game.java index 56bb51c15..531a0c537 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/football/Game.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/football/Game.java @@ -18,9 +18,6 @@ package org.springframework.batch.sample.domain.football; import java.io.Serializable; -import org.apache.commons.lang.builder.EqualsBuilder; -import org.apache.commons.lang.builder.HashCodeBuilder; - public class Game implements Serializable { private String id; @@ -225,13 +222,30 @@ public class Game implements Serializable { return "Game: ID=" + id + " " + team + " vs. " + opponent + " - " + year; } - - public boolean equals(Object obj) { - return EqualsBuilder.reflectionEquals(this, obj); - } + + @Override public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + final int prime = 31; + int result = 1; + result = prime * result + ((id == null) ? 0 : id.hashCode()); + return result; } - - + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Game other = (Game) obj; + if (id == null) { + if (other.id != null) + return false; + } + else if (!id.equals(other.id)) + return false; + return true; + } + } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/football/PlayerSummary.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/football/PlayerSummary.java index 8b6aeced5..a8ef969a8 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/football/PlayerSummary.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/football/PlayerSummary.java @@ -16,8 +16,6 @@ package org.springframework.batch.sample.domain.football; -import org.apache.commons.lang.builder.EqualsBuilder; -import org.apache.commons.lang.builder.HashCodeBuilder; /** * Domain object representing the summary of a given Player's @@ -120,12 +118,29 @@ public class PlayerSummary { ";" + passingTd + ";" + interceptions + ";" + rushes + ";" + rushYards + ";" + receptions + ";" + receptionYards + ";" + totalTd; } - - public boolean equals(Object obj) { - return EqualsBuilder.reflectionEquals(this, obj); - } + @Override public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + final int prime = 31; + int result = 1; + result = prime * result + ((id == null) ? 0 : id.hashCode()); + return result; } - + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + PlayerSummary other = (PlayerSummary) obj; + if (id == null) { + if (other.id != null) + return false; + } + else if (!id.equals(other.id)) + return false; + return true; + } + } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/Address.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/Address.java index b81ea720c..1d58a2c63 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/Address.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/Address.java @@ -16,88 +16,125 @@ package org.springframework.batch.sample.domain.order; -import org.apache.commons.lang.builder.EqualsBuilder; -import org.apache.commons.lang.builder.HashCodeBuilder; -import org.apache.commons.lang.builder.ToStringBuilder; - public class Address { - public static final String LINE_ID_BILLING_ADDR = "BAD"; - public static final String LINE_ID_SHIPPING_ADDR = "SAD"; - private String addressee; - private String addrLine1; - private String addrLine2; - private String city; - private String zipCode; - private String state; - private String country; + public static final String LINE_ID_BILLING_ADDR = "BAD"; - public String getAddrLine1() { - return addrLine1; - } + public static final String LINE_ID_SHIPPING_ADDR = "SAD"; - public void setAddrLine1(String addrLine1) { - this.addrLine1 = addrLine1; - } + private String addressee; - public String getAddrLine2() { - return addrLine2; - } + private String addrLine1; - public void setAddrLine2(String addrLine2) { - this.addrLine2 = addrLine2; - } + private String addrLine2; - public String getAddressee() { - return addressee; - } + private String city; - public void setAddressee(String addressee) { - this.addressee = addressee; - } + private String zipCode; - public String getCity() { - return city; - } + private String state; - public void setCity(String city) { - this.city = city; - } + private String country; - public String getCountry() { - return country; - } - - public void setCountry(String country) { - this.country = country; - } - - public String getState() { - return state; - } - - public void setState(String state) { - this.state = state; - } - - public String getZipCode() { - return zipCode; - } - - public void setZipCode(String zipCode) { - this.zipCode = zipCode; - } - - public String toString() { - return ToStringBuilder.reflectionToString(this); - } - - public boolean equals(Object o) { - return EqualsBuilder.reflectionEquals(this, o); + public String getAddrLine1() { + return addrLine1; } + public void setAddrLine1(String addrLine1) { + this.addrLine1 = addrLine1; + } + + public String getAddrLine2() { + return addrLine2; + } + + public void setAddrLine2(String addrLine2) { + this.addrLine2 = addrLine2; + } + + public String getAddressee() { + return addressee; + } + + public void setAddressee(String addressee) { + this.addressee = addressee; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getCountry() { + return country; + } + + public void setCountry(String country) { + this.country = country; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public String getZipCode() { + return zipCode; + } + + public void setZipCode(String zipCode) { + this.zipCode = zipCode; + } + + @Override + public String toString() { + return "Address [addressee=" + addressee + ", city=" + city + ", country=" + country + ", state=" + state + + ", zipCode=" + zipCode + "]"; + } + + @Override public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + final int prime = 31; + int result = 1; + result = prime * result + ((addressee == null) ? 0 : addressee.hashCode()); + result = prime * result + ((country == null) ? 0 : country.hashCode()); + result = prime * result + ((zipCode == null) ? 0 : zipCode.hashCode()); + return result; } - - + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Address other = (Address) obj; + if (addressee == null) { + if (other.addressee != null) + return false; + } + else if (!addressee.equals(other.addressee)) + return false; + if (country == null) { + if (other.country != null) + return false; + } + else if (!country.equals(other.country)) + return false; + if (zipCode == null) { + if (other.zipCode != null) + return false; + } + else if (!zipCode.equals(other.zipCode)) + return false; + return true; + } + } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/BillingInfo.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/BillingInfo.java index cbec4f447..e54f309ee 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/BillingInfo.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/BillingInfo.java @@ -16,42 +16,66 @@ package org.springframework.batch.sample.domain.order; -import org.apache.commons.lang.builder.EqualsBuilder; -import org.apache.commons.lang.builder.HashCodeBuilder; -import org.apache.commons.lang.builder.ToStringBuilder; public class BillingInfo { - public static final String LINE_ID_BILLING_INFO = "BIN"; - private String paymentId; - private String paymentDesc; + public static final String LINE_ID_BILLING_INFO = "BIN"; - public String getPaymentDesc() { - return paymentDesc; - } + private String paymentId; - public void setPaymentDesc(String paymentDesc) { - this.paymentDesc = paymentDesc; - } + private String paymentDesc; - public String getPaymentId() { - return paymentId; - } - - public void setPaymentId(String paymentId) { - this.paymentId = paymentId; - } - - public String toString() { - return ToStringBuilder.reflectionToString(this); - } - - public boolean equals(Object o) { - return EqualsBuilder.reflectionEquals(this, o); + public String getPaymentDesc() { + return paymentDesc; } + public void setPaymentDesc(String paymentDesc) { + this.paymentDesc = paymentDesc; + } + + public String getPaymentId() { + return paymentId; + } + + public void setPaymentId(String paymentId) { + this.paymentId = paymentId; + } + + @Override + public String toString() { + return "BillingInfo [paymentDesc=" + paymentDesc + ", paymentId=" + paymentId + "]"; + } + + @Override public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + final int prime = 31; + int result = 1; + result = prime * result + ((paymentDesc == null) ? 0 : paymentDesc.hashCode()); + result = prime * result + ((paymentId == null) ? 0 : paymentId.hashCode()); + return result; } - - + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + BillingInfo other = (BillingInfo) obj; + if (paymentDesc == null) { + if (other.paymentDesc != null) + return false; + } + else if (!paymentDesc.equals(other.paymentDesc)) + return false; + if (paymentId == null) { + if (other.paymentId != null) + return false; + } + else if (!paymentId.equals(other.paymentId)) + return false; + return true; + } + } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/Customer.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/Customer.java index 91b3dc9d8..f5528fc7f 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/Customer.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/Customer.java @@ -16,100 +16,156 @@ package org.springframework.batch.sample.domain.order; -import org.apache.commons.lang.builder.EqualsBuilder; -import org.apache.commons.lang.builder.HashCodeBuilder; -import org.apache.commons.lang.builder.ToStringBuilder; public class Customer { - public static final String LINE_ID_BUSINESS_CUST = "BCU"; - public static final String LINE_ID_NON_BUSINESS_CUST = "NCU"; - private boolean businessCustomer; - private boolean registered; - private long registrationId; + public static final String LINE_ID_BUSINESS_CUST = "BCU"; - //non-business customer - private String firstName; - private String lastName; - private String middleName; - private boolean vip; + public static final String LINE_ID_NON_BUSINESS_CUST = "NCU"; - //business customer - private String companyName; + private boolean businessCustomer; - public boolean isBusinessCustomer() { - return businessCustomer; - } + private boolean registered; - public void setBusinessCustomer(boolean bussinessCustomer) { - this.businessCustomer = bussinessCustomer; - } + private long registrationId; - public String getCompanyName() { - return companyName; - } + // non-business customer + private String firstName; - public void setCompanyName(String companyName) { - this.companyName = companyName; - } + private String lastName; - public String getFirstName() { - return firstName; - } + private String middleName; - public void setFirstName(String firstName) { - this.firstName = firstName; - } + private boolean vip; - public boolean isRegistered() { - return registered; - } + // business customer + private String companyName; - public void setRegistered(boolean registered) { - this.registered = registered; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - public String getMiddleName() { - return middleName; - } - - public void setMiddleName(String middleName) { - this.middleName = middleName; - } - - public long getRegistrationId() { - return registrationId; - } - - public void setRegistrationId(long registrationId) { - this.registrationId = registrationId; - } - - public boolean isVip() { - return vip; - } - - public void setVip(boolean vip) { - this.vip = vip; - } - - public String toString() { - return ToStringBuilder.reflectionToString(this); - } - - public boolean equals(Object o) { - return EqualsBuilder.reflectionEquals(this, o); + public boolean isBusinessCustomer() { + return businessCustomer; } + public void setBusinessCustomer(boolean bussinessCustomer) { + this.businessCustomer = bussinessCustomer; + } + + public String getCompanyName() { + return companyName; + } + + public void setCompanyName(String companyName) { + this.companyName = companyName; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public boolean isRegistered() { + return registered; + } + + public void setRegistered(boolean registered) { + this.registered = registered; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getMiddleName() { + return middleName; + } + + public void setMiddleName(String middleName) { + this.middleName = middleName; + } + + public long getRegistrationId() { + return registrationId; + } + + public void setRegistrationId(long registrationId) { + this.registrationId = registrationId; + } + + public boolean isVip() { + return vip; + } + + public void setVip(boolean vip) { + this.vip = vip; + } + + @Override + public String toString() { + return "Customer [companyName=" + companyName + ", firstName=" + firstName + ", lastName=" + lastName + "]"; + } + + @Override public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + final int prime = 31; + int result = 1; + result = prime * result + (businessCustomer ? 1231 : 1237); + result = prime * result + ((companyName == null) ? 0 : companyName.hashCode()); + result = prime * result + ((firstName == null) ? 0 : firstName.hashCode()); + result = prime * result + ((lastName == null) ? 0 : lastName.hashCode()); + result = prime * result + ((middleName == null) ? 0 : middleName.hashCode()); + result = prime * result + (registered ? 1231 : 1237); + result = prime * result + (int) (registrationId ^ (registrationId >>> 32)); + result = prime * result + (vip ? 1231 : 1237); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Customer other = (Customer) obj; + if (businessCustomer != other.businessCustomer) + return false; + if (companyName == null) { + if (other.companyName != null) + return false; + } + else if (!companyName.equals(other.companyName)) + return false; + if (firstName == null) { + if (other.firstName != null) + return false; + } + else if (!firstName.equals(other.firstName)) + return false; + if (lastName == null) { + if (other.lastName != null) + return false; + } + else if (!lastName.equals(other.lastName)) + return false; + if (middleName == null) { + if (other.middleName != null) + return false; + } + else if (!middleName.equals(other.middleName)) + return false; + if (registered != other.registered) + return false; + if (registrationId != other.registrationId) + return false; + if (vip != other.vip) + return false; + return true; } } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/LineItem.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/LineItem.java index 17247e994..3ec0798a6 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/LineItem.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/LineItem.java @@ -18,10 +18,6 @@ package org.springframework.batch.sample.domain.order; import java.math.BigDecimal; -import org.apache.commons.lang.builder.EqualsBuilder; -import org.apache.commons.lang.builder.HashCodeBuilder; -import org.apache.commons.lang.builder.ToStringBuilder; - public class LineItem { public static final String LINE_ID_ITEM = "LIT"; @@ -97,17 +93,35 @@ public class LineItem { public void setTotalPrice(BigDecimal totalPrice) { this.totalPrice = totalPrice; } - - public String toString() { - return ToStringBuilder.reflectionToString(this); - } - - public boolean equals(Object o) { - return EqualsBuilder.reflectionEquals(this, o); + + @Override + public String toString() { + return "LineItem [price=" + price + ", quantity=" + quantity + ", totalPrice=" + totalPrice + "]"; } + @Override public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + final int prime = 31; + int result = 1; + result = prime * result + (int) (itemId ^ (itemId >>> 32)); + result = prime * result + quantity; + return result; } - + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + LineItem other = (LineItem) obj; + if (itemId != other.itemId) + return false; + if (quantity != other.quantity) + return false; + return true; + } + } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/Order.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/Order.java index f8f58378c..4a1896deb 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/Order.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/Order.java @@ -20,129 +20,212 @@ import java.math.BigDecimal; import java.util.Date; import java.util.List; -import org.apache.commons.lang.builder.EqualsBuilder; -import org.apache.commons.lang.builder.HashCodeBuilder; -import org.apache.commons.lang.builder.ToStringBuilder; - - public class Order { - public static final String LINE_ID_HEADER = "HEA"; - public static final String LINE_ID_FOOTER = "FOT"; + public static final String LINE_ID_HEADER = "HEA"; - //header - private long orderId; - private Date orderDate; + public static final String LINE_ID_FOOTER = "FOT"; - //footer - private int totalLines; - private int totalItems; - private BigDecimal totalPrice; - private Customer customer; - private Address billingAddress; - private Address shippingAddress; - private BillingInfo billing; - private ShippingInfo shipping; + // header + private long orderId; - //order items - private List lineItems; + private Date orderDate; - public BillingInfo getBilling() { - return billing; - } + // footer + private int totalLines; - public void setBilling(BillingInfo billing) { - this.billing = billing; - } + private int totalItems; - public Address getBillingAddress() { - return billingAddress; - } + private BigDecimal totalPrice; - public void setBillingAddress(Address billingAddress) { - this.billingAddress = billingAddress; - } + private Customer customer; - public Customer getCustomer() { - return customer; - } + private Address billingAddress; - public void setCustomer(Customer customer) { - this.customer = customer; - } + private Address shippingAddress; - public List getLineItems() { - return lineItems; - } + private BillingInfo billing; - public void setLineItems(List lineItems) { - this.lineItems = lineItems; - } + private ShippingInfo shipping; - public Date getOrderDate() { - return orderDate; - } + // order items + private List lineItems; - public void setOrderDate(Date orderDate) { - this.orderDate = orderDate; - } - - public long getOrderId() { - return orderId; - } - - public void setOrderId(long orderId) { - this.orderId = orderId; - } - - public ShippingInfo getShipping() { - return shipping; - } - - public void setShipping(ShippingInfo shipping) { - this.shipping = shipping; - } - - public Address getShippingAddress() { - return shippingAddress; - } - - public void setShippingAddress(Address shippingAddress) { - this.shippingAddress = shippingAddress; - } - - public BigDecimal getTotalPrice() { - return totalPrice; - } - - public void setTotalPrice(BigDecimal totalPrice) { - this.totalPrice = totalPrice; - } - - public int getTotalItems() { - return totalItems; - } - - public void setTotalItems(int totalItems) { - this.totalItems = totalItems; - } - - public int getTotalLines() { - return totalLines; - } - - public void setTotalLines(int totalLines) { - this.totalLines = totalLines; - } - - public String toString() { - return ToStringBuilder.reflectionToString(this); - } - - public boolean equals(Object o) { - return EqualsBuilder.reflectionEquals(this, o); + public BillingInfo getBilling() { + return billing; } + public void setBilling(BillingInfo billing) { + this.billing = billing; + } + + public Address getBillingAddress() { + return billingAddress; + } + + public void setBillingAddress(Address billingAddress) { + this.billingAddress = billingAddress; + } + + public Customer getCustomer() { + return customer; + } + + public void setCustomer(Customer customer) { + this.customer = customer; + } + + public List getLineItems() { + return lineItems; + } + + public void setLineItems(List lineItems) { + this.lineItems = lineItems; + } + + public Date getOrderDate() { + return orderDate; + } + + public void setOrderDate(Date orderDate) { + this.orderDate = orderDate; + } + + public long getOrderId() { + return orderId; + } + + public void setOrderId(long orderId) { + this.orderId = orderId; + } + + public ShippingInfo getShipping() { + return shipping; + } + + public void setShipping(ShippingInfo shipping) { + this.shipping = shipping; + } + + public Address getShippingAddress() { + return shippingAddress; + } + + public void setShippingAddress(Address shippingAddress) { + this.shippingAddress = shippingAddress; + } + + public BigDecimal getTotalPrice() { + return totalPrice; + } + + public void setTotalPrice(BigDecimal totalPrice) { + this.totalPrice = totalPrice; + } + + public int getTotalItems() { + return totalItems; + } + + public void setTotalItems(int totalItems) { + this.totalItems = totalItems; + } + + public int getTotalLines() { + return totalLines; + } + + public void setTotalLines(int totalLines) { + this.totalLines = totalLines; + } + + @Override + public String toString() { + return "Order [customer=" + customer + ", orderId=" + orderId + ", totalItems=" + totalItems + ", totalPrice=" + + totalPrice + "]"; + } + + @Override public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + final int prime = 31; + int result = 1; + result = prime * result + ((billing == null) ? 0 : billing.hashCode()); + result = prime * result + ((billingAddress == null) ? 0 : billingAddress.hashCode()); + result = prime * result + ((customer == null) ? 0 : customer.hashCode()); + result = prime * result + ((lineItems == null) ? 0 : lineItems.hashCode()); + result = prime * result + ((orderDate == null) ? 0 : orderDate.hashCode()); + result = prime * result + (int) (orderId ^ (orderId >>> 32)); + result = prime * result + ((shipping == null) ? 0 : shipping.hashCode()); + result = prime * result + ((shippingAddress == null) ? 0 : shippingAddress.hashCode()); + result = prime * result + totalItems; + result = prime * result + totalLines; + result = prime * result + ((totalPrice == null) ? 0 : totalPrice.hashCode()); + return result; } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Order other = (Order) obj; + if (billing == null) { + if (other.billing != null) + return false; + } + else if (!billing.equals(other.billing)) + return false; + if (billingAddress == null) { + if (other.billingAddress != null) + return false; + } + else if (!billingAddress.equals(other.billingAddress)) + return false; + if (customer == null) { + if (other.customer != null) + return false; + } + else if (!customer.equals(other.customer)) + return false; + if (lineItems == null) { + if (other.lineItems != null) + return false; + } + else if (!lineItems.equals(other.lineItems)) + return false; + if (orderDate == null) { + if (other.orderDate != null) + return false; + } + else if (!orderDate.equals(other.orderDate)) + return false; + if (orderId != other.orderId) + return false; + if (shipping == null) { + if (other.shipping != null) + return false; + } + else if (!shipping.equals(other.shipping)) + return false; + if (shippingAddress == null) { + if (other.shippingAddress != null) + return false; + } + else if (!shippingAddress.equals(other.shippingAddress)) + return false; + if (totalItems != other.totalItems) + return false; + if (totalLines != other.totalLines) + return false; + if (totalPrice == null) { + if (other.totalPrice != null) + return false; + } + else if (!totalPrice.equals(other.totalPrice)) + return false; + return true; + } + } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/ShippingInfo.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/ShippingInfo.java index e254c0d82..efdf8befb 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/ShippingInfo.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/ShippingInfo.java @@ -16,44 +16,78 @@ package org.springframework.batch.sample.domain.order; -import org.apache.commons.lang.builder.EqualsBuilder; -import org.apache.commons.lang.builder.HashCodeBuilder; public class ShippingInfo { - public static final String LINE_ID_SHIPPING_INFO = "SIN"; - private String shipperId; - private String shippingTypeId; - private String shippingInfo; + public static final String LINE_ID_SHIPPING_INFO = "SIN"; - public String getShipperId() { - return shipperId; - } + private String shipperId; - public void setShipperId(String shipperId) { - this.shipperId = shipperId; - } + private String shippingTypeId; - public String getShippingInfo() { - return shippingInfo; - } + private String shippingInfo; - public void setShippingInfo(String shippingInfo) { - this.shippingInfo = shippingInfo; - } - - public String getShippingTypeId() { - return shippingTypeId; - } - - public void setShippingTypeId(String shippingTypeId) { - this.shippingTypeId = shippingTypeId; - } - - public boolean equals(Object o) { - return EqualsBuilder.reflectionEquals(this, o); + public String getShipperId() { + return shipperId; } + public void setShipperId(String shipperId) { + this.shipperId = shipperId; + } + + public String getShippingInfo() { + return shippingInfo; + } + + public void setShippingInfo(String shippingInfo) { + this.shippingInfo = shippingInfo; + } + + public String getShippingTypeId() { + return shippingTypeId; + } + + public void setShippingTypeId(String shippingTypeId) { + this.shippingTypeId = shippingTypeId; + } + + @Override public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + final int prime = 31; + int result = 1; + result = prime * result + ((shipperId == null) ? 0 : shipperId.hashCode()); + result = prime * result + ((shippingInfo == null) ? 0 : shippingInfo.hashCode()); + result = prime * result + ((shippingTypeId == null) ? 0 : shippingTypeId.hashCode()); + return result; } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ShippingInfo other = (ShippingInfo) obj; + if (shipperId == null) { + if (other.shipperId != null) + return false; + } + else if (!shipperId.equals(other.shipperId)) + return false; + if (shippingInfo == null) { + if (other.shippingInfo != null) + return false; + } + else if (!shippingInfo.equals(other.shippingInfo)) + return false; + if (shippingTypeId == null) { + if (other.shippingTypeId != null) + return false; + } + else if (!shippingTypeId.equals(other.shippingTypeId)) + return false; + return true; + } + } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/xml/Customer.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/xml/Customer.java index 74e2f6554..39dcb6ab3 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/xml/Customer.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/xml/Customer.java @@ -16,62 +16,65 @@ package org.springframework.batch.sample.domain.order.internal.xml; -import org.apache.commons.lang.builder.ToStringBuilder; - - /** * An XML customer. - * + * * This is a complex type. */ public class Customer { - private String name; - private String address; - private int age; - private int moo; - private int poo; + private String name; - public String getAddress() { - return address; - } + private String address; - public void setAddress(String address) { - this.address = address; - } + private int age; - public int getAge() { - return age; - } + private int moo; - public void setAge(int age) { - this.age = age; - } + private int poo; - public String getName() { - return name; - } + public String getAddress() { + return address; + } - public void setName(String name) { - this.name = name; - } + public void setAddress(String address) { + this.address = address; + } - public int getMoo() { - return moo; - } + public int getAge() { + return age; + } - public void setMoo(int moo) { - this.moo = moo; - } + public void setAge(int age) { + this.age = age; + } - public int getPoo() { - return poo; - } + public String getName() { + return name; + } - public void setPoo(int poo) { - this.poo = poo; - } + public void setName(String name) { + this.name = name; + } + + public int getMoo() { + return moo; + } + + public void setMoo(int moo) { + this.moo = moo; + } + + public int getPoo() { + return poo; + } + + public void setPoo(int poo) { + this.poo = poo; + } + + @Override + public String toString() { + return "Customer [address=" + address + ", age=" + age + ", name=" + name + "]"; + } - public String toString() { - return ToStringBuilder.reflectionToString(this); - } } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/xml/Order.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/xml/Order.java index f18ba4cd9..238d0099f 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/xml/Order.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/xml/Order.java @@ -19,53 +19,55 @@ package org.springframework.batch.sample.domain.order.internal.xml; import java.util.Date; import java.util.List; -import org.apache.commons.lang.builder.ToStringBuilder; - - /** * An XML order. - * + * * This is a complex type. */ public class Order { - private Customer customer; - private Date date; - private List lineItems; - private Shipper shipper; + private Customer customer; - public Customer getCustomer() { - return customer; - } + private Date date; - public void setCustomer(Customer customer) { - this.customer = customer; - } + private List lineItems; - public Date getDate() { - return date; - } + private Shipper shipper; - public void setDate(Date date) { - this.date = date; - } + public Customer getCustomer() { + return customer; + } - public List getLineItems() { - return lineItems; - } + public void setCustomer(Customer customer) { + this.customer = customer; + } - public void setLineItems(List lineItems) { - this.lineItems = lineItems; - } + public Date getDate() { + return date; + } - public Shipper getShipper() { - return shipper; - } + public void setDate(Date date) { + this.date = date; + } - public void setShipper(Shipper shipper) { - this.shipper = shipper; - } + public List getLineItems() { + return lineItems; + } + + public void setLineItems(List lineItems) { + this.lineItems = lineItems; + } + + public Shipper getShipper() { + return shipper; + } + + public void setShipper(Shipper shipper) { + this.shipper = shipper; + } + + @Override + public String toString() { + return "Order [customer=" + customer + ", date=" + date + ", lineItems=" + lineItems + "]"; + } - public String toString() { - return ToStringBuilder.reflectionToString(this); - } } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/person/Child.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/person/Child.java index 232c3a96a..0571fdaae 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/person/Child.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/person/Child.java @@ -16,9 +16,6 @@ package org.springframework.batch.sample.domain.person; -import org.apache.commons.lang.builder.EqualsBuilder; -import org.apache.commons.lang.builder.HashCodeBuilder; -import org.apache.commons.lang.builder.ToStringBuilder; public class Child { @@ -31,17 +28,36 @@ public class Child { public String getName(){ return name; } - + + @Override public String toString() { - return ToStringBuilder.reflectionToString(this); - } - - public boolean equals(Object o) { - return EqualsBuilder.reflectionEquals(this, o); + return "Child [name=" + name + "]"; } + @Override public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; } - + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Child other = (Child) obj; + if (name == null) { + if (other.name != null) + return false; + } + else if (!name.equals(other.name)) + return false; + return true; + } + } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/person/Person.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/person/Person.java index ec2f38620..4ee7af83f 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/person/Person.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/person/Person.java @@ -19,73 +19,83 @@ package org.springframework.batch.sample.domain.person; import java.util.ArrayList; import java.util.List; -import org.apache.commons.lang.builder.EqualsBuilder; -import org.apache.commons.lang.builder.HashCodeBuilder; -import org.apache.commons.lang.builder.ToStringBuilder; import org.springframework.batch.sample.domain.order.Address; public class Person { private String title = ""; + private String firstName = ""; + private String last_name = ""; + private int age = 0; + private Address address = new Address(); + private List children = new ArrayList(); - - public Person(){ + + public Person() { children.add(new Child()); children.add(new Child()); } - + /** * @return the address */ public Address getAddress() { return address; } + /** * @param address the address to set */ public void setAddress(Address address) { this.address = address; } + /** * @return the age */ public int getAge() { return age; } + /** * @param age the age to set */ public void setAge(int age) { this.age = age; } + /** * @return the firstName */ public String getFirstName() { return firstName; } + /** * @param firstName the firstName to set */ public void setFirstName(String firstName) { this.firstName = firstName; } + /** * @return the children */ public List getChildren() { return children; } + /** * @param children the children to set */ public void setChildren(List children) { this.children = children; } + /** * Intentionally non-standard method name for testing purposes * @return the last_name @@ -93,6 +103,7 @@ public class Person { public String getLast_name() { return last_name; } + /** * Intentionally non-standard method name for testing purposes * @param last_name the last_name to set @@ -100,28 +111,82 @@ public class Person { public void setLast_name(String last_name) { this.last_name = last_name; } + /** * @return the person_title */ public String getTitle() { return title; } + /** * @param title the person title to set */ public void setTitle(String title) { this.title = title; } - + + @Override public String toString() { - return ToStringBuilder.reflectionToString(this); - } - - public boolean equals(Object o) { - return EqualsBuilder.reflectionEquals(this, o); + return "Person [address=" + address + ", age=" + age + ", children=" + children + ", firstName=" + firstName + + ", last_name=" + last_name + ", title=" + title + "]"; } + @Override public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + final int prime = 31; + int result = 1; + result = prime * result + ((address == null) ? 0 : address.hashCode()); + result = prime * result + age; + result = prime * result + ((children == null) ? 0 : children.hashCode()); + result = prime * result + ((firstName == null) ? 0 : firstName.hashCode()); + result = prime * result + ((last_name == null) ? 0 : last_name.hashCode()); + result = prime * result + ((title == null) ? 0 : title.hashCode()); + return result; } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Person other = (Person) obj; + if (address == null) { + if (other.address != null) + return false; + } + else if (!address.equals(other.address)) + return false; + if (age != other.age) + return false; + if (children == null) { + if (other.children != null) + return false; + } + else if (!children.equals(other.children)) + return false; + if (firstName == null) { + if (other.firstName != null) + return false; + } + else if (!firstName.equals(other.firstName)) + return false; + if (last_name == null) { + if (other.last_name != null) + return false; + } + else if (!last_name.equals(other.last_name)) + return false; + if (title == null) { + if (other.title != null) + return false; + } + else if (!title.equals(other.title)) + return false; + return true; + } + } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/CustomerDebit.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/CustomerDebit.java index 212d221bc..95566979d 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/CustomerDebit.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/CustomerDebit.java @@ -18,9 +18,6 @@ package org.springframework.batch.sample.domain.trade; import java.math.BigDecimal; -import org.apache.commons.lang.builder.EqualsBuilder; -import org.apache.commons.lang.builder.HashCodeBuilder; - public class CustomerDebit { private String name; @@ -53,12 +50,38 @@ public class CustomerDebit { public String toString() { return "CustomerDebit [name=" + name + ", debit=" + debit + "]"; } - - public boolean equals(Object o) { - return EqualsBuilder.reflectionEquals(this, o); + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((debit == null) ? 0 : debit.hashCode()); + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; } - public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + CustomerDebit other = (CustomerDebit) obj; + if (debit == null) { + if (other.debit != null) + return false; + } + else if (!debit.equals(other.debit)) + return false; + if (name == null) { + if (other.name != null) + return false; + } + else if (!name.equals(other.name)) + return false; + return true; } + } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/Trade.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/Trade.java index 4e171496f..f16de1516 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/Trade.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/Trade.java @@ -19,8 +19,6 @@ package org.springframework.batch.sample.domain.trade; import java.io.Serializable; import java.math.BigDecimal; -import org.apache.commons.lang.builder.HashCodeBuilder; - /** * @author Rob Harrop @@ -103,23 +101,51 @@ public class Trade implements Serializable { return "Trade: [isin=" + this.isin + ",quantity=" + this.quantity + ",price=" + this.price + ",customer=" + this.customer + "]"; } - - public boolean equals(Object o) { - if(!(o instanceof Trade)){ - return false; - } - - if(o == this){ - return true; - - } - - Trade t = (Trade)o; - return isin.equals(t.getIsin()) && quantity == t.getQuantity() && - price.equals(t.getPrice()) && customer.equals(t.getCustomer()) ; + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((customer == null) ? 0 : customer.hashCode()); + result = prime * result + ((isin == null) ? 0 : isin.hashCode()); + result = prime * result + ((price == null) ? 0 : price.hashCode()); + result = prime * result + (int) (quantity ^ (quantity >>> 32)); + result = prime * result + (int) (version ^ (version >>> 32)); + return result; } - public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Trade other = (Trade) obj; + if (customer == null) { + if (other.customer != null) + return false; + } + else if (!customer.equals(other.customer)) + return false; + if (isin == null) { + if (other.isin != null) + return false; + } + else if (!isin.equals(other.isin)) + return false; + if (price == null) { + if (other.price != null) + return false; + } + else if (!price.equals(other.price)) + return false; + if (quantity != other.quantity) + return false; + if (version != other.version) + return false; + return true; } -} + + }