I am trying to create an array of unique values based on the properties of a number of identical Objects. These properties will have identical values, but some of them will be null, like so:
Object obj1 = new Object("Value 1", "Value 2", null);
Object obj2 = new Object("Value 1", null, "Value 3");
Object obj3 = new Object(null, "Value2", "Value3")
Object Class
public class Object {
private String value1;
private String value2;
private String value3;
// Constructor
public Object(String value1, String value2, String value3){ // this.value1... }
// Getters & Setters
}
(These Objects can have n number of properties, but assume just 3 for this question)
How can I take the above 3 objects (or any number objects) and quickly combine (or sample) each of their properties to create the below array?
["Value 1", "Value 2", "Value 3"]
I'm thinking a Set could be useful here, but I'm not quite sure how to approach it