package org.asamk.signal.dbus; import org.asamk.Signal; import java.util.Collection; import java.util.List; import java.util.function.Consumer; import java.util.function.Supplier; public class DbusInterfacePropertiesHandler { private final String interfaceName; private final List> properties; public DbusInterfacePropertiesHandler(final String interfaceName, final List> properties) { this.interfaceName = interfaceName; this.properties = properties; } public String getInterfaceName() { return interfaceName; } @SuppressWarnings("unchecked") private DbusProperty findProperty(String propertyName) { final var property = properties.stream().filter(p -> p.getName().equals(propertyName)).findFirst(); if (property.isEmpty()) { throw new Signal.Error.Failure("Property not found"); } return (DbusProperty) property.get(); } Consumer getSetter(String propertyName) { return this.findProperty(propertyName).getSetter(); } Supplier getGetter(String propertyName) { return this.findProperty(propertyName).getGetter(); } Collection> getProperties() { return properties; } }