Tabnine Logo
ChoiceNode
Code IndexAdd Tabnine to your IDE (free)

How to use
ChoiceNode
in
org.opendaylight.yangtools.yang.data.api.schema

Best Java code snippets using org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode (Showing top 20 results out of 315)

origin: org.opendaylight.bgpcep/bgp-evpn

@Override
public Esi parseEsiModel(final ChoiceNode esiChoice) {
  Preconditions.checkArgument(esiChoice != null && !esiChoice.getValue().isEmpty(), "ESI is mandatory. Can't be null or empty.");
  final ContainerNode cont = (ContainerNode) Iterables.getOnlyElement(esiChoice.getValue());
  final EsiSerializer serializer = this.modelHandlers.get(cont.getIdentifier());
  if (serializer != null) {
    return serializer.serializeEsi(cont);
  }
  LOG.warn("Unrecognized ESI {}", esiChoice);
  return null;
}
origin: org.opendaylight.bgpcep/bgp-linkstate

public static boolean isTeLsp(final ChoiceNode objectType) {
  return objectType.getChild(ADDRESS_FAMILY).isPresent();
}
origin: opendaylight/yangtools

  @Override
  protected NormalizedNode<?, ?> createEmptyValue(final NormalizedNode<?, ?> original) {
    checkArgument(original instanceof ChoiceNode);
    return ImmutableChoiceNodeBuilder.create().withNodeIdentifier(((ChoiceNode) original).getIdentifier()).build();
  }
}
origin: org.opendaylight.controller/netconf-util

writer.startChoiceNode(n.getIdentifier(), OrderedNormalizedNodeWriter.childSizeHint(n.getValue()));
return writeChildren(n.getValue(), dataSchemaNode, true);
origin: org.opendaylight.bgpcep/bgp-rib-impl

@Override
public void createEmptyTableStructure(final DOMDataWriteTransaction tx, final YangInstanceIdentifier tableId) {
  final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> tb = ImmutableNodes.mapEntryBuilder();
  tb.withNodeIdentifier((NodeIdentifierWithPredicates)tableId.getLastPathArgument());
  tb.withChild(EMPTY_TABLE_ATTRIBUTES);
  // tableId is keyed, but that fact is not directly visible from YangInstanceIdentifier, see BUG-2796
  final NodeIdentifierWithPredicates tableKey = (NodeIdentifierWithPredicates) tableId.getLastPathArgument();
  for (final Entry<QName, Object> e : tableKey.getKeyValues().entrySet()) {
    tb.withChild(ImmutableNodes.leafNode(e.getKey(), e.getValue()));
  }
  final ChoiceNode routes = this.ribSupport.emptyRoutes();
  Verify.verifyNotNull(routes, "Null empty routes in %s", this.ribSupport);
  Verify.verify(Routes.QNAME.equals(routes.getNodeType()), "Empty routes have unexpected identifier %s, expected %s", routes.getNodeType(), Routes.QNAME);
  tx.put(LogicalDatastoreType.OPERATIONAL, tableId, tb.withChild(routes).build());
}
origin: org.opendaylight.controller/sal-rest-connector

writer.startChoiceNode(n.getIdentifier(), childSizeHint(n.getValue()));
processedAsCompositeNode = writeChildren(n.getValue());
origin: org.opendaylight.yangtools/yang-data-api

writer.startChoiceNode(n.getIdentifier(), childSizeHint(n.getValue()));
return writeChildren(n.getValue());
origin: org.opendaylight.bgpcep/bgp-evpn

  private EvpnChoice getEvpnCase(final ChoiceNode evpnChoice, final SerializerInterface serializerInterface) {
    Preconditions.checkArgument(evpnChoice != null && !evpnChoice.getValue().isEmpty(), "Evpn case is mandatory. Can't be null or empty.");
    final ContainerNode cont = (ContainerNode) Iterables.getOnlyElement(evpnChoice.getValue());
    final EvpnSerializer serializer = this.modelHandlers.get(cont.getIdentifier());
    if (serializer == null) {
      return null;
    }
    return serializerInterface.check(serializer, cont);
  }
}
origin: org.opendaylight.bgpcep/bgp-linkstate

