gpt4 book ai didi

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

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

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

YangInstanceIdentifier.isEmpty介绍

[英]Check if this instance identifier has empty path arguments, e.g. it is empty and corresponds to #EMPTY.
[中]

代码示例

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

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

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

/**
 * Create an RPC identifier with a particular context reference.
 *
 * @param type RPC type, SchemaPath of its definition, may not be null
 * @param contextReference Context reference, null means a global RPC identifier.
 * @return A global RPC identifier, guaranteed to be non-null.
 */
public static @Nonnull DOMRpcIdentifier create(final @Nonnull SchemaPath type,
    final @Nullable YangInstanceIdentifier contextReference) {
  if (contextReference == null || contextReference.isEmpty()) {
    return new Global(type);
  }
  return new Local(type, contextReference);
}

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

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

代码示例来源:origin: org.opendaylight.mdsal/mdsal-dom-inmemory-datastore

private Iterable<PathArgument> stripShardPath(final YangInstanceIdentifier listenerPath) {
  if (shardPath.isEmpty()) {
    return listenerPath.getPathArguments();
  }
  final List<PathArgument> listenerPathArgs = new ArrayList<>(listenerPath.getPathArguments());
  final Iterator<PathArgument> shardIter = shardPath.getPathArguments().iterator();
  final Iterator<PathArgument> listenerIter = listenerPathArgs.iterator();
  while (shardIter.hasNext()) {
    if (shardIter.next().equals(listenerIter.next())) {
      listenerIter.remove();
    } else {
      break;
    }
  }
  return listenerPathArgs;
}

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

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

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

/**
 * Create an RPC identifier with a particular context reference.
 *
 * @param type RPC type, SchemaPath of its definition, may not be null
 * @param contextReference Context reference, null means a global RPC identifier.
 * @return A global RPC identifier, guaranteed to be non-null.
 */
public static DOMRpcIdentifier create(final SchemaPath type,
    final @Nullable YangInstanceIdentifier contextReference) {
  if (contextReference == null || contextReference.isEmpty()) {
    return new Global(type);
  }
  return new Local(type, contextReference);
}

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

Optional<NormalizedNodeContext> findDescendant(final YangInstanceIdentifier path) {
  if (path.isEmpty()) {
    return Optional.of(this);
  }
  NormalizedNodeContext ctxWalk = this;
  NormalizedNode<?, ?> dataWalk = node;
  for (PathArgument arg : path.getPathArguments()) {
    checkArgument(dataWalk instanceof DataContainerNode, "Path %s refers beyond node %s", path, dataWalk);
    final Optional<DataContainerChild<? extends @Nullable PathArgument, ?>> optChild =
        ((DataContainerNode)dataWalk).getChild(arg);
    if (!optChild.isPresent()) {
      return Optional.empty();
    }
    dataWalk = optChild.get();
    ctxWalk = createChild(dataWalk);
  }
  return Optional.of(ctxWalk.createChild(dataWalk));
}

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

Optional<NormalizedNodeContext> findDescendant(final YangInstanceIdentifier path) {
  if (path.isEmpty()) {
    return Optional.of(this);
  }
  NormalizedNodeContext ctxWalk = this;
  NormalizedNode<?, ?> dataWalk = node;
  for (PathArgument arg : path.getPathArguments()) {
    checkArgument(dataWalk instanceof DataContainerNode, "Path %s refers beyond node %s", path, dataWalk);
    final Optional<DataContainerChild<? extends @Nullable PathArgument, ?>> optChild =
        ((DataContainerNode)dataWalk).getChild(arg);
    if (!optChild.isPresent()) {
      return Optional.empty();
    }
    dataWalk = optChild.get();
    ctxWalk = createChild(dataWalk);
  }
  return Optional.of(ctxWalk.createChild(dataWalk));
}

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

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: 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: 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 Set<String> getGlobalRpc() {
  RoutingTable table = getLocalData();
  Set<String> globalRpc = new HashSet<>(table.getRoutes().size());
  for (DOMRpcIdentifier route : table.getRoutes()) {
    if (route.getContextReference().isEmpty()) {
      globalRpc.add(route.getType().toString());
    }
  }
  log.debug("Locally registered global RPCs {}", globalRpc);
  return globalRpc;
}

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

