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.booleanequals(java.lang.Object driverToBeCompared)java.lang.StringgetProperty(java.lang.String name)Gets the value of given property name.booleanhasBehaviour(java.lang.Class<? extends Behaviour> behaviourClass)Indicates whether or not the driver, or any of its parents, support the specified class of behaviour.inthashCode()java.lang.StringhwVersion()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.Stringmanufacturer()Returns the device manufacturer name.Drivermerge(Driver other)Merges the specified driver behaviours and properties into this one, giving preference to the other driver when dealing with conflicts.java.lang.Stringname()Returns the driver name.Driverparent()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.StringswVersion()Returns the device software version.java.lang.StringtoString()java.lang.Stringvalue(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:DriverMerges 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:DriverReturns 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:DriverReturns the device manufacturer name.- Specified by:
manufacturerin interfaceDriver- Returns:
- manufacturer name
-
hwVersion
public java.lang.String hwVersion()
Description copied from interface:DriverReturns the device hardware version.
-
swVersion
public java.lang.String swVersion()
Description copied from interface:DriverReturns the device software version.
-
parent
public Driver parent()
Description copied from interface:DriverReturns the parent driver from which this driver inherits behaviours and properties.
-
parents
public java.util.List<Driver> parents()
Description copied from interface:DriverReturns 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:DriverReturns the set of behaviours supported by this driver. It reflects behaviours of only this driver and not its parent.- Specified by:
behavioursin 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:DriverReturns the implementation class for the specified behaviour. It reflects behaviours of only this driver and not its parent.- Specified by:
implementationin interfaceDriver- Parameters:
behaviour- behaviour interface- Returns:
- implementation class
-
hasBehaviour
public boolean hasBehaviour(java.lang.Class<? extends Behaviour> behaviourClass)
Description copied from interface:DriverIndicates whether or not the driver, or any of its parents, support the specified class of behaviour.- Specified by:
hasBehaviourin 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:DriverCreates 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:
createBehaviourin 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:DriverCreates 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:
createBehaviourin 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:AnnotationsReturns the set of keys for available annotations.- Specified by:
keysin interfaceAnnotations- Returns:
- annotation keys
-
value
public java.lang.String value(java.lang.String key)
Description copied from interface:AnnotationsReturns the value of the specified annotation.- Specified by:
valuein interfaceAnnotations- Parameters:
key- annotation key- Returns:
- annotation value
-
properties
public java.util.Map<java.lang.String,java.lang.String> properties()
Description copied from interface:DriverReturns the set of annotations as map of key/value properties.- Specified by:
propertiesin interfaceDriver- Returns:
- map of properties
-
getProperty
public java.lang.String getProperty(java.lang.String name)
Description copied from interface:DriverGets 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:
getPropertyin 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:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object driverToBeCompared)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-