Top Description Constructors Methods
org.freedesktop.dbus

public final Class StructHelper

extends Object
Class Inheritance
Imports
org.freedesktop.dbus.annotations.Position, org.freedesktop.dbus.types.DBusStructType, .Variant, org.freedesktop.dbus.utils.PrimitiveUtils, java.lang.reflect.Constructor, .Field, .InvocationTargetException, java.util.*

Helper util to create Struct subclasses when receiving it from DBus.
Author
David M.
Since
v3.2.1 - 2019-10-25

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static <
struct type
T extends Struct
>
void
convertToStructCollection(Collection<Object[]>
list of object arrays to process
_input
,
Class<T>
struct class to create
_structType
,
Collection<T>
collection to store results
_result
)

Creates a collection of struct of the given type using the list of object arrays.

public static <
struct type
T extends Struct
>
List<T>

Returns:

List of given struct type
convertToStructList
(List<Object[]>
list of object arrays to process
_obj
,
Class<T>
struct class to create
_structType
)

Creates a ArrayList of struct of the given type using the list of object arrays.

public static <
struct type
T extends Struct
>
Set<T>

Returns:

List of given struct type
convertToStructSet
(Set<Object[]>
list of object arrays to process
_obj
,
Class<T>
struct class to create
_structType
)

Creates a LinkedHashSet of struct of the given type using the list of object arrays.

public static <
type of struct
T extends Struct
>
T

Returns:

instance of _classToConstruct or null if any input argument is null
createStruct
(Class<?>[]
argument-classes expected by constructor
_constructorArgs
,
Object
values passed to the constructor
_values
,
Class<T>
Struct subclass to instantiate
_classToConstruct
)

Will create a new Struct subclass instance if possible.

public static <
type of struct
T extends Struct
>
T

Returns:

instance of _structClass or null if _variant is not Struct compatible or any input parameter is null
createStructFromVariant
(Variant<?>
variant to convert
_variant
,
Class<T>
Struct subclass to create
_structClass
)

Creates a instance of the given Struct subclass if the given variant is some sort of Struct.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

StructHelperback to summary
private StructHelper()

Method Detail

convertToStructCollectionback to summary
public static <T extends Struct> void convertToStructCollection(Collection<Object[]> _input, Class<T> _structType, Collection<T> _result) throws NoSuchMethodException, SecurityException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException

Creates a collection of struct of the given type using the list of object arrays.

Parameters
<T>
struct type
_input:Collection<Object[]>

list of object arrays to process

_structType:Class<T>

struct class to create

_result:Collection<T>

collection to store results

Exceptions
NoSuchMethodException:
when no constructor can be found for the arguments of the struct
SecurityException:
when constructor cannot be accesses
InstantiationException:
when reflection fails
IllegalAccessException:
if this Constructor object is enforcing Java language access control and the underlying constructor is inaccessible.
IllegalArgumentException:
when data types are incompatible or incompatible argument length
InvocationTargetException:
if the underlying constructor throws an exception
Since
4.3.1 - 2023-08-16
convertToStructListback to summary
public static <T extends Struct> List<T> convertToStructList(List<Object[]> _obj, Class<T> _structType) throws NoSuchMethodException, SecurityException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException

Creates a ArrayList of struct of the given type using the list of object arrays.

Parameters
<T>
struct type
_obj:List<Object[]>

list of object arrays to process

_structType:Class<T>

struct class to create

Returns:List<T>

List of given struct type

Exceptions
NoSuchMethodException:
when no constructor can be found for the arguments of the struct
SecurityException:
when constructor cannot be accesses
InstantiationException:
when reflection fails
IllegalAccessException:
if this Constructor object is enforcing Java language access control and the underlying constructor is inaccessible.
IllegalArgumentException:
when data types are incompatible or incompatible argument length
InvocationTargetException:
if the underlying constructor throws an exception
Since
4.3.1 - 2023-08-16
convertToStructSetback to summary
public static <T extends Struct> Set<T> convertToStructSet(Set<Object[]> _obj, Class<T> _structType) throws NoSuchMethodException, SecurityException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException

Creates a LinkedHashSet of struct of the given type using the list of object arrays.

Parameters
<T>
struct type
_obj:Set<Object[]>

list of object arrays to process

_structType:Class<T>

struct class to create

Returns:Set<T>

List of given struct type

Exceptions
NoSuchMethodException:
when no constructor can be found for the arguments of the struct
SecurityException:
when constructor cannot be accesses
InstantiationException:
when reflection fails
IllegalAccessException:
if this Constructor object is enforcing Java language access control and the underlying constructor is inaccessible.
IllegalArgumentException:
when data types are incompatible or incompatible argument length
InvocationTargetException:
if the underlying constructor throws an exception
Since
4.3.1 - 2023-08-16
createStructback to summary
public static <T extends Struct> T createStruct(Class<?>[] _constructorArgs, Object _values, Class<T> _classToConstruct) throws NoSuchMethodException, SecurityException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException

Will create a new Struct subclass instance if possible. May replace Wrapper-classes with primitive classes in _constructorArgs if constructor does not match.

Parameters
<T>
type of struct
_constructorArgs:Class<?>[]

argument-classes expected by constructor

_values:Object

values passed to the constructor

_classToConstruct:Class<T>

Struct subclass to instantiate

Returns:T

instance of _classToConstruct or null if any input argument is null

Exceptions
NoSuchMethodException:
when no constructor can be found for the arguments of the struct
SecurityException:
when constructor cannot be accesses
InstantiationException:
when reflection fails
IllegalAccessException:
if this Constructor object is enforcing Java language access control and the underlying constructor is inaccessible.
IllegalArgumentException:
when data types are incompatible
InvocationTargetException:
if the underlying constructor throws an exception
createStructFromVariantback to summary
public static <T extends Struct> T createStructFromVariant(Variant<?> _variant, Class<T> _structClass) throws NoSuchMethodException, SecurityException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException

Creates a instance of the given Struct subclass if the given variant is some sort of Struct.

Parameters
<T>
type of struct
_variant:Variant<?>

variant to convert

_structClass:Class<T>

Struct subclass to create

Returns:T

instance of _structClass or null if _variant is not Struct compatible or any input parameter is null

Exceptions
NoSuchMethodException:
when no constructor can be found for the arguments of the struct
SecurityException:
when constructor cannot be accesses
InstantiationException:
when reflection fails
IllegalAccessException:
if this Constructor object is enforcing Java language access control and the underlying constructor is inaccessible.
IllegalArgumentException:
when data types are incompatible
InvocationTargetException:
if the underlying constructor throws an exception