1 package org
.asamk
.signal
.dbus
;
3 import org
.asamk
.Signal
;
5 import java
.util
.Collection
;
7 import java
.util
.function
.Consumer
;
8 import java
.util
.function
.Supplier
;
10 public class DbusInterfacePropertiesHandler
{
12 private final String interfaceName
;
13 private final List
<DbusProperty
<?
>> properties
;
15 public DbusInterfacePropertiesHandler(final String interfaceName
, final List
<DbusProperty
<?
>> properties
) {
16 this.interfaceName
= interfaceName
;
17 this.properties
= properties
;
20 public String
getInterfaceName() {
24 @SuppressWarnings("unchecked")
25 private <T
> DbusProperty
<T
> findProperty(String propertyName
) {
26 final var property
= properties
.stream().filter(p
-> p
.getName().equals(propertyName
)).findFirst();
27 if (property
.isEmpty()) {
28 throw new Signal
.Error
.Failure("Property not found");
30 return (DbusProperty
<T
>) property
.get();
33 <T
> Consumer
<T
> getSetter(String propertyName
) {
34 return this.<T
>findProperty(propertyName
).getSetter();
37 <T
> Supplier
<T
> getGetter(String propertyName
) {
38 return this.<T
>findProperty(propertyName
).getGetter();
41 Collection
<DbusProperty
<?
>> getProperties() {