Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // with instance of checked
- public class Example {
- private String foo;
- private int bar;
- public String getFoo() {
- return foo;
- }
- public void setFoo(String foo) {
- this.foo = foo;
- }
- public int getBar() {
- return bar;
- }
- public void setBar(int bar) {
- this.bar = bar;
- }
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + bar;
- result = prime * result + ((foo == null) ? 0 : foo.hashCode());
- return result;
- }
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (!(obj instanceof Example))
- return false;
- Example other = (Example) obj;
- if (bar != other.bar)
- return false;
- if (foo == null) {
- if (other.foo != null)
- return false;
- } else if (!foo.equals(other.foo))
- return false;
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement