BAEL-3859 Remove unnecessary equals and hashcode overriden methods.

This commit is contained in:
Florin Hriscu 2020-03-13 21:25:17 +02:00
parent ae6aaf40f0
commit 205ee99874

View File

@ -1,6 +1,5 @@
package com.baeldung.concurrent.atomic; package com.baeldung.concurrent.atomic;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicMarkableReference; import java.util.concurrent.atomic.AtomicMarkableReference;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -18,24 +17,21 @@ public class AtomicMarkableReferenceUnitTest {
this.name = name; this.name = name;
} }
@Override public int getId() {
public boolean equals(Object obj) { return id;
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof Employee))
return false;
Employee employee = (Employee) obj;
return id == employee.id && name.equals(employee.name);
} }
@Override public void setId(int id) {
public int hashCode() { this.id = id;
return Objects.hash(id, name);
} }
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
} }
@Test @Test