private static CRouterIdentifier serializeRouterId(final ContainerNode descriptorsData) {
  CRouterIdentifier cRouterId = null;
  final Optional<DataContainerChild<? extends PathArgument, ?>> maybeRouterId = descriptorsData.getChild(ROUTER_NID);
  if (maybeRouterId.isPresent()) {
    final ChoiceNode routerId = (ChoiceNode) maybeRouterId.get();
    if (routerId.getChild(ISIS_NODE_NID).isPresent()) {
      cRouterId = serializeIsisNode((ContainerNode) routerId.getChild(ISIS_NODE_NID).get());
    } else if (routerId.getChild(ISIS_PSEUDONODE_NID).isPresent()) {
      cRouterId = serializeIsisPseudoNode((ContainerNode) routerId.getChild(ISIS_PSEUDONODE_NID).get());
    } else if (routerId.getChild(OSPF_NODE_NID).isPresent()) {
      cRouterId = serializeOspfNode((ContainerNode) routerId.getChild(OSPF_NODE_NID).get());
    } else if (routerId.getChild(OSPF_PSEUDONODE_NID).isPresent()) {
      cRouterId = serializeOspfPseudoNode((ContainerNode) routerId.getChild(OSPF_PSEUDONODE_NID).get());
    }
  }
  return cRouterId;
}
origin: org.opendaylight.yangtools/yang-data-impl

  @Override
  protected NormalizedNode<?, ?> createEmptyValue(final NormalizedNode<?, ?> original) {
    checkArgument(original instanceof ChoiceNode);
    return ImmutableChoiceNodeBuilder.create().withNodeIdentifier(((ChoiceNode) original).getIdentifier()).build();
  }
}
origin: opendaylight/yangtools

writer.startChoiceNode(n.getIdentifier(), childSizeHint(n.getValue()));
return writeChildren(n.getValue());
origin: org.opendaylight.mdsal/mdsal-binding-dom-codec

@SuppressWarnings("unchecked")
@Override
public D deserialize(final NormalizedNode<?, ?> data) {
  checkArgument(data instanceof ChoiceNode);
  final ChoiceNode casted = (ChoiceNode) data;
  final NormalizedNode<?, ?> first = Iterables.getFirst(casted.getValue(), null);
  if (first == null) {
    // FIXME: this needs to be sorted out
    return null;
  }
  final DataContainerCodecPrototype<?> caze = byYangCaseChild.get(first.getIdentifier());
  return (D) caze.get().deserialize(data);
}
origin: org.opendaylight.bgpcep/bgp-rib-spi

private static ContainerNode getDestination(final DataContainerChild<? extends PathArgument, ?> routes, final NodeIdentifier destinationId) {
  if (routes instanceof ContainerNode) {
    final Optional<DataContainerChild<? extends PathArgument, ?>> maybeDestination = ((ContainerNode)routes).getChild(DESTINATION_TYPE);
    if (maybeDestination.isPresent()) {
      final DataContainerChild<? extends PathArgument, ?> destination = maybeDestination.get();
      if (destination instanceof ChoiceNode) {
        final Optional<DataContainerChild<? extends PathArgument, ?>> maybeRet = ((ChoiceNode)destination).getChild(destinationId);
        if (maybeRet.isPresent()) {
          final DataContainerChild<? extends PathArgument, ?> ret = maybeRet.get();
          if (ret instanceof ContainerNode) {
            return (ContainerNode)ret;
          } else {
            LOG.debug("Specified node {} is not a container, ignoring it", ret);
          }
        } else {
          LOG.debug("Specified container {} is not present in destination {}", destinationId, destination);
        }
      } else {
        LOG.warn("Destination {} is not a choice, ignoring it", destination);
      }
    } else {
      LOG.debug("Destination is not present in routes {}", routes);
    }
  } else {
    LOG.warn("Advertized routes {} are not a container, ignoring it", routes);
  }
  return null;
}
origin: org.opendaylight.controller/sal-rest-connector

