Package org.onosproject.net.driver
Class DefaultDriver
- java.lang.Object
-
- org.onosproject.net.driver.DefaultDriver
-
- All Implemented Interfaces:
Annotations
,Driver
public class DefaultDriver extends java.lang.Object implements Driver
Default implementation of extensible driver.
-
-
Constructor Summary
Constructors Constructor Description DefaultDriver(java.lang.String name, java.util.List<Driver> parents, java.lang.String manufacturer, java.lang.String hwVersion, java.lang.String swVersion, java.util.Map<java.lang.Class<? extends Behaviour>,java.lang.Class<? extends Behaviour>> behaviours, java.util.Map<java.lang.String,java.lang.String> properties)
Creates a driver with the specified name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Set<java.lang.Class<? extends Behaviour>>
behaviours()
Returns the set of behaviours supported by this driver.<T extends Behaviour>
TcreateBehaviour(DriverData data, java.lang.Class<T> behaviourClass)
Creates an instance of behaviour primed with the specified driver data.<T extends Behaviour>
TcreateBehaviour(DriverHandler handler, java.lang.Class<T> behaviourClass)
Creates an instance of behaviour primed with the specified driver handler.boolean
equals(java.lang.Object driverToBeCompared)
java.lang.String
getProperty(java.lang.String name)
Gets the value of given property name.boolean
hasBehaviour(java.lang.Class<? extends Behaviour> behaviourClass)
Indicates whether or not the driver, or any of its parents, support the specified class of behaviour.int
hashCode()
java.lang.String
hwVersion()
Returns the device hardware version.java.lang.Class<? extends Behaviour>
implementation(java.lang.Class<? extends Behaviour> behaviour)
Returns the implementation class for the specified behaviour.java.util.Set<java.lang.String>
keys()
Returns the set of keys for available annotations.java.lang.String
manufacturer()
Returns the device manufacturer name.Driver
merge(Driver other)
Merges the specified driver behaviours and properties into this one, giving preference to the other driver when dealing with conflicts.java.lang.String
name()
Returns the driver name.Driver
parent()
Returns the parent driver from which this driver inherits behaviours and properties.java.util.List<Driver>
parents()
Returns all the parent drivers from which this driver inherits behaviours and properties.java.util.Map<java.lang.String,java.lang.String>
properties()
Returns the set of annotations as map of key/value properties.java.lang.String
swVersion()
Returns the device software version.java.lang.String
toString()
java.lang.String
value(java.lang.String key)
Returns the value of the specified annotation.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.onosproject.net.driver.Driver
getProperty
-
-
-
-
Constructor Detail
-
DefaultDriver
public DefaultDriver(java.lang.String name, java.util.List<Driver> parents, java.lang.String manufacturer, java.lang.String hwVersion, java.lang.String swVersion, java.util.Map<java.lang.Class<? extends Behaviour>,java.lang.Class<? extends Behaviour>> behaviours, java.util.Map<java.lang.String,java.lang.String> properties)
Creates a driver with the specified name.- Parameters:
name
- driver nameparents
- optional parent driversmanufacturer
- device manufacturerhwVersion
- device hardware versionswVersion
- device software versionbehaviours
- device behaviour classesproperties
- 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.
-
name
public java.lang.String name()
Description copied from interface:Driver
Returns the driver name. This is expected to be a reverse-DNS, Java package-like name.
-
manufacturer
public java.lang.String manufacturer()
Description copied from interface:Driver
Returns the device manufacturer name.- Specified by:
manufacturer
in interfaceDriver
- Returns:
- manufacturer name
-
hwVersion
public java.lang.String hwVersion()
Description copied from interface:Driver
Returns the device hardware version.
-
swVersion
public java.lang.String swVersion()
Description copied from interface:Driver
Returns the device software version.
-
parent
public Driver parent()
Description copied from interface:Driver
Returns the parent driver from which this driver inherits behaviours and properties.
-
parents
public java.util.List<Driver> parents()
Description copied from interface:Driver
Returns all the parent drivers from which this driver inherits behaviours and properties.
-
behaviours
public java.util.Set<java.lang.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 interfaceDriver
- Returns:
- set of device driver behaviours
-
implementation
public java.lang.Class<? extends Behaviour> implementation(java.lang.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 interfaceDriver
- Parameters:
behaviour
- behaviour interface- Returns:
- implementation class
-
hasBehaviour
public boolean hasBehaviour(java.lang.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 interfaceDriver
- Parameters:
behaviourClass
- behaviour class- Returns:
- true if behaviour is supported
-
createBehaviour
public <T extends Behaviour> T createBehaviour(DriverData data, java.lang.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 interfaceDriver
- Type Parameters:
T
- type of behaviour- Parameters:
data
- driver data contextbehaviourClass
- driver behaviour class- Returns:
- behaviour instance
-
createBehaviour
public <T extends Behaviour> T createBehaviour(DriverHandler handler, java.lang.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 interfaceDriver
- Type Parameters:
T
- type of behaviour- Parameters:
handler
- driver handler contextbehaviourClass
- driver behaviour class- Returns:
- behaviour instance
-
keys
public java.util.Set<java.lang.String> keys()
Description copied from interface:Annotations
Returns the set of keys for available annotations.- Specified by:
keys
in interfaceAnnotations
- Returns:
- annotation keys
-
value
public java.lang.String value(java.lang.String key)
Description copied from interface:Annotations
Returns the value of the specified annotation.- Specified by:
value
in interfaceAnnotations
- Parameters:
key
- annotation key- Returns:
- annotation value
-
properties
public java.util.Map<java.lang.String,java.lang.String> properties()
Description copied from interface:Driver
Returns the set of annotations as map of key/value properties.- Specified by:
properties
in interfaceDriver
- Returns:
- map of properties
-
getProperty
public java.lang.String getProperty(java.lang.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 interfaceDriver
- 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
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object driverToBeCompared)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-