On Wed, 29 Nov 2023 15:54:17 GMT, Andy Goryachev <ango...@openjdk.org> wrote:
> > I'm unconvinced that this is the way to solve the issue it describes in its > > doc. The problem is that each control wants to add its own css metadata to > > that of its parent (recursively), and that the list is immutable (or > > unmodifiable). > > This is not the problem. But it is according to the CSR: "the same less-than-optimal implementation is duplicated throughout the javafx code base which combines the parent and child styleable properties, using ArrayList wrapped in a Collections.unmodifiableList()". > > The solution offered is a helper method for the general problem of creating > > a new immutable list from an existing one plus other elements (I agree with > > John that it's another copy of this kind of method, which would probably > > mean it's a good candidate for the JDK). > > I would not go that far as to call it a candidate for JDK, the scope of this > change is limited to CssMetaData and is sufficiently different from a general > purpose entity. But it's limited because it has been artificially limited. It's a special case of `<T> List<T> combine(List<T>, T... items)`, which is a general utility method. Just duplicating this method for specific `T`'s doesn't make it more fitting for that scope. > > What each class brings with itself is a list of its own metadata > > properties. That's all it should declare. This list should automatically be > > added to the one of its parent, recursively, forming the final list. This > > part shouldn't be done by users as it's just another place to make a > > mistake in. > > True. The only way to avoid mistake is to have this data generated by > reflection or pre-processing. Neither is a good alternative, so I am not > solving this particular problem. The problem I am trying to solve is to > provide a slightly more efficient utility method to replace repeating the > same code over and over. I don't think this is the only way at all. John outlined one solution, I think there is at least one more that I can broadly think of that works in maybe a similar way to how dirty bits are implemented. ------------- PR Comment: https://git.openjdk.org/jfx/pull/1296#issuecomment-1832704078