private DataContainerChild<?, ?> processChoiceNode(final NormalizedNode<?, ?> node, final Integer depth) {
  final ChoiceNode choiceNode = (ChoiceNode) node;
  DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> newChoiceBuilder = Builders.choiceBuilder()
      .withNodeIdentifier(choiceNode.getIdentifier());
  processDataContainerChild((DataContainerNode<?>) node, depth, newChoiceBuilder);
  return newChoiceBuilder.build();
}
origin: org.opendaylight.yangtools/yang-data-impl

private void enforceCases(final NormalizedNode<?, ?> normalizedNode) {
  Verify.verify(normalizedNode instanceof ChoiceNode);
  final Collection<DataContainerChild<?, ?>> children = ((ChoiceNode) normalizedNode).getValue();
  if (!children.isEmpty()) {
    final DataContainerChild<?, ?> firstChild = children.iterator().next();
    final CaseEnforcer enforcer = Verify.verifyNotNull(caseEnforcers.get(firstChild.getIdentifier()),
      "Case enforcer cannot be null. Most probably, child node %s of choice node %s does not belong "
      + "in current tree type.", firstChild.getIdentifier(), normalizedNode.getIdentifier());
    // Make sure no leaves from other cases are present
    for (final CaseEnforcer other : exclusions.get(enforcer)) {
      for (final PathArgument id : other.getAllChildIdentifiers()) {
        final Optional<NormalizedNode<?, ?>> maybeChild = NormalizedNodes.getDirectChild(normalizedNode,
          id);
        Preconditions.checkArgument(!maybeChild.isPresent(),
          "Child %s (from case %s) implies non-presence of child %s (from case %s), which is %s",
          firstChild.getIdentifier(), enforcer, id, other, maybeChild.orElse(null));
      }
    }
    // Make sure all mandatory children are present
    enforcer.enforceOnTreeNode(normalizedNode);
  }
}
origin: org.opendaylight.bgpcep/bgp-linkstate

public static TeLspCase serializeTeLsp(final ChoiceNode objectType) {
  final TeLspCaseBuilder teLsp = new TeLspCaseBuilder();
  teLsp.setLspId(new LspId((Long) objectType.getChild(LSP_ID).get().getValue()));
  teLsp.setTunnelId(new TunnelId((Integer) objectType.getChild(TUNNEL_ID).get().getValue()));
  final ChoiceNode addressFamily = (ChoiceNode) objectType.getChild(ADDRESS_FAMILY).get();
  teLsp.setAddressFamily(serializeAddressFamily(addressFamily, addressFamily.getChild(IPV4_TUNNEL_SENDER_ADDRESS).isPresent()));
  return teLsp.build();
}
origin: opendaylight/yangtools

private void enforceCases(final NormalizedNode<?, ?> normalizedNode) {
  Verify.verify(normalizedNode instanceof ChoiceNode);
  final Collection<DataContainerChild<?, ?>> children = ((ChoiceNode) normalizedNode).getValue();
  if (!children.isEmpty()) {
    final DataContainerChild<?, ?> firstChild = children.iterator().next();
    final CaseEnforcer enforcer = Verify.verifyNotNull(caseEnforcers.get(firstChild.getIdentifier()),
      "Case enforcer cannot be null. Most probably, child node %s of choice node %s does not belong "
      + "in current tree type.", firstChild.getIdentifier(), normalizedNode.getIdentifier());
    // Make sure no leaves from other cases are present
    for (final CaseEnforcer other : exclusions.get(enforcer)) {
      for (final PathArgument id : other.getAllChildIdentifiers()) {
        final Optional<NormalizedNode<?, ?>> maybeChild = NormalizedNodes.getDirectChild(normalizedNode,
          id);
        Preconditions.checkArgument(!maybeChild.isPresent(),
          "Child %s (from case %s) implies non-presence of child %s (from case %s), which is %s",
          firstChild.getIdentifier(), enforcer, id, other, maybeChild.orElse(null));
      }
    }
    // Make sure all mandatory children are present
    enforcer.enforceOnTreeNode(normalizedNode);
  }
}
origin: org.opendaylight.bgpcep/bgp-linkstate

