BAEL - 971 Code Changes (#2492)

* BAEL-971 Code

BAEL-  971 Introduction to Apache Commons Lang3 code

* BAEL - 971 Code

BAEL - 971 : Introduction to Apache Commons Lang3

* Updated the commons.lang version from V3.5 to V3.6
This commit is contained in:
Kiran
2017-08-28 21:48:44 +05:30
committed by adamd1985
parent c5d77f424d
commit 73526dd0a8
3 changed files with 180 additions and 2 deletions
@@ -0,0 +1,60 @@
package com.baeldung.commons.lang3;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
public class BuilderMethods {
private final int intValue;
private final String strSample;
public BuilderMethods(final int newId, final String newName) {
this.intValue = newId;
this.strSample = newName;
}
public int getId() {
return this.intValue;
}
public String getName() {
return this.strSample;
}
@Override
public int hashCode() {
return new HashCodeBuilder().append(this.intValue)
.append(this.strSample)
.toHashCode();
}
@Override
public boolean equals(Object obj) {
if (obj instanceof BuilderMethods == false) {
return false;
}
if (this == obj) {
return true;
}
final BuilderMethods otherObject = (BuilderMethods) obj;
return new EqualsBuilder().append(this.intValue, otherObject.intValue)
.append(this.strSample, otherObject.strSample)
.isEquals();
}
@Override
public String toString() {
return new ToStringBuilder(this).append("INTVALUE", this.intValue)
.append("STRINGVALUE", this.strSample)
.toString();
}
public static void main(final String[] arguments) {
final BuilderMethods simple1 = new BuilderMethods(1, "The First One");
System.out.println(simple1.getName());
System.out.println(simple1.hashCode());
System.out.println(simple1.toString());
}
}