gpt4 book ai didi

org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier类的使用及代码示例

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

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

YangInstanceIdentifier介绍

[英]Unique identifier of a particular node instance in the data tree.

Java representation of YANG Built-in type instance-identifier, which conceptually is XPath expression minimized to uniquely identify element in data tree which conforms to constraints maintained by YANG Model, effectively this makes Instance Identifier a path to element in data tree.

Constraints put in YANG specification on instance-identifier allowed it to be effectively represented in Java and it's evaluation does not require full-blown XPath processor.

Path Arguments

Path to the node represented in instance identifier consists of PathArgument which carries necessary information to uniquely identify node on particular level in the subtree.

  • NodeIdentifier - Identifier of node, which has cardinality 0..1 in particular subtree in data tree.
  • NodeIdentifierWithPredicates - Identifier of node (list item), which has cardinality 0..n.
  • NodeWithValue - Identifier of instance leaf node or leaf-list node.
  • AugmentationIdentifier - Identifier of instance of augmentation node.
    [中]数据树中特定节点实例的唯一标识符。
    YANG内置类型instance-identifier的Java表示形式,在概念上是XPath表达式最小化,以唯一标识数据树中符合YANG模型维护的约束的元素,这实际上使实例标识符成为数据树中元素的路径。
    YANG规范中对实例标识符的约束允许它在Java中有效地表示,并且它的计算不需要完整的XPath处理器。
    ####路径参数
    实例标识符中表示的节点路径由PathArgument组成,PathArgument携带必要的信息,以便在子树的特定级别上唯一地标识节点。
    *NodeIdentifier——节点的标识符,在数据树的特定子树中具有基数0..1
    *NodeIdentifierWithPredicates——节点(列表项)的标识符,其基数为[$2$]。
    *NodeWithValue—实例leaf节点或leaf-list节点的标识符。
    *AugmentationIdentifier—augmentation节点实例的标识符。

代码示例

代码示例来源:origin: org.opendaylight.bgpcep/bgp-rib-spi

private static NodeIdentifierWithPredicates firstKeyOf(final YangInstanceIdentifier id, final Predicate<PathArgument> match) {
  final PathArgument ret = Iterables.find(id.getPathArguments(), match);
  Preconditions.checkArgument(ret instanceof NodeIdentifierWithPredicates, "Non-key peer identifier %s", ret);
  return (NodeIdentifierWithPredicates) ret;
}

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

AdjInTracker(final DOMDataTreeChangeService service, final RIBSupportContextRegistry registry, final DOMTransactionChain chain, final YangInstanceIdentifier peerIId,
    @Nonnull final PerTableTypeRouteCounter effectiveRibInRouteCounters, @Nonnull final PerTableTypeRouteCounter adjRibInRouteCounters) {
  this.registry = Preconditions.checkNotNull(registry);
  this.chain = Preconditions.checkNotNull(chain);
  this.peerIId = Preconditions.checkNotNull(peerIId);
  this.effRibTables = this.peerIId.node(EffectiveRibIn.QNAME).node(Tables.QNAME);
  this.effectiveRibInRouteCounters = Preconditions.checkNotNull(effectiveRibInRouteCounters);
  this.adjRibInRouteCounters = Preconditions.checkNotNull(adjRibInRouteCounters);
  final DOMDataTreeIdentifier treeId = new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, this.peerIId.node(AdjRibIn.QNAME).node(Tables.QNAME));
  LOG.debug("Registered Effective RIB on {}", this.peerIId);
  this.reg = service.registerDataTreeChangeListener(treeId, this);
}

代码示例来源:origin: org.opendaylight.yangtools/yang-data-api

/**
 * Returns a new InstanceIdentifier with only one path argument of type {@link NodeIdentifier} with supplied
 * QName.
 *
 * @param name QName of first node identifier
 * @return Instance Identifier with only one path argument of type {@link NodeIdentifier}
 */
public static YangInstanceIdentifier of(final QName name) {
  return create(new NodeIdentifier(name));
}

代码示例来源:origin: opendaylight/yangtools