@Override
public Set<String> getLocalRegisteredRoutedRpc() {
  RoutingTable table = getLocalData();
  Set<String> routedRpc = new HashSet<>(table.getRoutes().size());
  for (DOMRpcIdentifier route : table.getRoutes()) {
    if (!route.getContextReference().isEmpty()) {
      routedRpc.add(ROUTE_CONSTANT + route.getContextReference() + NAME_CONSTANT + route.getType());
    }
  }
  log.debug("Locally registered routed RPCs {}", routedRpc);
  return routedRpc;
}

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

/**
 * Search if the routing table route type contains name.
 */
private static Map<String, String>  getRpcMemberMapByName(final RoutingTable table, final String name,
                          final String address) {
  Set<DOMRpcIdentifier> routes = table.getRoutes();
  Map<String, String> rpcMap = new HashMap<>(routes.size());
  for (DOMRpcIdentifier route : routes) {
    if (!route.getContextReference().isEmpty()) {
      String type = route.getType().toString();
      if (type.contains(name)) {
        rpcMap.put(ROUTE_CONSTANT + route.getContextReference() + NAME_CONSTANT + type, address);
      }
    }
  }
  return rpcMap;
}

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

/**
 * Search if the routing table route String contains routeName.
 */
private static Map<String,String> getRpcMemberMapByRoute(final RoutingTable table, final String routeName,
                         final String address) {
  Set<DOMRpcIdentifier> routes = table.getRoutes();
  Map<String, String> rpcMap = new HashMap<>(routes.size());
  for (DOMRpcIdentifier route : routes) {
    if (!route.getContextReference().isEmpty()) {
      String routeString = route.getContextReference().toString();
      if (routeString.contains(routeName)) {
        rpcMap.put(ROUTE_CONSTANT + routeString + NAME_CONSTANT + route.getType(), address);
      }
    }
  }
  return rpcMap;
}

代码示例来源: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 static NormalizedNode<?, ?> createRoot(final YangInstanceIdentifier path) {
    if (path.isEmpty()) {
      return ROOT_CONTAINER;
    }

    final PathArgument arg = path.getLastPathArgument();
    if (arg instanceof NodeIdentifier) {
      return ImmutableContainerNodeBuilder.create().withNodeIdentifier((NodeIdentifier) arg).build();
    }
    if (arg instanceof NodeIdentifierWithPredicates) {
      return ImmutableNodes.mapEntryBuilder().withNodeIdentifier((NodeIdentifierWithPredicates) arg).build();
    }

    // FIXME: implement augmentations and leaf-lists
    throw new IllegalArgumentException("Unsupported root node " + arg);
  }
}

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

private static void applyToCursorAwareModification(final CursorAwareDataTreeModification modification,
    final DataTreeCandidate candidate) {
  final YangInstanceIdentifier candidatePath = candidate.getRootPath();
  if (candidatePath.isEmpty()) {
    try (DataTreeModificationCursor cursor = modification.openCursor()) {
      DataTreeCandidateNodes.applyRootToCursor(cursor, candidate.getRootNode());
    }
  } else {
    try (DataTreeModificationCursor cursor = modification.openCursor(candidatePath.getParent()).get()) {
      DataTreeCandidateNodes.applyRootedNodeToCursor(cursor, candidatePath, candidate.getRootNode());
    }
  }
}

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

private static NormalizedNode<?, ?> createRoot(final YangInstanceIdentifier path) {
    if (path.isEmpty()) {
      return ROOT_CONTAINER;
    }

    final PathArgument arg = path.getLastPathArgument();
    if (arg instanceof NodeIdentifier) {
      return ImmutableContainerNodeBuilder.create().withNodeIdentifier((NodeIdentifier) arg).build();
    }
    if (arg instanceof NodeIdentifierWithPredicates) {
      return ImmutableNodes.mapEntryBuilder().withNodeIdentifier((NodeIdentifierWithPredicates) arg).build();
    }

    // FIXME: implement augmentations and leaf-lists
    throw new IllegalArgumentException("Unsupported root node " + arg);
  }
}

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

private static void applyToCursorAwareModification(final CursorAwareDataTreeModification modification,
    final DataTreeCandidate candidate) {
  final YangInstanceIdentifier candidatePath = candidate.getRootPath();
  if (candidatePath.isEmpty()) {
    try (DataTreeModificationCursor cursor = modification.openCursor()) {
      DataTreeCandidateNodes.applyRootToCursor(cursor, candidate.getRootNode());
    }
  } else {
    try (DataTreeModificationCursor cursor = modification.openCursor(candidatePath.getParent()).get()) {
      DataTreeCandidateNodes.applyRootedNodeToCursor(cursor, candidatePath, candidate.getRootNode());
    }
  }
}

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