Class AbstractTranscriberInterface<T extends org.opendaylight.yangtools.yang.binding.DataObject & org.opendaylight.yangtools.yang.binding.Identifiable<K> & org.opendaylight.yangtools.yang.binding.ChildOf<? super U>,U extends org.opendaylight.yangtools.yang.binding.ChildOf<? super V> & org.opendaylight.yangtools.yang.binding.Augmentable<U>,K extends org.opendaylight.yangtools.yang.binding.Identifier<T>,S extends INeutronObject<S>,V extends org.opendaylight.yangtools.yang.binding.DataObject>
- java.lang.Object
-
- org.opendaylight.neutron.transcriber.AbstractTranscriberInterface<T,U,K,S,V>
-
- Type Parameters:
T
- Target yang modelU
- parent of TK
- key type to indentify TS
- Neutron-spi classV
- parent of U
- All Implemented Interfaces:
AutoCloseable
,INeutronCRUD<S>
- Direct Known Subclasses:
AbstractNeutronInterface
,NeutronTapFlowInterface
public abstract class AbstractTranscriberInterface<T extends org.opendaylight.yangtools.yang.binding.DataObject & org.opendaylight.yangtools.yang.binding.Identifiable<K> & org.opendaylight.yangtools.yang.binding.ChildOf<? super U>,U extends org.opendaylight.yangtools.yang.binding.ChildOf<? super V> & org.opendaylight.yangtools.yang.binding.Augmentable<U>,K extends org.opendaylight.yangtools.yang.binding.Identifier<T>,S extends INeutronObject<S>,V extends org.opendaylight.yangtools.yang.binding.DataObject> extends Object implements AutoCloseable, INeutronCRUD<S>
Base class of Transcriber converts data from/to neutron spi to/from md-sal yang model.V -> U -> T K: key T(MD-SAL model) <-> S (neutron spi): Neutron northbound -> fromMd() <- toMd()
Example T: Port U: Ports K: PortKey S: NeutronPort V: Neutron
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.opendaylight.neutron.spi.INeutronCRUD
INeutronCRUD.Result
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractTranscriberInterface(Class<? extends org.opendaylight.yangtools.concepts.Builder<T>> builderClass, org.opendaylight.mdsal.binding.api.DataBroker db)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description INeutronCRUD.Result
add(S input)
Applications call this interface method to add a Neutron object to the concurrent map.protected boolean
areAllDependenciesAvailable(org.opendaylight.mdsal.binding.api.ReadOperations tx, S neutronObject)
Check if this particular (subclass) transcriber's dependencies are met.protected static void
checkedCommit(org.opendaylight.mdsal.binding.api.WriteTransaction tx)
void
close()
boolean
exists(String uuid, org.opendaylight.mdsal.binding.api.ReadOperations tx)
Applications call this interface method to determine if a particular Neutron object exists.protected abstract S
fromMd(T dataObject)
protected <M extends AdminAttributes,S1 extends INeutronAdminAttributes<S1>>
voidfromMdAdminAttributes(M attr, S1 answer)
protected <S1 extends INeutronBaseAttributes<S1>>
voidfromMdBaseAttributes(BaseAttributes baseAttributes, S1 answer)
protected <S1 extends INeutronObject<S1>>
voidfromMdIds(IdAttributes idAttributes, INeutronObject<S1> answer)
S
get(String uuid)
Applications call this interface method to return if a particular Neutron object exists.List<S>
getAll()
Applications call this interface method to return all Neutron objects.@NonNull org.opendaylight.mdsal.binding.api.DataBroker
getDataBroker()
protected abstract Collection<T>
getDataObjectList(U dataObjects)
protected Class<V>
getMdParentClass(Type[] types)
protected static <X> boolean
ifNonNull(@Nullable X property, org.opendaylight.infrautils.utils.function.CheckedFunction<@NonNull X,@NonNull Boolean,org.opendaylight.mdsal.common.api.ReadFailedException> function)
Utility to perform well readable code of null-safe chains of e.g.protected <W extends org.opendaylight.yangtools.yang.binding.DataObject>
WreadMd(org.opendaylight.yangtools.yang.binding.InstanceIdentifier<W> path)
boolean
remove(String uuid)
Applications call this interface method to remove a Neutron object to the concurrent map.protected T
toMd(String uuid)
protected abstract T
toMd(S neutronObject)
protected <S1 extends INeutronAdminAttributes<S1>,M extends AdminAttributes,B extends org.opendaylight.yangtools.concepts.Builder<M>>
voidtoMdAdminAttributes(S1 neutronObject, B builder)
protected <S1 extends INeutronBaseAttributes<S1>,M extends BaseAttributes,B extends org.opendaylight.yangtools.concepts.Builder<M>>
voidtoMdBaseAttributes(S1 neutronObject, B builder)
protected <S1 extends INeutronObject<S1>,M extends IdAttributes,B extends org.opendaylight.yangtools.concepts.Builder<M>>
voidtoMdIds(INeutronObject<S1> neutronObject, B builder)
protected static <S1 extends INeutronObject<S1>,M extends IdAttributes,B extends org.opendaylight.yangtools.concepts.Builder<M>>
BtoMdIds(INeutronObject<S1> neutronObject, Class<B> builderClass)
protected static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid
toUuid(String uuid)
INeutronCRUD.Result
update(String uuid, S delta)
Applications call this interface method to edit a Neutron object.
-
-
-
Method Detail
-
getDataBroker
public @NonNull org.opendaylight.mdsal.binding.api.DataBroker getDataBroker()
-
toMdIds
protected static <S1 extends INeutronObject<S1>,M extends IdAttributes,B extends org.opendaylight.yangtools.concepts.Builder<M>> B toMdIds(INeutronObject<S1> neutronObject, Class<B> builderClass)
-
toMdIds
protected <S1 extends INeutronObject<S1>,M extends IdAttributes,B extends org.opendaylight.yangtools.concepts.Builder<M>> void toMdIds(INeutronObject<S1> neutronObject, B builder)
-
fromMdIds
protected <S1 extends INeutronObject<S1>> void fromMdIds(IdAttributes idAttributes, INeutronObject<S1> answer)
-
toMdBaseAttributes
protected <S1 extends INeutronBaseAttributes<S1>,M extends BaseAttributes,B extends org.opendaylight.yangtools.concepts.Builder<M>> void toMdBaseAttributes(S1 neutronObject, B builder)
-
fromMdBaseAttributes
protected <S1 extends INeutronBaseAttributes<S1>> void fromMdBaseAttributes(BaseAttributes baseAttributes, S1 answer)
-
toMdAdminAttributes
protected <S1 extends INeutronAdminAttributes<S1>,M extends AdminAttributes,B extends org.opendaylight.yangtools.concepts.Builder<M>> void toMdAdminAttributes(S1 neutronObject, B builder)
-
fromMdAdminAttributes
protected <M extends AdminAttributes,S1 extends INeutronAdminAttributes<S1>> void fromMdAdminAttributes(M attr, S1 answer)
-
readMd
protected <W extends org.opendaylight.yangtools.yang.binding.DataObject> W readMd(org.opendaylight.yangtools.yang.binding.InstanceIdentifier<W> path) throws org.opendaylight.mdsal.common.api.ReadFailedException
- Throws:
org.opendaylight.mdsal.common.api.ReadFailedException
-
toUuid
protected static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid toUuid(String uuid)
-
close
@PreDestroy public void close() throws Exception
- Specified by:
close
in interfaceAutoCloseable
- Throws:
Exception
-
exists
public boolean exists(String uuid, org.opendaylight.mdsal.binding.api.ReadOperations tx) throws org.opendaylight.mdsal.common.api.ReadFailedException
Description copied from interface:INeutronCRUD
Applications call this interface method to determine if a particular Neutron object exists.- Specified by:
exists
in interfaceINeutronCRUD<T extends org.opendaylight.yangtools.yang.binding.DataObject & org.opendaylight.yangtools.yang.binding.Identifiable<K> & org.opendaylight.yangtools.yang.binding.ChildOf<? super U>>
- Parameters:
uuid
- UUID of the Neutron objecttx
- the ReadTransaction within which to perform the check- Returns:
- boolean
- Throws:
org.opendaylight.mdsal.common.api.ReadFailedException
- if the read failed
-
get
public S get(String uuid) throws org.opendaylight.mdsal.common.api.ReadFailedException
Description copied from interface:INeutronCRUD
Applications call this interface method to return if a particular Neutron object exists.- Specified by:
get
in interfaceINeutronCRUD<T extends org.opendaylight.yangtools.yang.binding.DataObject & org.opendaylight.yangtools.yang.binding.Identifiable<K> & org.opendaylight.yangtools.yang.binding.ChildOf<? super U>>
- Parameters:
uuid
- UUID of the Neutron object- Returns:
INeutronObject
OpenStack Neutron class- Throws:
org.opendaylight.mdsal.common.api.ReadFailedException
- if the read failed
-
getDataObjectList
protected abstract Collection<T> getDataObjectList(U dataObjects)
-
getAll
public List<S> getAll() throws ReadFailedRuntimeException
Description copied from interface:INeutronCRUD
Applications call this interface method to return all Neutron objects.- Specified by:
getAll
in interfaceINeutronCRUD<T extends org.opendaylight.yangtools.yang.binding.DataObject & org.opendaylight.yangtools.yang.binding.Identifiable<K> & org.opendaylight.yangtools.yang.binding.ChildOf<? super U>>
- Returns:
- List of OpenStackNeutrons objects
- Throws:
ReadFailedRuntimeException
- if the read failed
-
add
public INeutronCRUD.Result add(S input) throws org.opendaylight.yangtools.yang.common.OperationFailedException
Description copied from interface:INeutronCRUD
Applications call this interface method to add a Neutron object to the concurrent map.- Specified by:
add
in interfaceINeutronCRUD<T extends org.opendaylight.yangtools.yang.binding.DataObject & org.opendaylight.yangtools.yang.binding.Identifiable<K> & org.opendaylight.yangtools.yang.binding.ChildOf<? super U>>
- Parameters:
input
- OpenStackNeutron object- Returns:
- result with indication on whether the object was added or not and if so why
- Throws:
org.opendaylight.yangtools.yang.common.OperationFailedException
- if the write (or a required implicit read) failed
-
remove
public boolean remove(String uuid) throws org.opendaylight.yangtools.yang.common.OperationFailedException
Description copied from interface:INeutronCRUD
Applications call this interface method to remove a Neutron object to the concurrent map.- Specified by:
remove
in interfaceINeutronCRUD<T extends org.opendaylight.yangtools.yang.binding.DataObject & org.opendaylight.yangtools.yang.binding.Identifiable<K> & org.opendaylight.yangtools.yang.binding.ChildOf<? super U>>
- Parameters:
uuid
- identifier for the neutron object- Returns:
- boolean on whether the object was removed or not
- Throws:
org.opendaylight.yangtools.yang.common.OperationFailedException
- if the remove (or a required implicit read) failed
-
update
public INeutronCRUD.Result update(String uuid, S delta) throws org.opendaylight.yangtools.yang.common.OperationFailedException
Description copied from interface:INeutronCRUD
Applications call this interface method to edit a Neutron object.- Specified by:
update
in interfaceINeutronCRUD<T extends org.opendaylight.yangtools.yang.binding.DataObject & org.opendaylight.yangtools.yang.binding.Identifiable<K> & org.opendaylight.yangtools.yang.binding.ChildOf<? super U>>
- Parameters:
uuid
- identifier of the neutron objectdelta
- OpenStackNeutron object containing changes to apply- Returns:
- boolean on whether the object was updated or not
- Throws:
org.opendaylight.yangtools.yang.common.OperationFailedException
- if the update (or a required implicit read) failed
-
areAllDependenciesAvailable
protected boolean areAllDependenciesAvailable(org.opendaylight.mdsal.binding.api.ReadOperations tx, S neutronObject) throws org.opendaylight.mdsal.common.api.ReadFailedException
Check if this particular (subclass) transcriber's dependencies are met. Default implementation just returns true. Some but not all transcribers will customize this.Implementations *MUST* use the passed in transaction. They will typically call the
exists(String, ReadOperations)
method on ANOTHER transcriber with it.Implementations should chain
ifNonNull(Object, CheckedFunction)
, or perform null safe comparisons otherwise, for both optional non-mandatoryNeutronObject
as well as mandatory properties which may well be null. Both must mandatory and non-mandatory must be guarded, because modify (update) operation are allowed to contain partial neutron objects with missing fields.- Parameters:
tx
- the transaction within which to perform reads to check for dependenciesneutronObject
- the incoming main neutron object in which there may be references to dependencies- Returns:
- true if all dependencies are available and the
add(INeutronObject)
(orupdate(String, INeutronObject)
operation can proceed; false if there are unmet dependencies, which will cause the add to abort, and a respective error code returned to the caller. - Throws:
org.opendaylight.mdsal.common.api.ReadFailedException
- in case of a data store problem
-
ifNonNull
protected static final <X> boolean ifNonNull(@Nullable X property, org.opendaylight.infrautils.utils.function.CheckedFunction<@NonNull X,@NonNull Boolean,org.opendaylight.mdsal.common.api.ReadFailedException> function) throws org.opendaylight.mdsal.common.api.ReadFailedException
Utility to perform well readable code of null-safe chains of e.g.exists(String, ReadOperations)
method calls.- Throws:
org.opendaylight.mdsal.common.api.ReadFailedException
- in case of a data store problem
-
checkedCommit
protected static final void checkedCommit(org.opendaylight.mdsal.binding.api.WriteTransaction tx) throws org.opendaylight.mdsal.common.api.TransactionCommitFailedException
- Throws:
org.opendaylight.mdsal.common.api.TransactionCommitFailedException
-
-