Package org.onosproject.net
Class AbstractProjectableModel
- java.lang.Object
-
- org.onosproject.net.AbstractAnnotated
-
- org.onosproject.net.AbstractModel
-
- org.onosproject.net.AbstractProjectableModel
-
- All Implemented Interfaces:
Annotated,Projectable,Provided
- Direct Known Subclasses:
AbstractElement,DefaultLink
@Beta public abstract class AbstractProjectableModel extends AbstractModel implements Projectable
Base model entity, capable of being extended via projection mechanism.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classAbstractProjectableModel.AnnotationDriverDataProjection of the parent entity as a driver data entity.
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.StringNO_DRIVERprotected static java.lang.StringNO_DRIVER_SERVICE
-
Constructor Summary
Constructors Constructor Description AbstractProjectableModel()AbstractProjectableModel(ProviderId providerId, Annotations[] annotations)Creates a model entity attributed to the specified provider and optionally annotated.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <B extends Behaviour>
Bas(java.lang.Class<B> projectionClass)Returns the specified projection of this entity if such projection is supported.protected DriverDataasData()Returns self as an immutable driver data instance.protected voidbindAndCheckDriver()Attempts to bind the driver, if not already bound and checks that the driver is bound.protected voidbindDriver()Attempts to binds the driver, if not already bound.Driverdriver()Returns the currently bound driver or null if no driver is bound.protected static DriverServicedriverService()Returns the currently bound driver service reference.<B extends Behaviour>
booleanis(java.lang.Class<B> projectionClass)Returns true if this entity is capable of being projected as the specified class.protected DriverlocateDriver()Locates the driver to be used by this entity.static voidsetDriverService(java.lang.Object key, DriverService driverService)Injects the driver service reference for use during projections into various behaviours.-
Methods inherited from class org.onosproject.net.AbstractModel
providerId
-
Methods inherited from class org.onosproject.net.AbstractAnnotated
annotations
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.onosproject.net.driver.Projectable
project
-
-
-
-
Field Detail
-
NO_DRIVER_SERVICE
protected static final java.lang.String NO_DRIVER_SERVICE
- See Also:
- Constant Field Values
-
NO_DRIVER
protected static final java.lang.String NO_DRIVER
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractProjectableModel
public AbstractProjectableModel()
-
AbstractProjectableModel
public AbstractProjectableModel(ProviderId providerId, Annotations[] annotations)
Creates a model entity attributed to the specified provider and optionally annotated.- Parameters:
providerId- identity of the providerannotations- optional key/value annotations
-
-
Method Detail
-
setDriverService
public static void setDriverService(java.lang.Object key, DriverService driverService)Injects the driver service reference for use during projections into various behaviours.This is a privileged call; unauthorized invocations will result in illegal state exception
- Parameters:
key- opaque admin key objectdriverService- injected driver service- Throws:
java.lang.IllegalStateException- when invoked sans authorization
-
driverService
protected static DriverService driverService()
Returns the currently bound driver service reference.- Returns:
- driver service
-
driver
public Driver driver()
Returns the currently bound driver or null if no driver is bound.- Returns:
- bound driver; null if none
-
as
public <B extends Behaviour> B as(java.lang.Class<B> projectionClass)
Description copied from interface:ProjectableReturns the specified projection of this entity if such projection is supported.- Specified by:
asin interfaceProjectable- Type Parameters:
B- type of behaviour- Parameters:
projectionClass- requested projection class- Returns:
- projection instance
-
is
public <B extends Behaviour> boolean is(java.lang.Class<B> projectionClass)
Description copied from interface:ProjectableReturns true if this entity is capable of being projected as the specified class.- Specified by:
isin interfaceProjectable- Type Parameters:
B- type of behaviour- Parameters:
projectionClass- requested projection class- Returns:
- true if the requested projection is supported
-
locateDriver
protected Driver locateDriver()
Locates the driver to be used by this entity.The default implementation derives the driver based on the
driverannotation value.- Returns:
- driver for alternate projections of this model entity or null if no driver is expected or driver is not found
-
bindDriver
protected final void bindDriver()
Attempts to binds the driver, if not already bound.
-
bindAndCheckDriver
protected final void bindAndCheckDriver()
Attempts to bind the driver, if not already bound and checks that the driver is bound.- Throws:
java.lang.IllegalStateException- if driver cannot be bound
-
asData
protected DriverData asData()
Returns self as an immutable driver data instance.- Returns:
- self as driver data
-
-