This commit is contained in:
Armin Schrenk
2025-03-19 11:58:04 +01:00
parent f27f3c46c1
commit fbbbc1cb40
2 changed files with 10 additions and 101 deletions

View File

@@ -1,101 +0,0 @@
package org.cryptomator.common;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javafx.beans.InvalidationListener;
import javafx.collections.MapChangeListener;
import javafx.collections.ObservableMap;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
public abstract class ObservableMapDecorator<K, V> implements ObservableMap<K, V> {
protected final ObservableMap<K, V> delegate;
protected ObservableMapDecorator(ObservableMap<K, V> delegate) {
this.delegate = delegate;
}
@Override
public void addListener(MapChangeListener<? super K, ? super V> mapChangeListener) {
delegate.addListener(mapChangeListener);
}
@Override
public void removeListener(MapChangeListener<? super K, ? super V> mapChangeListener) {
delegate.removeListener(mapChangeListener);
}
@Override
public int size() {
return delegate.size();
}
@Override
public boolean isEmpty() {
return delegate.isEmpty();
}
@Override
public boolean containsKey(Object key) {
return delegate.containsKey(key);
}
@Override
public boolean containsValue(Object value) {
return delegate.containsValue(value);
}
@Override
public V get(Object key) {
return delegate.get(key);
}
@Override
public @Nullable V put(K key, V value) {
return delegate.put(key, value);
}
@Override
public V remove(Object key) {
return delegate.remove(key);
}
@Override
public void putAll(@NotNull Map<? extends K, ? extends V> m) {
delegate.putAll(m);
}
@Override
public void clear() {
delegate.clear();
}
@Override
public @NotNull Set<K> keySet() {
return delegate.keySet();
}
@Override
public @NotNull Collection<V> values() {
return delegate.values();
}
@Override
public @NotNull Set<Entry<K, V>> entrySet() {
return delegate.entrySet();
}
@Override
public void addListener(InvalidationListener invalidationListener) {
delegate.addListener(invalidationListener);
}
@Override
public void removeListener(InvalidationListener invalidationListener) {
delegate.removeListener(invalidationListener);
}
}

View File

@@ -89,6 +89,7 @@ public class VaultEventsMap {
* Must be executed on the JavaFX application thread
*
* @return a list of vault events, mainly sorted ascending by the event timestamp
* @implNote Method is not synchronized, because it is only executed if executed by JavaFX application thread
*/
public List<VaultEvent> listAll() {
if (!Platform.isFxApplicationThread()) {
@@ -109,6 +110,7 @@ public class VaultEventsMap {
* @param v Vault where the event occurred
* @param similar A similar {@link FilesystemEvent} (same class, same idPath)
* @return the removed {@link Value}
* @implNote Method is not synchronized, because it is only executed if executed by JavaFX application thread
*/
public Value remove(Vault v, FilesystemEvent similar) {
if (!Platform.isFxApplicationThread()) {
@@ -119,6 +121,13 @@ public class VaultEventsMap {
return map.remove(key);
}
/**
* Clears the event map.
* <p>
* Must be executed on the JavaFX application thread
*
* @implNote Method is not synchronized, because it is only executed if executed by JavaFX application thread
*/
public void clear() {
if (!Platform.isFxApplicationThread()) {
throw new IllegalStateException("Map removal must be performed on JavaFX application thread");
@@ -151,6 +160,7 @@ public class VaultEventsMap {
*
* @param k Key of the entry to update
* @param v Value of the entry to update
* @implNote Method is not synchronized, because it is only called on the (one-and-only) JavaFX application thread
*/
private void updateMap(Key k, Value v) {
var entry = map.get(k);