I have two custom lists that tell CompanyList that
public class CompanyList<E> extends Collection<E> implements List<E> {}
Here I have a list of CompanyList, so
public class CompanyMakeVO extends BaseVO {
private static final long serialVersionUID = 1L;
private String name;
public CompanyMakeVO() {
super();
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public boolean equals(Object obj) {
if (obj == null || !(obj.getClass() == this.getClass())) {
return false;
}
CompanyMakeVO make = (CompanyMakeVO) obj;
String thisName = this.getName();
String thatName = make.getName();
if (null == thisName || null == thatName)
return false;
return thisName.equals(thatName);
}
public int hashCode() {
return getName().hashCode();
}
}
I have two such lists: oldList and newList have some CompanyMakeVO objects, each object represents the company name through the name attribute. Let's say the old list has 3 objects named Audi, BMW and Aston Martin, and the new list consists of 5 objects named Audi, BMW, Aston Martin, Jaquar and Tesla. There will be no duplicate elements in the lists. The dug name will not be repeated. I need to find a unique element present in any list, as well as with the list name and element name. What is the best way to find out?