The four requirements
- current and new object
- permission to process transient variables
- prohibition to use reflection for the superclass
- exclusion of fields
are implemented, but something is not working yet.
package en.codegym.task.jdk13.task43.task4301;
/*
Compare Candidates
*/
import org.apache.commons.lang3.builder.EqualsBuilder;
import java.util.Objects;
public class Candidate {
private String name;
private int age;
private final transient String sex;
private transient int weight;
private transient int height;
private int yearsExperience;
public Candidate(String name, int age, String sex, int weight, int height, int yearsExperience) {
this.name = name;
this.age = age;
this.sex = sex;
this.weight = weight;
this.height = height;
this.yearsExperience = yearsExperience;
}
@Override
public boolean equals(Object obj) {
//write your code here
return EqualsBuilder.reflectionEquals(
this,
obj,
true, // process transient fields
Boolean.FALSE, // do not use reflection for superclass
"name",
"age",
"height",
"weight" // exclude these fields
);
//return false;
}
@Override
public int hashCode() {
return Objects.hash(sex, yearsExperience);
}
}