Fix dbus properties GetAll method for variants

This commit is contained in:
AsamK 2021-10-07 20:52:10 +02:00
parent c56a8df9b2
commit 179855272a

View file

@ -51,6 +51,7 @@ public abstract class DbusProperties implements Properties {
} }
@Override @Override
@SuppressWarnings("unchecked")
public Map<String, Variant<?>> GetAll(final String interface_name) { public Map<String, Variant<?>> GetAll(final String interface_name) {
final var handler = getHandlerOptional(interface_name); final var handler = getHandlerOptional(interface_name);
if (handler.isEmpty()) { if (handler.isEmpty()) {
@ -61,6 +62,9 @@ public abstract class DbusProperties implements Properties {
.getProperties() .getProperties()
.stream() .stream()
.filter(p -> p.getGetter() != null) .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);
}));
} }
} }