Package org.freedesktop.dbus
Class StructHelper
java.lang.Object
org.freedesktop.dbus.StructHelper
Helper util to create
Struct subclasses when receiving it from DBus.- Since:
- v3.2.1 - 2019-10-25
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Struct>
TcreateStruct(Class<?>[] _constructorArgs, Object _values, Class<T> _classToConstruct) Will create a newStructsubclass instance if possible.static <T extends Struct>
TcreateStructFromVariant(Variant<?> _variant, Class<T> _structClass) Creates a instance of the givenStructsubclass if the given variant is some sort of Struct.
-
Constructor Details
-
StructHelper
private StructHelper()
-
-
Method Details
-
createStructFromVariant
public static <T extends Struct> T createStructFromVariant(Variant<?> _variant, Class<T> _structClass) throws NoSuchMethodException, SecurityException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException Creates a instance of the givenStructsubclass if the given variant is some sort of Struct.- Type Parameters:
T- type of struct- Parameters:
_variant- variant to convert_structClass-Structsubclass to create- Returns:
- instance of _structClass or null if _variant is not Struct compatible or any input parameter is null
- Throws:
NoSuchMethodException- when no constructor can be found for the arguments of the structSecurityException- when constructor cannot be accessesInstantiationException- when reflection failsIllegalAccessException- if this Constructor object is enforcing Java language access control and the underlying constructor is inaccessible.IllegalArgumentException- when data types are incompatibleInvocationTargetException- if the underlying constructor throws an exception
-
createStruct
public static <T extends Struct> T createStruct(Class<?>[] _constructorArgs, Object _values, Class<T> _classToConstruct) throws NoSuchMethodException, SecurityException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException Will create a newStructsubclass instance if possible. May replace Wrapper-classes with primitive classes in _constructorArgs if constructor does not match.- Type Parameters:
T- type of struct- Parameters:
_constructorArgs- argument-classes expected by constructor_values- values passed to the constructor_classToConstruct-Structsubclass to instantiate- Returns:
- instance of _classToConstruct or null if any input argument is null
- Throws:
NoSuchMethodException- when no constructor can be found for the arguments of the structSecurityException- when constructor cannot be accessesInstantiationException- when reflection failsIllegalAccessException- if this Constructor object is enforcing Java language access control and the underlying constructor is inaccessible.IllegalArgumentException- when data types are incompatibleInvocationTargetException- if the underlying constructor throws an exception
-