@Override
boolean pathArgumentsEqual(final YangInstanceIdentifier other) {
  if (other instanceof StackedYangInstanceIdentifier) {
    final StackedYangInstanceIdentifier stacked = (StackedYangInstanceIdentifier) other;
    return pathArgument.equals(stacked.pathArgument) && parent.equals(stacked.parent);
  }
  return super.pathArgumentsEqual(other);
}

代码示例来源:origin: org.opendaylight.yangtools/yang-data-api

/**
 * Returns new builder for InstanceIdentifier with path arguments copied from original instance identifier.
 *
 * @param origin InstanceIdentifier from which path arguments are copied.
 * @return new builder for InstanceIdentifier with path arguments copied from original instance identifier.
 */
public static InstanceIdentifierBuilder builder(final YangInstanceIdentifier origin) {
  return new YangInstanceIdentifierBuilder(origin.getPathArguments(), origin.hashCode());
}

代码示例来源:origin: org.opendaylight.controller/sal-clustering-commons

@Override
public final void exit() {
  Preconditions.checkState(!current.isEmpty());
  current = Verify.verifyNotNull(current.getParent());
}

代码示例来源:origin: org.opendaylight.bgpcep/bgp-rib-spi

private static YangInstanceIdentifier firstIdentifierOf(final YangInstanceIdentifier id, final Predicate<PathArgument> match) {
  final int idx = Iterables.indexOf(id.getPathArguments(), match);
  Preconditions.checkArgument(idx != -1, "Failed to find %s in %s", match, id);
  // we want the element at index idx to be included in the list
  return YangInstanceIdentifier.create(Iterables.limit(id.getPathArguments(), idx + 1));
}

代码示例来源:origin: io.fd.honeycomb/data-impl

private static YangInstanceIdentifier childYangId(@Nonnull final YangInstanceIdentifier topLevelIdentifier,
                           @Nonnull final Map.Entry<YangInstanceIdentifier.PathArgument, DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?>> entry) {
    return YangInstanceIdentifier.builder(topLevelIdentifier)
        .node(entry.getKey()).build();
  }
}

代码示例来源:origin: org.opendaylight.netconf/mdsal-netconf-connector

private SchemaPath getSchemaPath(final YangInstanceIdentifier dataRoot) {
  return SchemaPath.create(Iterables.transform(dataRoot.getPathArguments(), PATH_ARG_TO_QNAME), dataRoot.equals(ROOT));
}

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

private static YangInstanceIdentifier.NodeIdentifierWithPredicates listNodeIdentifier(@Nonnull final YangInstanceIdentifier nodeIdentifier) {
    return java.util.Optional.ofNullable(nodeIdentifier.getLastPathArgument())
        .filter(pathArgument -> pathArgument instanceof YangInstanceIdentifier.NodeIdentifierWithPredicates)
        .map(YangInstanceIdentifier.NodeIdentifierWithPredicates.class::cast)
        .orElseThrow(() -> new IllegalArgumentException(
            String.format("Unable to create list node identifier from %s", nodeIdentifier)));
  }
}

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

private void installAdjRibInTables(final YangInstanceIdentifier newPeerPath, final TablesKey tableKey, final RIBSupportContext rs,
  final NodeIdentifierWithPredicates instanceIdentifierKey, final DOMDataWriteTransaction tx, final Builder<TablesKey, TableContext> tb) {
  // We will use table keys very often, make sure they are optimized
  final InstanceIdentifierBuilder idb = YangInstanceIdentifier.builder(newPeerPath.node(EMPTY_ADJRIBIN.getIdentifier()).node(TABLES));
  idb.nodeWithKey(instanceIdentifierKey.getNodeType(), instanceIdentifierKey.getKeyValues());
  final TableContext ctx = new TableContext(rs, idb.build());
  ctx.createEmptyTableStructure(tx);
  tx.merge(LogicalDatastoreType.OPERATIONAL, ctx.getTableId().node(Attributes.QNAME).node(ATTRIBUTES_UPTODATE_FALSE.getNodeType()), ATTRIBUTES_UPTODATE_FALSE);
  LOG.debug("Created table instance {}", ctx.getTableId());
  tb.put(tableKey, ctx);
}

代码示例来源:origin: org.opendaylight.controller/sal-distributed-datastore

