Skip to content

Commit 1c5c6bf

Browse files
committed
add fallback methods for DataStore interface to avoid breaking change on concrete implementation, implementation will be required to move to the new interface
1 parent 30d21e2 commit 1c5c6bf

File tree

1 file changed

+48
-1
lines changed
  • domino-ui/src/main/java/org/dominokit/domino/ui/datatable/store

1 file changed

+48
-1
lines changed

domino-ui/src/main/java/org/dominokit/domino/ui/datatable/store/DataStore.java

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
package org.dominokit.domino.ui.datatable.store;
1818

19+
import java.util.Objects;
20+
import org.dominokit.domino.ui.data.DataChangedEvent;
21+
1922
/**
2023
* The {@code DataStore} interface defines a contract for managing and retrieving data for a data
2124
* table.
@@ -24,4 +27,48 @@
2427
* @deprecated use {@link org.dominokit.domino.ui.data.DataStore} instead
2528
*/
2629
@Deprecated
27-
public interface DataStore<T> extends org.dominokit.domino.ui.data.DataStore<T> {}
30+
public interface DataStore<T> extends org.dominokit.domino.ui.data.DataStore<T> {
31+
32+
void onDataChanged(
33+
org.dominokit.domino.ui.datatable.store.StoreDataChangeListener<T> dataChangeListener);
34+
35+
void removeDataChangeListener(
36+
org.dominokit.domino.ui.datatable.store.StoreDataChangeListener<T> dataChangeListener);
37+
38+
default void onDataChanged(
39+
org.dominokit.domino.ui.data.StoreDataChangeListener<T> dataChangeListener) {
40+
onDataChanged(new ListenerWrapper<>(dataChangeListener));
41+
}
42+
43+
default void removeDataChangeListener(
44+
org.dominokit.domino.ui.data.StoreDataChangeListener<T> dataChangeListener) {
45+
removeDataChangeListener(new ListenerWrapper<>(dataChangeListener));
46+
}
47+
48+
final class ListenerWrapper<T>
49+
implements org.dominokit.domino.ui.datatable.store.StoreDataChangeListener<T> {
50+
51+
private final org.dominokit.domino.ui.data.StoreDataChangeListener<T> wrapped;
52+
53+
public ListenerWrapper(org.dominokit.domino.ui.data.StoreDataChangeListener<T> wrapped) {
54+
this.wrapped = wrapped;
55+
}
56+
57+
@Override
58+
public void onDataChanged(DataChangedEvent<T> dataChangedEvent) {
59+
wrapped.onDataChanged(dataChangedEvent);
60+
}
61+
62+
@Override
63+
public boolean equals(Object o) {
64+
if (o == null || getClass() != o.getClass()) return false;
65+
ListenerWrapper<?> that = (ListenerWrapper<?>) o;
66+
return Objects.equals(wrapped, that.wrapped);
67+
}
68+
69+
@Override
70+
public int hashCode() {
71+
return Objects.hashCode(wrapped);
72+
}
73+
}
74+
}

0 commit comments

Comments
 (0)