class MyClass {
private final int i;
private final Boolean b;
private final String s;
private MyClass(int i, Boolean b, String s) {
this.i = i;
this.b = b;
this.s = s;
}
public int getI() {
return i;
}
public Boolean getB() {
return b;
}
public String getS() {
return s;
}
@Override
public int hashCode() {
return Objects.hash(i, b, s);
}
@Override
public boolean equals(Object obj) {
return LambdaEquals.equals(this , obj,
MyClass::getI,
MyClass::getB,
MyClass::getS);
}
public boolean oldStyleEquals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
final MyClass other = (MyClass) obj;
return Objects.equals(this.i, other.i)
&& Objects.equals(this.b, other.b)
&& Objects.equals(this.s, other.s);
}
}
-
Notifications
You must be signed in to change notification settings - Fork 2
A Java 8 utility method to implement equals method without boilerplate
License
blemale/lambda-equals
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
A Java 8 utility method to implement equals method without boilerplate
Resources
License
Stars
Watchers
Forks
Releases
No releases published