jwstegemann / fritz2

Easily build reactive web-apps in Kotlin based on flows and coroutines.
https://www.fritz2.dev
MIT License
636 stars 25 forks source link

equals()/hashCode() for ComponentValidationMessage #801

Closed metin-kale closed 9 months ago

metin-kale commented 10 months ago

ComponentValidationMessage does not implement equals()/hashCode(). Even if we have exact the same ComponentValidationMessage''s, equals() will say they are un-equal.

If we e.g. use ValidatingStore.allMessages().distinctUntilChanged(), the distinctUntilChanged will be useless, because the Messages will never be equal.

We should either use a 'data class' oder implement proper equals()/hashCode()-Functions.

Lysander commented 10 months ago

Dumb question: Would changing the type from class to data class be API breaking? I would assume no, as only some methods on top appear...

In General I would agree, that those messages should definitely be data classes!

I ask for picking the correct label category on which we base the release notes later on...

metin-kale commented 9 months ago

No, it should not be api breaking at all. Construction and reading a data class object is the same.

metin-kale commented 9 months ago

ComponentValidationMessage turned out to be a "open class". Therefore the change is indeed api-breaking! Because using ComponentValidationMessage as supertype is rather rare we still decided to change it to data class instead.

see #808