Class DBusObjects
java.lang.Object
org.freedesktop.dbus.utils.DBusObjects
Various validations.
- Since:
- 5.0.0 - 2023-11-08
- Author:
- hypfvieh
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidensurePublicInterfaces(Object _object) Ensures that all interfaces found on the given object a public accessable.static StringrequireBusName(String _busName) Ensures given string is a valid bus name.static StringrequireBusName(String _busName, String _customMessage) Ensures given string is a valid bus name.static StringrequireBusNameOrConnectionId(String _busNameOrConnId) Ensures given string is a valid bus name or connection Id.static StringrequireConnectionId(String _connId) Ensures given string is a valid connection Id.static Class<?> requireDBusInterface(Class<?> _clz) Ensures that the given class is implements or extendsDBusInterfaceclass.static Class<?> requireDBusInterface(Class<?> _clz, String _customMsg) Ensures that the given class is implements or extendsDBusInterfaceclass.static StringrequireDBusInterface(String _str) Checks if given String is a valid DBusInterface.static Class<?> requireDBusSignal(Class<?> _clz) Ensures that the given class is implements or extendsDBusSignalclass.static Class<?> requireDBusSignal(Class<?> _clz, String _customMsg) Ensures that the given class is implements or extendsDBusSignalclass.static voidrequireDBusSignalRule(Class<?> _type, String _source) Checks if given type is a DBusSignal and source comply with naming rules.static StringrequireNotBusName(String _busName, String _customMessage) Ensures given string is NOT a valid bus name.static <T, X extends Exception>
TrequireNotNull(T _input, Supplier<X> _exception) Ensure given value is not null.static StringrequireObjectPath(String _objectPath) Ensures given string is a valid object path.static StringrequireObjectPath(String _objectPath, String _customMsg) Ensures given string is a valid object path.static DBusPathrequireObjectPath(DBusPath _dbusPath) Ensures given DBusPath is a valid object path.static DBusPathrequireObjectPath(DBusPath _dbusPath, String _customMsg) Ensures given DBusPath is a valid object path.static Class<?> requirePackage(Class<?> _clz) Ensures that the given class is part of a package.static Class<?> requirePackage(Class<?> _clz, String _customMsg) Ensures that the given class is part of a package.static booleanvalidateBusName(String _busName) Checks if input is valid bus name.static booleanvalidateClassHasPackage(Class<?> _clz) Checks if given class has/is in a package.static booleanvalidateConnectionId(String _connectionId) Checks if input is a valid connection Id.static booleanvalidateDBusInterface(Class<?> _clz) Checks if given class is compatible withDBusInterfaceclass.static booleanvalidateDBusSignal(Class<?> _clz) Checks if given class is compatible withDBusSignalclass.static booleanvalidateNotBusName(String _busName) Checks if input is NOT a valid bus name.static booleanvalidateNotConnectionId(String _connectionId) Checks if input is NOT a valid connection Id.static booleanvalidateNotObjectPath(String _objectPath) Checks if input is NOT a valid object path.static booleanvalidateObjectPath(String _objectPath) Checks if input is a valid object path.
-
Method Details
-
requirePackage
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 extendsDBusInterfaceclass.- Parameters:
_clz- class to check- Returns:
- input if valid
- Throws:
MissingInterfaceImplementationException- when class is incompatible
-
requireObjectPath
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
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 extendsDBusInterfaceclass.- 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 extendsDBusSignalclass.- Parameters:
_clz- class to check_customMsg- custom error message- Returns:
- input if valid
- Throws:
InvalidSignalException- when class is incompatible
-
requireDBusSignal
Ensures that the given class is implements or extendsDBusSignalclass.- Parameters:
_clz- class to check- Returns:
- input if valid
- Throws:
InvalidSignalException- when class is incompatible- Since:
- 5.2.0 - 2025-05-02
-
requireDBusSignalRule
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
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
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
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
Checks if input is valid bus name.- Parameters:
_busName- input to check- Returns:
- true if valid
-
validateNotBusName
Checks if input is NOT a valid bus name.- Parameters:
_busName- input to check- Returns:
- true if invalid
-
validateObjectPath
Checks if input is a valid object path.- Parameters:
_objectPath- input to check- Returns:
- true if valid
-
validateDBusInterface
Checks if given class is compatible withDBusInterfaceclass.- Parameters:
_clz- class to check- Returns:
- true if class is compatible
-
validateDBusSignal
Checks if given class is compatible withDBusSignalclass.- Parameters:
_clz- class to check- Returns:
- true if class is compatible
- Since:
- 5.2.0 - 2025-05-02
-
validateClassHasPackage
Checks if given class has/is in a package.- Parameters:
_clz- class to check- Returns:
- true if class has a package
-
validateNotObjectPath
Checks if input is NOT a valid object path.- Parameters:
_objectPath- input to check- Returns:
- true if invalid
-
validateNotConnectionId
Checks if input is NOT a valid connection Id.- Parameters:
_connectionId- input to check- Returns:
- true if invalid
-
validateConnectionId
Checks if input is a valid connection Id.- Parameters:
_connectionId- input to check- Returns:
- true if valid
-
requireNotNull
Ensure given value is not null.- Type Parameters:
T- input typeX- 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
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
-