Class Variant<T>

java.lang.Object
org.freedesktop.dbus.types.Variant<T>

public class Variant<T> extends Object
A Wrapper class for Variant values. A method on DBus can send or receive a Variant. This will wrap another value whose type is determined at runtime. The Variant may be parameterized to restrict the types it may accept.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final org.slf4j.Logger
     
    private final String
     
    private final Type
     
    private final T
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Variant(T _value)
    Create a Variant from a basic type object.
    Variant(T _value, Type _type)
    Create a Variant.
    Variant(T _value, String _sig)
    Create a Variant.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    equals(Object _obj)
    Compare this Variant with another by comparing contents.
    Return the dbus signature of the wrapped value.
    Return the type of the wrapped value.
    Return the wrapped value.
    int
     
    Format the Variant as a string.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • logger

      private final org.slf4j.Logger logger
    • value

      private final T value
    • type

      private final Type type
    • sig

      private final String sig
  • Constructor Details

    • Variant

      public Variant(T _value) throws IllegalArgumentException
      Create a Variant from a basic type object.
      Parameters:
      _value - The wrapped value.
      Throws:
      IllegalArgumentException - If you try and wrap Null or an object of a non-basic type.
    • Variant

      public Variant(T _value, Type _type) throws IllegalArgumentException
      Create a Variant.
      Parameters:
      _value - The wrapped value.
      _type - The explicit type of the value.
      Throws:
      IllegalArgumentException - If you try and wrap Null or an object which cannot be sent over DBus.
    • Variant

      public Variant(T _value, String _sig) throws IllegalArgumentException
      Create a Variant.
      Parameters:
      _value - The wrapped value.
      _sig - The explicit type of the value, as a dbus type string.
      Throws:
      IllegalArgumentException - If you try and wrap Null or an object which cannot be sent over DBus.
  • Method Details

    • getValue

      public T getValue()
      Return the wrapped value.
      Returns:
      value
    • getType

      public Type getType()
      Return the type of the wrapped value.
      Returns:
      type
    • getSig

      public String getSig()
      Return the dbus signature of the wrapped value.
      Returns:
      signature
    • toString

      public String toString()
      Format the Variant as a string.
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object _obj)
      Compare this Variant with another by comparing contents.
      Overrides:
      equals in class Object
      Parameters:
      _obj - other object
      Returns:
      boolean