public boolean equals(Object o) { if (o == null) return false; if (o.getClass() != this.getClass()) return false; if (this == o) return true; Food that = (Food) o; if (this.getVolume() != that.getVolume()) { return false; } if (this.getProteins() != that.getProteins()) { return false; } if (this.getFats() != that.getFats()) { return false; } if (this.getFresh() != that.getFresh()) { return false; } if (this.getName() != that.getName()) { return false; } return true; }