RFR: JDK-8298200 Clean up raw type warnings in javafx.beans.property.* and com.sun.javafx.property.* [v2]
John Hendrikx
jhendrikx at openjdk.org
Fri Dec 9 20:13:52 UTC 2022
On Fri, 9 Dec 2022 18:40:09 GMT, Nir Lisker <nlisker at openjdk.org> wrote:
>> It also removes the need for the `SuppressWarnings` here.
>
> I suggest the following method:
>
>
> @Override
> public boolean equals(Object obj) {
> if (this == obj) {
> return true;
> }
> if (!(obj instanceof List<?> otherList)) {
> return false;
> }
> if (size() != otherList.size()) {
> return false;
> }
> ListIterator<E> e1 = listIterator();
> ListIterator<?> e2 = otherList.listIterator();
> while (e1.hasNext() && e2.hasNext()) {
> if (!Objects.equals(e1.next(), e2.next())) {
> return false;
> }
> }
> return true;
> }
>
>
> Technically, there's no need to check `hasNext` on both since they have the same length, but it doesn't matter.
>
> I also don't like the names `e1` and `e2` for list iterators :)
There is a lot to not like about this method. Especially because apparently you can pass in a `List` to this equals method that is for a `ReadOnlyListProperty`. How is a list equal to a property? What sense does it make to do this:
ReadOnlyListProperty<String> x;
x.equals(List.of("a", "b", "c"));
Shouldn't that be:
x.get().equals(List.of("a", "b", "c"));
?
-------------
PR: https://git.openjdk.org/jfx/pull/969
More information about the openjfx-dev
mailing list