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(
16 final String interfaceName
, final List
<DbusProperty
<?
>> properties
18 this.interfaceName
= interfaceName
;
19 this.properties
= properties
;
22 public String
getInterfaceName() {
26 @SuppressWarnings("unchecked")
27 private <T
> DbusProperty
<T
> findProperty(String propertyName
) {
28 final var property
= properties
.stream().filter(p
-> p
.getName().equals(propertyName
)).findFirst();
29 if (property
.isEmpty()) {
30 throw new Signal
.Error
.Failure("Property not found");
32 return (DbusProperty
<T
>) property
.get();
35 <T
> Consumer
<T
> getSetter(String propertyName
) {
36 return this.<T
>findProperty(propertyName
).getSetter();
39 <T
> Supplier
<T
> getGetter(String propertyName
) {
40 return this.<T
>findProperty(propertyName
).getGetter();
43 Collection
<DbusProperty
<?
>> getProperties() {