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>

  • Type Parameters:
    T - Target yang model
    U - parent of T
    K - key type to indentify T
    S - Neutron-spi class
    V - 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

    • Constructor Detail

      • AbstractTranscriberInterface

        protected AbstractTranscriberInterface​(Class<? extends org.opendaylight.yangtools.concepts.Builder<T>> builderClass,
                                               org.opendaylight.mdsal.binding.api.DataBroker db)
    • Method Detail

      • getMdParentClass

        protected Class<V> getMdParentClass​(Type[] types)
      • getDataBroker

        public @NonNull org.opendaylight.mdsal.binding.api.DataBroker getDataBroker()
      • toMdIds

        protected <S1 extends INeutronObject<S1>,​M extends IdAttributes,​B extends org.opendaylight.yangtools.concepts.Builder<M>> void toMdIds​(INeutronObject<S1> neutronObject,
                                                                                                                                                           B builder)
      • toMdBaseAttributes

        protected <S1 extends INeutronBaseAttributes<S1>,​M extends BaseAttributes,​B extends org.opendaylight.yangtools.concepts.Builder<M>> void toMdBaseAttributes​(S1 neutronObject,
                                                                                                                                                                                B builder)
      • toMdAdminAttributes

        protected <S1 extends INeutronAdminAttributes<S1>,​M extends AdminAttributes,​B extends org.opendaylight.yangtools.concepts.Builder<M>> void toMdAdminAttributes​(S1 neutronObject,
                                                                                                                                                                                   B builder)
      • toMd

        protected abstract T toMd​(S neutronObject)
      • toMd

        protected T toMd​(String uuid)
      • fromMd

        protected abstract S fromMd​(T dataObject)
      • 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)
      • 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 interface INeutronCRUD<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
        tx - 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 interface INeutronCRUD<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 interface INeutronCRUD<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 interface INeutronCRUD<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 interface INeutronCRUD<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 interface INeutronCRUD<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 object
        delta - 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-mandatory NeutronObject 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 dependencies
        neutronObject - the incoming main neutron object in which there may be references to dependencies
        Returns:
        true if all dependencies are available and the add(INeutronObject) (or update(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