Closed sumhungyee closed 1 year ago
@sumhungyee Perhaps you can give the code as text instead of screenshots so that others can easy copy-paste-modify the code?
public void setPersons(List<Person> persons) {
requireAllNonNull(persons);
ObservableList<Person> test = FXCollections.observableArrayList();
Person p = new Person(new Name("a"), new Postal("111111"), new Date("2000-01-01"), new Age("11"), getVariantSet("DENV1"));
test.setAll(List.<Person>of(p));
System.out.println(test);
test.setAll(List.<Person>of(p));
System.out.println(test);
if (!personsAreUnique(persons)) {
throw new DuplicatePersonException();
}
System.out.println("UNIQUEPLIST: " + persons);
System.out.println("in: " + this.internalList);
this.internalList.setAll(persons);
System.out.println(this.internalList);
}
Thanks prof. Also, somehow when changing from ObservableList<Integer> to ObservableList<Person> the test code (above) works now, but the main setAll code still fails
Resolved. Issue was persons is mutable. Replaced with List.copyOf(persons)
Resolved. Issue was persons is mutable. Replaced with List.copyOf(persons)
The so called 'rubber-duck debugging' :-p i.e., trying to explain the problem in details sometimes leads to the solution.
persons is a type List\<Person>, internalList is of type ObservableList\<Person> setAll clears the list instead of setting everything. somehow only does this for persons not integers pls send help prof! :( @damithc