Search in sources :

Example 1 with BindingDataObjectCodecTreeNode

use of org.opendaylight.mdsal.binding.dom.codec.api.BindingDataObjectCodecTreeNode in project bgpcep by opendaylight.

the class CodecsImpl method onCodecTreeUpdated.

@Override
@SuppressWarnings("unchecked")
public void onCodecTreeUpdated(final BindingCodecTree tree) {
    @SuppressWarnings("rawtypes") final BindingDataObjectCodecTreeNode tableCodecContext = tree.getSubtreeCodec(TABLE_BASE_II);
    final BindingDataObjectCodecTreeNode<? extends Route> routeListCodec = tableCodecContext.streamChild(Routes.class).streamChild(this.ribSupport.routesCaseClass()).streamChild(this.ribSupport.routesContainerClass()).streamChild(this.ribSupport.routesListClass());
    this.attributesCodec = routeListCodec.streamChild(Attributes.class).createCachingCodec(this.cacheableAttributes);
    this.reachNlriCodec = tree.getSubtreeCodec(MP_REACH_NLRI_II).createCachingCodec(this.ribSupport.cacheableNlriObjects());
    this.unreachNlriCodec = tree.getSubtreeCodec(MP_UNREACH_NLRI_II).createCachingCodec(this.ribSupport.cacheableNlriObjects());
}
Also used : BindingDataObjectCodecTreeNode(org.opendaylight.mdsal.binding.dom.codec.api.BindingDataObjectCodecTreeNode) Routes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes)

Example 2 with BindingDataObjectCodecTreeNode

use of org.opendaylight.mdsal.binding.dom.codec.api.BindingDataObjectCodecTreeNode in project mdsal by opendaylight.

the class LazyDataObjectModification method populateList.

private static void populateList(final List<LazyDataObjectModification<? extends DataObject>> result, final BindingDataObjectCodecTreeNode<?> parentCodec, final Collection<DataTreeCandidateNode> domChildNodes) {
    for (final DataTreeCandidateNode domChildNode : domChildNodes) {
        if (domChildNode.getModificationType() != UNMODIFIED) {
            final BindingStructuralType type = BindingStructuralType.from(domChildNode);
            if (type != BindingStructuralType.NOT_ADDRESSABLE) {
                /*
                     *  Even if type is UNKNOWN, from perspective of BindingStructuralType
                     *  we try to load codec for it. We will use that type to further specify
                     *  debug log.
                     */
                try {
                    final BindingCodecTreeNode childCodec = parentCodec.yangPathArgumentChild(domChildNode.getIdentifier());
                    verify(childCodec instanceof BindingDataObjectCodecTreeNode, "Unhandled codec %s for type %s", childCodec, type);
                    populateList(result, type, (BindingDataObjectCodecTreeNode<?>) childCodec, domChildNode);
                } catch (final IllegalArgumentException e) {
                    if (type == BindingStructuralType.UNKNOWN) {
                        LOG.debug("Unable to deserialize unknown DOM node {}", domChildNode, e);
                    } else {
                        LOG.debug("Binding representation for DOM node {} was not found", domChildNode, e);
                    }
                }
            }
        }
    }
}
Also used : BindingDataObjectCodecTreeNode(org.opendaylight.mdsal.binding.dom.codec.api.BindingDataObjectCodecTreeNode) DataTreeCandidateNode(org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode) BindingCodecTreeNode(org.opendaylight.mdsal.binding.dom.codec.api.BindingCodecTreeNode)

Example 3 with BindingDataObjectCodecTreeNode

use of org.opendaylight.mdsal.binding.dom.codec.api.BindingDataObjectCodecTreeNode in project mdsal by opendaylight.

the class DefaultQueryResult method loadItemCodec.

private BindingDataObjectCodecTreeNode<T> loadItemCodec(final YangInstanceIdentifier domPath) {
    final BindingCodecTreeNode codecNode = codec.getSubtreeCodec(domPath);
    if (!(codecNode instanceof BindingDataObjectCodecTreeNode)) {
        throw new VerifyException("Unexpected codec " + codecNode);
    }
    @SuppressWarnings("unchecked") final BindingDataObjectCodecTreeNode<T> ret = (BindingDataObjectCodecTreeNode<T>) codecNode;
    final Object witness = ITEM_CODEC.compareAndExchangeRelease(this, null, ret);
    return witness == null ? ret : (BindingDataObjectCodecTreeNode<T>) witness;
}
Also used : BindingDataObjectCodecTreeNode(org.opendaylight.mdsal.binding.dom.codec.api.BindingDataObjectCodecTreeNode) VerifyException(com.google.common.base.VerifyException) BindingCodecTreeNode(org.opendaylight.mdsal.binding.dom.codec.api.BindingCodecTreeNode) DataObject(org.opendaylight.yangtools.yang.binding.DataObject)

Aggregations

BindingDataObjectCodecTreeNode (org.opendaylight.mdsal.binding.dom.codec.api.BindingDataObjectCodecTreeNode)3 BindingCodecTreeNode (org.opendaylight.mdsal.binding.dom.codec.api.BindingCodecTreeNode)2 VerifyException (com.google.common.base.VerifyException)1 Routes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes)1 DataObject (org.opendaylight.yangtools.yang.binding.DataObject)1 DataTreeCandidateNode (org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode)1