Class StructHelper


  • public final class StructHelper
    extends java.lang.Object
    Helper util to create Struct subclasses when receiving it from DBus.
    Since:
    v3.2.1 - 2019-10-25
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private StructHelper()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T extends Struct>
      T
      createStruct​(java.lang.Class<?>[] _constructorArgs, java.lang.Object _values, java.lang.Class<T> _classToConstruct)
      Will create a new Struct subclass instance if possible.
      static <T extends Struct>
      T
      createStructFromVariant​(Variant<?> _variant, java.lang.Class<T> _structClass)
      Creates a instance of the given Struct subclass if the given variant is some sort of Struct.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • StructHelper

        private StructHelper()
    • Method Detail

      • createStructFromVariant

        public static <T extends Struct> T createStructFromVariant​(Variant<?> _variant,
                                                                   java.lang.Class<T> _structClass)
                                                            throws java.lang.NoSuchMethodException,
                                                                   java.lang.SecurityException,
                                                                   java.lang.InstantiationException,
                                                                   java.lang.IllegalAccessException,
                                                                   java.lang.IllegalArgumentException,
                                                                   java.lang.reflect.InvocationTargetException
        Creates a instance of the given Struct subclass if the given variant is some sort of Struct.
        Type Parameters:
        T - type of struct
        Parameters:
        _variant - variant to convert
        _structClass - Struct subclass to create
        Returns:
        instance of _structClass or null if _variant is not Struct compatible or any input parameter is null
        Throws:
        java.lang.NoSuchMethodException - when no constructor can be found for the arguments of the struct
        java.lang.SecurityException - when constructor cannot be accesses
        java.lang.InstantiationException - when reflection fails
        java.lang.IllegalAccessException - if this Constructor object is enforcing Java language access control and the underlying constructor is inaccessible.
        java.lang.IllegalArgumentException - when data types are incompatible
        java.lang.reflect.InvocationTargetException - if the underlying constructor throws an exception
      • createStruct

        public static <T extends Struct> T createStruct​(java.lang.Class<?>[] _constructorArgs,
                                                        java.lang.Object _values,
                                                        java.lang.Class<T> _classToConstruct)
                                                 throws java.lang.NoSuchMethodException,
                                                        java.lang.SecurityException,
                                                        java.lang.InstantiationException,
                                                        java.lang.IllegalAccessException,
                                                        java.lang.IllegalArgumentException,
                                                        java.lang.reflect.InvocationTargetException
        Will create a new Struct subclass 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 - Struct subclass to instantiate
        Returns:
        instance of _classToConstruct or null if any input argument is null
        Throws:
        java.lang.NoSuchMethodException - when no constructor can be found for the arguments of the struct
        java.lang.SecurityException - when constructor cannot be accesses
        java.lang.InstantiationException - when reflection fails
        java.lang.IllegalAccessException - if this Constructor object is enforcing Java language access control and the underlying constructor is inaccessible.
        java.lang.IllegalArgumentException - when data types are incompatible
        java.lang.reflect.InvocationTargetException - if the underlying constructor throws an exception