]> nmode's Git Repositories - signal-cli/blobdiff - src/main/java/org/asamk/signal/dbus/DbusProperties.java
Move configuration store to db
[signal-cli] / src / main / java / org / asamk / signal / dbus / DbusProperties.java
index 37cc35e340099cf2174bba29648d191e3b6ce2b3..256b858d080b4f5679dadb525e7b666ed8b8e0ac 100644 (file)
@@ -7,6 +7,7 @@ import org.freedesktop.dbus.types.Variant;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 import java.util.stream.Collectors;
 
 public abstract class DbusProperties implements Properties {
@@ -25,7 +26,7 @@ public abstract class DbusProperties implements Properties {
         return handler.get();
     }
 
-    private java.util.Optional<DbusInterfacePropertiesHandler> getHandlerOptional(final String interfaceName) {
+    private Optional<DbusInterfacePropertiesHandler> getHandlerOptional(final String interfaceName) {
         return handlers.stream().filter(h -> h.getInterfaceName().equals(interfaceName)).findFirst();
     }
 
@@ -51,6 +52,7 @@ public abstract class DbusProperties implements Properties {
     }
 
     @Override
+    @SuppressWarnings("unchecked")
     public Map<String, Variant<?>> GetAll(final String interface_name) {
         final var handler = getHandlerOptional(interface_name);
         if (handler.isEmpty()) {
@@ -61,6 +63,9 @@ public abstract class DbusProperties implements Properties {
                 .getProperties()
                 .stream()
                 .filter(p -> p.getGetter() != null)
-                .collect(Collectors.toMap(DbusProperty::getName, p -> new Variant<>(p.getGetter().get())));
+                .collect(Collectors.toMap(DbusProperty::getName, p -> {
+                    final Object o = p.getGetter().get();
+                    return o instanceof Variant ? (Variant<Object>) o : new Variant<>(o);
+                }));
     }
 }