private static void serializeLocalNodeDescriptor(final CLinkstateDestinationBuilder builder, final ChoiceNode objectType) {
  // link local node descriptors
  final LinkCaseBuilder linkBuilder = new LinkCaseBuilder();
  linkBuilder.setLocalNodeDescriptors(NodeNlriParser.serializeLocalNodeDescriptors((ContainerNode) objectType.getChild(LOCAL_NODE_DESCRIPTORS_NID).get()));
  // link remote node descriptors
  if (objectType.getChild(REMOTE_NODE_DESCRIPTORS_NID).isPresent()) {
    linkBuilder.setRemoteNodeDescriptors(NodeNlriParser.serializeRemoteNodeDescriptors((ContainerNode) objectType.getChild(REMOTE_NODE_DESCRIPTORS_NID).get()));
  }
  // link descriptors
  final Optional<DataContainerChild<? extends PathArgument, ?>> linkDescriptors = objectType.getChild(LINK_DESCRIPTORS_NID);
  if (linkDescriptors.isPresent()) {
    linkBuilder.setLinkDescriptors(LinkNlriParser.serializeLinkDescriptors((ContainerNode) linkDescriptors.get()));
  }
  builder.setObjectType(linkBuilder.build());
}
origin: org.opendaylight.yangtools/yang-data-operations

for (DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?> child : modification.get().getValue()) {
  Optional<ChoiceCaseNode> detectedCaseForChild = SchemaUtils.detectCase(schema, child);
origin: org.opendaylight.bgpcep/bgp-linkstate

private static void serializeAdvertisedNodeDescriptor(final CLinkstateDestinationBuilder builder, final ChoiceNode objectType) {
  // prefix node descriptors
  final PrefixCaseBuilder prefixBuilder = new PrefixCaseBuilder();
  prefixBuilder.setAdvertisingNodeDescriptors(NodeNlriParser.serializeAdvNodeDescriptors((ContainerNode) objectType.getChild(
    ADVERTISING_NODE_DESCRIPTORS_NID).get()));
  // prefix descriptors
  final Optional<DataContainerChild<? extends PathArgument, ?>> prefixDescriptors = objectType.getChild(PREFIX_DESCRIPTORS_NID);
  if (prefixDescriptors.isPresent()) {
    prefixBuilder.setPrefixDescriptors(AbstractPrefixNlriParser.serializePrefixDescriptors((ContainerNode) prefixDescriptors.get()));
  }
  builder.setObjectType(prefixBuilder.build());
}
org.opendaylight.yangtools.yang.data.api.schemaChoiceNode

Javadoc

Node representing data instance of choice.

Choice node is instance of one of possible alternatives, from which only one is allowed to exist at one time in particular context of parent node.

YANG Model and schema for choice is described by instance of org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode.

Valid alternatives of subtree are described by instances of org.opendaylight.yangtools.yang.model.api.CaseSchemaNode, which are retrieved via org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode#getCases().

Most used methods

  • getValue
  • getChild
  • getIdentifier
  • getNodeType

Popular in Java

  • Reactive rest calls using spring rest template
  • setScale (BigDecimal)
  • getExternalFilesDir (Context)
  • getApplicationContext (Context)
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • System (java.lang)
    Provides access to system-related information and resources including standard input and output. Ena
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • Reference (javax.naming)
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now