Class DBusObjects

java.lang.Object
org.freedesktop.dbus.utils.DBusObjects

public final class DBusObjects extends Object
Various validations.
Since:
5.0.0 - 2023-11-08
Author:
hypfvieh
  • Method Details

    • requirePackage

      public static Class<?> requirePackage(Class<?> _clz) throws ClassOutsideOfPackageException
      Ensures that the given class is part of a package.
      Parameters:
      _clz - class to check
      Returns:
      input if valid
      Throws:
      ClassOutsideOfPackageException - when class has no package
    • requireDBusInterface

      public static Class<?> requireDBusInterface(Class<?> _clz) throws MissingInterfaceImplementationException
      Ensures that the given class is implements or extends DBusInterface class.
      Parameters:
      _clz - class to check
      Returns:
      input if valid
      Throws:
      MissingInterfaceImplementationException - when class is incompatible
    • requireObjectPath

      public static String requireObjectPath(String _objectPath) throws InvalidObjectPathException
      Ensures given string is a valid object path.
      Parameters:
      _objectPath - string to check
      Returns:
      input string if valid
      Throws:
      InvalidObjectPathException - when input is not a valid object path
    • requireObjectPath

      public static DBusPath requireObjectPath(DBusPath _dbusPath) throws InvalidObjectPathException
      Ensures given DBusPath is a valid object path.
      Parameters:
      _dbusPath - to check
      Returns:
      input DBusPath if valid
      Throws:
      InvalidObjectPathException - when input is not a valid object path
    • requirePackage

      public static Class<?> requirePackage(Class<?> _clz, String _customMsg) throws ClassOutsideOfPackageException
      Ensures that the given class is part of a package.
      Parameters:
      _clz - class to check
      _customMsg - custom error message
      Returns:
      input if valid
      Throws:
      ClassOutsideOfPackageException - when class has no package
    • requireDBusInterface

      public static Class<?> requireDBusInterface(Class<?> _clz, String _customMsg) throws MissingInterfaceImplementationException
      Ensures that the given class is implements or extends DBusInterface class.
      Parameters:
      _clz - class to check
      _customMsg - custom error message
      Returns:
      input if valid
      Throws:
      MissingInterfaceImplementationException - when class is incompatible
    • requireDBusSignal

      public static Class<?> requireDBusSignal(Class<?> _clz, String _customMsg) throws InvalidSignalException
      Ensures that the given class is implements or extends DBusSignal class.
      Parameters:
      _clz - class to check
      _customMsg - custom error message
      Returns:
      input if valid
      Throws:
      InvalidSignalException - when class is incompatible
    • requireDBusSignal

      public static Class<?> requireDBusSignal(Class<?> _clz) throws InvalidSignalException
      Ensures that the given class is implements or extends DBusSignal class.
      Parameters:
      _clz - class to check
      Returns:
      input if valid
      Throws:
      InvalidSignalException - when class is incompatible
      Since:
      5.2.0 - 2025-05-02
    • requireDBusSignalRule

      public static void requireDBusSignalRule(Class<?> _type, String _source) throws DBusException
      Checks if given type is a DBusSignal and source comply with naming rules.
      Parameters:
      _type - class
      _source - source of signal (aka sender)
      Throws:
      DBusException - when validation fails
      Since:
      5.2.0 - 2025-05-02
    • requireDBusInterface

      public static String requireDBusInterface(String _str) throws InvalidObjectPathException
      Checks if given String is a valid DBusInterface.
      Parameters:
      _str - string to check
      Returns:
      input if valid
      Throws:
      InvalidObjectPathException - when not matching
      Since:
      5.2.0 - 2025-05-02
    • requireObjectPath

      public static String requireObjectPath(String _objectPath, String _customMsg) throws InvalidObjectPathException
      Ensures given string is a valid object path.
      Parameters:
      _objectPath - string to check
      _customMsg - custom error message
      Returns:
      input string if valid
      Throws:
      InvalidObjectPathException - when input is not a valid object path
    • requireObjectPath

      public static DBusPath requireObjectPath(DBusPath _dbusPath, String _customMsg) throws InvalidObjectPathException
      Ensures given DBusPath is a valid object path.
      Parameters:
      _dbusPath - to check
      _customMsg - custom error message
      Returns:
      input DBusPath if valid
      Throws:
      InvalidObjectPathException - when input is not a valid object path
    • requireBusName

      public static String requireBusName(String _busName) throws InvalidBusNameException
      Ensures given string is a valid bus name.
      Parameters:
      _busName - string to check
      Returns:
      input if valid
      Throws:
      InvalidBusNameException - when input is not a valid bus name
    • requireBusName

      public static String requireBusName(String _busName, String _customMessage) throws InvalidBusNameException
      Ensures given string is a valid bus name.
      Parameters:
      _busName - string to check
      _customMessage - custom exception message
      Returns:
      input if valid
      Throws:
      InvalidBusNameException - when input is not a valid bus name
    • requireNotBusName

      public static String requireNotBusName(String _busName, String _customMessage) throws InvalidBusNameException
      Ensures given string is NOT a valid bus name.
      Parameters:
      _busName - string to check
      _customMessage - custom exception message
      Returns:
      input if valid
      Throws:
      InvalidBusNameException - when input is a valid bus name
    • requireConnectionId

      public static String requireConnectionId(String _connId) throws InvalidBusNameException
      Ensures given string is a valid connection Id.
      Parameters:
      _connId - string to check
      Returns:
      input if valid
      Throws:
      InvalidBusNameException - when input is not a valid connection Id
    • requireBusNameOrConnectionId

      public static String requireBusNameOrConnectionId(String _busNameOrConnId) throws InvalidBusNameException
      Ensures given string is a valid bus name or connection Id.
      Parameters:
      _busNameOrConnId - string to check
      Returns:
      input if valid
      Throws:
      InvalidBusNameException - when input is not a valid bus name or connection Id
    • validateBusName

      public static boolean validateBusName(String _busName)
      Checks if input is valid bus name.
      Parameters:
      _busName - input to check
      Returns:
      true if valid
    • validateNotBusName

      public static boolean validateNotBusName(String _busName)
      Checks if input is NOT a valid bus name.
      Parameters:
      _busName - input to check
      Returns:
      true if invalid
    • validateObjectPath

      public static boolean validateObjectPath(String _objectPath)
      Checks if input is a valid object path.
      Parameters:
      _objectPath - input to check
      Returns:
      true if valid
    • validateDBusInterface

      public static boolean validateDBusInterface(Class<?> _clz)
      Checks if given class is compatible with DBusInterface class.
      Parameters:
      _clz - class to check
      Returns:
      true if class is compatible
    • validateDBusSignal

      public static boolean validateDBusSignal(Class<?> _clz)
      Checks if given class is compatible with DBusSignal class.
      Parameters:
      _clz - class to check
      Returns:
      true if class is compatible
      Since:
      5.2.0 - 2025-05-02
    • validateClassHasPackage

      public static boolean validateClassHasPackage(Class<?> _clz)
      Checks if given class has/is in a package.
      Parameters:
      _clz - class to check
      Returns:
      true if class has a package
    • validateNotObjectPath

      public static boolean validateNotObjectPath(String _objectPath)
      Checks if input is NOT a valid object path.
      Parameters:
      _objectPath - input to check
      Returns:
      true if invalid
    • validateNotConnectionId

      public static boolean validateNotConnectionId(String _connectionId)
      Checks if input is NOT a valid connection Id.
      Parameters:
      _connectionId - input to check
      Returns:
      true if invalid
    • validateConnectionId

      public static boolean validateConnectionId(String _connectionId)
      Checks if input is a valid connection Id.
      Parameters:
      _connectionId - input to check
      Returns:
      true if valid
    • requireNotNull

      public static <T, X extends Exception> T requireNotNull(T _input, Supplier<X> _exception) throws X
      Ensure given value is not null.
      Type Parameters:
      T - input type
      X - exception type to throw
      Parameters:
      _input - input to validate
      _exception - supplier providing exception which will be thrown if input is null
      Returns:
      input if not null
      Throws:
      X - exception provided by supplier thrown when input was null
    • ensurePublicInterfaces

      public static void ensurePublicInterfaces(Object _object) throws InvalidInterfaceSignature
      Ensures that all interfaces found on the given object a public accessable.
      Parameters:
      _object - object to check
      Throws:
      InvalidInterfaceSignature - when there is any interface on the given object which is non public