private String getModuleName(final YangInstanceIdentifier path) {
    if (path.isEmpty()) {
      return UNKNOWN_MODULE_NAME;
    }

    String namespace = path.getPathArguments().iterator().next().getNodeType().getNamespace().toASCIIString();
    String moduleName = configuration.getModuleNameFromNameSpace(namespace);
    return moduleName != null ? moduleName : UNKNOWN_MODULE_NAME;
  }
}

代码示例来源:origin: org.opendaylight.controller/sal-distributed-datastore

public static String entityTypeFromEntityPath(YangInstanceIdentifier entityPath){
  YangInstanceIdentifier parent = entityPath;
  while(!parent.isEmpty()) {
    if (EntityType.QNAME.equals(parent.getLastPathArgument().getNodeType())) {
      YangInstanceIdentifier.NodeIdentifierWithPredicates entityTypeLastPathArgument = (YangInstanceIdentifier.NodeIdentifierWithPredicates) parent.getLastPathArgument();
      return (String) entityTypeLastPathArgument.getKeyValues().get(ENTITY_TYPE_QNAME);
    }
    parent = parent.getParent();
  }
  return null;
}

代码示例来源:origin: opendaylight/yangtools

private void checkIdentifierReferencesData(final YangInstanceIdentifier path,
    final NormalizedNode<?, ?> data) {
  final PathArgument arg;
  if (!path.isEmpty()) {
    arg = path.getLastPathArgument();
    checkArgument(arg != null, "Instance identifier %s has invalid null path argument", path);
  } else {
    arg = rootNode.getIdentifier();
  }
  checkIdentifierReferencesData(arg, data);
}

代码示例来源:origin: opendaylight/controller

@Override
public boolean equals(final Object obj) {
  if (this == obj) {
    return true;
  }
  if (!(obj instanceof DOMDataTreeIdentifier)) {
    return false;
  }
  DOMDataTreeIdentifier other = (DOMDataTreeIdentifier) obj;
  if (datastoreType != other.datastoreType) {
    return false;
  }
  return rootIdentifier.equals(other.rootIdentifier);
}

代码示例来源:origin: org.opendaylight.mdsal/mdsal-binding-dom-adapter

/**
 * Subclasses of this class are required to implement creation of parent nodes based on behaviour of their
 * underlying transaction.
 *
 * @param store an instance of LogicalDatastoreType
 * @param domPath an instance of YangInstanceIdentifier
 * @param path an instance of InstanceIdentifier
 */
protected final void ensureParentsByMerge(final LogicalDatastoreType store, final YangInstanceIdentifier domPath,
    final InstanceIdentifier<?> path) {
  final YangInstanceIdentifier parentPath = domPath.getParent();
  if (parentPath != null) {
    final NormalizedNode<?, ?> parentNode = getCodec().instanceIdentifierToNode(parentPath);
    getDelegate().merge(store, YangInstanceIdentifier.create(parentNode.getIdentifier()), parentNode);
  }
}

代码示例来源:origin: org.opendaylight.controller/sal-distributed-datastore

@Override
public void delete(PathArgument child) {
  try {
    output.write("\nDELETE -> ".getBytes());
    output.write(current().node(child).toString().getBytes());
    output.writeByte('\n');
  } catch(IOException e) {
    Throwables.propagate(e);
  }
}

代码示例来源:origin: org.opendaylight.controller/sal-netconf-connector

private boolean isFilterPresent(final Optional<YangInstanceIdentifier> filterPath) {
  return filterPath.isPresent() && !filterPath.get().isEmpty();
}

代码示例来源:origin: opendaylight/controller

@Override
public final void exit(final int depth) {
  Preconditions.checkArgument(depth >= 0);
  YangInstanceIdentifier next = current;
  for (int i = 0; i < depth; ++i) {
    next = next.getParent();
    Preconditions.checkState(next != null);
  }
  current = next;
}

代码示例来源:origin: org.opendaylight.yangtools/yang-data-api

private static int calculateSize(final YangInstanceIdentifier parent) {
  YangInstanceIdentifier current = parent;
  for (int i = 1;; ++i) {
    final Collection<PathArgument> args = current.tryReversePathArguments();
    if (args != null) {
      return i + args.size();
    }
    verify(current instanceof StackedYangInstanceIdentifier);
    current = current.getParent();
  }
}

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