Class DefaultDriver

  • All Implemented Interfaces:
    Annotations, Driver

    public class DefaultDriver
    extends Object
    implements Driver
    Default implementation of extensible driver.
    • Constructor Detail

      • DefaultDriver

        public DefaultDriver​(String name,
                             List<Driver> parents,
                             String manufacturer,
                             String hwVersion,
                             String swVersion,
                             Map<Class<? extends Behaviour>,​Class<? extends Behaviour>> behaviours,
                             Map<String,​String> properties)
        Creates a driver with the specified name.
        Parameters:
        name - driver name
        parents - optional parent drivers
        manufacturer - device manufacturer
        hwVersion - device hardware version
        swVersion - device software version
        behaviours - device behaviour classes
        properties - properties for configuration of device behaviour classes
    • Method Detail

      • merge

        public Driver merge​(Driver other)
        Description copied from interface: Driver
        Merges the specified driver behaviours and properties into this one, giving preference to the other driver when dealing with conflicts.
        Specified by:
        merge in interface Driver
        Parameters:
        other - other driver
        Returns:
        merged driver
      • name

        public String name()
        Description copied from interface: Driver
        Returns the driver name. This is expected to be a reverse-DNS, Java package-like name.
        Specified by:
        name in interface Driver
        Returns:
        driver name
      • manufacturer

        public String manufacturer()
        Description copied from interface: Driver
        Returns the device manufacturer name.
        Specified by:
        manufacturer in interface Driver
        Returns:
        manufacturer name
      • hwVersion

        public String hwVersion()
        Description copied from interface: Driver
        Returns the device hardware version.
        Specified by:
        hwVersion in interface Driver
        Returns:
        hardware version
      • swVersion

        public String swVersion()
        Description copied from interface: Driver
        Returns the device software version.
        Specified by:
        swVersion in interface Driver
        Returns:
        software version
      • parent

        public Driver parent()
        Description copied from interface: Driver
        Returns the parent driver from which this driver inherits behaviours and properties.
        Specified by:
        parent in interface Driver
        Returns:
        parent driver; null if driver has no parent
      • parents

        public List<Driver> parents()
        Description copied from interface: Driver
        Returns all the parent drivers from which this driver inherits behaviours and properties.
        Specified by:
        parents in interface Driver
        Returns:
        list of parent drivers
      • behaviours

        public Set<Class<? extends Behaviour>> behaviours()
        Description copied from interface: Driver
        Returns the set of behaviours supported by this driver. It reflects behaviours of only this driver and not its parent.
        Specified by:
        behaviours in interface Driver
        Returns:
        set of device driver behaviours
      • implementation

        public Class<? extends Behaviour> implementation​(Class<? extends Behaviour> behaviour)
        Description copied from interface: Driver
        Returns the implementation class for the specified behaviour. It reflects behaviours of only this driver and not its parent.
        Specified by:
        implementation in interface Driver
        Parameters:
        behaviour - behaviour interface
        Returns:
        implementation class
      • hasBehaviour

        public boolean hasBehaviour​(Class<? extends Behaviour> behaviourClass)
        Description copied from interface: Driver
        Indicates whether or not the driver, or any of its parents, support the specified class of behaviour.
        Specified by:
        hasBehaviour in interface Driver
        Parameters:
        behaviourClass - behaviour class
        Returns:
        true if behaviour is supported
      • createBehaviour

        public <T extends Behaviour> T createBehaviour​(DriverData data,
                                                       Class<T> behaviourClass)
        Description copied from interface: Driver
        Creates an instance of behaviour primed with the specified driver data. If the current driver does not support the specified behaviour and the driver has parent, the request is delegated to the parent driver.
        Specified by:
        createBehaviour in interface Driver
        Type Parameters:
        T - type of behaviour
        Parameters:
        data - driver data context
        behaviourClass - driver behaviour class
        Returns:
        behaviour instance
      • createBehaviour

        public <T extends Behaviour> T createBehaviour​(DriverHandler handler,
                                                       Class<T> behaviourClass)
        Description copied from interface: Driver
        Creates an instance of behaviour primed with the specified driver handler. If the current driver does not support the specified behaviour and the driver has parent, the request is delegated to the parent driver.
        Specified by:
        createBehaviour in interface Driver
        Type Parameters:
        T - type of behaviour
        Parameters:
        handler - driver handler context
        behaviourClass - driver behaviour class
        Returns:
        behaviour instance
      • keys

        public Set<String> keys()
        Description copied from interface: Annotations
        Returns the set of keys for available annotations.
        Specified by:
        keys in interface Annotations
        Returns:
        annotation keys
      • value

        public String value​(String key)
        Description copied from interface: Annotations
        Returns the value of the specified annotation.
        Specified by:
        value in interface Annotations
        Parameters:
        key - annotation key
        Returns:
        annotation value
      • properties

        public Map<String,​String> properties()
        Description copied from interface: Driver
        Returns the set of annotations as map of key/value properties.
        Specified by:
        properties in interface Driver
        Returns:
        map of properties
      • getProperty

        public String getProperty​(String name)
        Description copied from interface: Driver
        Gets the value of given property name. If the driver does not define the property, a BFS will be performed to search its ancestors.
        Specified by:
        getProperty in interface Driver
        Parameters:
        name - property name
        Returns:
        the value of the property, or null if the property is not defined in this driver nor in any of its ancestors
      • equals

        public boolean equals​(Object driverToBeCompared)
        Overrides:
        equals in class Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object