gpt4 book ai didi

org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.of()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-17 16:30:40 27 4
gpt4 key购买 nike

本文整理了Java中org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.of()方法的一些代码示例,展示了YangInstanceIdentifier.of()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YangInstanceIdentifier.of()方法的具体详情如下:
包路径:org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier
类名称:YangInstanceIdentifier
方法名:of

YangInstanceIdentifier.of介绍

[英]Returns a new InstanceIdentifier with only one path argument of type NodeIdentifier with supplied QName.
[中]返回一个新的InstanceIdentifier,该InstanceIdentifier只包含一个带有QName的NodeIdentifier类型的路径参数。

代码示例

代码示例来源:origin: io.fd.honeycomb.infra/test-tools

static YangInstanceIdentifier getRootInstanceIdentifier(final Class type) {
  try {
    return YangInstanceIdentifier.of(QName.class.cast(type.getField("QNAME").get(null)));
  } catch (IllegalAccessException e) {
    throw new IllegalStateException("Constant QNAME not accessible for type" + type, e);
  } catch (NoSuchFieldException e) {
    throw new IllegalStateException("Class " + type + " does not have QName defined", e);
  }
}

代码示例来源:origin: io.fd.honeycomb.infra/test-tools

@Nonnull
@Override
public DataObject getNodeData(@Nonnull YangInstanceIdentifier yangInstanceIdentifier, @Nonnull String resourcePath) {
  final InputStream resourceStream = this.getClass().getResourceAsStream(resourcePath);
  checkState(resourceStream != null, "Resource %s not found", resourcePath);
  final YangInstanceIdentifier nodeParent = getNodeParent(yangInstanceIdentifier).orElse(null);
  final SchemaNode parentSchema = parentSchema(schemaContext(), serializer(), nodeParent, LOG);
  // to be able to process containers in root of model
  if (isRoot(yangInstanceIdentifier)) {
    // if root ,read as root
    final ContainerNode data = readJson(schemaContext(), resourceStream, parentSchema);
    checkState(data.getValue().size() == 1, "Single root expected in %s", resourcePath);
    //then extracts first child
    final QName rootNodeType = data.getValue().iterator().next().getNodeType();
    final YangInstanceIdentifier realIdentifier = YangInstanceIdentifier.of(rootNodeType);
    return nodeBinding(serializer(), realIdentifier, data).getValue();
  } else {
    // reads just container
    final YangInstanceIdentifier.NodeIdentifier nodeIdentifier = containerNodeIdentifier(yangInstanceIdentifier);
    final ContainerNode data = readContainerEntryJson(schemaContext(), resourceStream, parentSchema, nodeIdentifier);
    return nodeBinding(serializer(), yangInstanceIdentifier, data.getValue().iterator().next()).getValue();
  }
}

代码示例来源:origin: org.opendaylight.controller/sal-broker-impl

private static AbstractDOMRpcRoutingTableEntry createRpcEntry(final SchemaContext context, final SchemaPath key, final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> implementations) {
  final RpcDefinition rpcDef = findRpcDefinition(context, key);
  if (rpcDef != null) {
    final ContainerSchemaNode input = rpcDef.getInput();
    if (input != null) {
      for (DataSchemaNode c : input.getChildNodes()) {
        for (UnknownSchemaNode extension : c.getUnknownSchemaNodes()) {
          if (CONTEXT_REFERENCE.equals(extension.getNodeType())) {
            final YangInstanceIdentifier keyId = YangInstanceIdentifier.of(c.getQName());
            return new RoutedDOMRpcRoutingTableEntry(rpcDef, keyId, implementations);
          }
        }
      }
    }
    return new GlobalDOMRpcRoutingTableEntry(rpcDef, implementations);
  } else {
    return new UnknownDOMRpcRoutingTableEntry(key, implementations);
  }
}

代码示例来源:origin: org.opendaylight.bgpcep/bgp-bmp-impl

private void createEmptyMonitor() {
  final DOMDataWriteTransaction wTx = this.domDataBroker.newWriteOnlyTransaction();
  ensureParentExists(wTx, YangInstanceIdentifier.of(BmpMonitor.QNAME));
  wTx.put(LogicalDatastoreType.OPERATIONAL,
      YangInstanceIdentifier.builder().node(BmpMonitor.QNAME).node(Monitor.QNAME)
        .nodeWithKey(Monitor.QNAME, MONITOR_ID_QNAME, this.monitorId.getValue()).build(),
      ImmutableNodes.mapEntryBuilder(Monitor.QNAME, MONITOR_ID_QNAME, this.monitorId.getValue())
        .addChild(ImmutableNodes.leafNode(MONITOR_ID_QNAME, this.monitorId.getValue()))
        .addChild(ImmutableNodes.mapNodeBuilder(Router.QNAME).build())
        .build());
  try {
    wTx.submit().checkedGet();
  } catch (final TransactionCommitFailedException e) {
    LOG.error("Failed to initiate BMP Monitor {}.", this.monitorId.getValue(), e);
  }
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com