gpt4 book ai didi

org.opendaylight.yangtools.yang.model.api.YangStmtMapping类的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 21:54:03 29 4
gpt4 key购买 nike

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

YangStmtMapping介绍

[英]Mapping for both RFC6020 and RFC7950 statements.
[中]RFC6020和RFC7950语句的映射。

代码示例

代码示例来源:origin: org.opendaylight.yangtools/yang-model-export

@Override
public void startStatement(final StatementDefinition statement) {
  currentStatement = requireNonNull(statement);
  try {
    writeStartXmlElement(statement.getStatementName());
    if (YangStmtMapping.MODULE.equals(statement) || YangStmtMapping.SUBMODULE.equals(statement)) {
      declareXmlNamespaces();
    }
  } catch (final XMLStreamException e) {
    // FIXME: Introduce proper expression
    throw new IllegalStateException(e);
  }
}

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

YangStmtMapping(final Class<? extends DeclaredStatement<?>> declared,
    final Class<? extends EffectiveStatement<?, ?>> effective, final String nameStr, final String argumentStr,
    final boolean yinElement) {
  declaredType = requireNonNull(declared);
  effectiveType = requireNonNull(effective);
  name = yinQName(nameStr);
  argument = yinQName(argumentStr);
  this.yinElement = yinElement;
}

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

checkArgument(RFC6020_YIN_MODULE.equals(qname.getModule()),
  "Root node namepsace %s does not match %s", rootNs, YangConstants.RFC6020_YIN_NAMESPACE);
checkArgument(MODULE.getStatementName().equals(qname)
  || SUBMODULE.getStatementName().equals(qname), "Root element %s is not a module nor a submodule", qname);
final Attr nameAttr = element.getAttributeNode(MODULE.getArgumentName().getLocalName());
checkArgument(nameAttr != null, "No %s name argument found in %s", element.getLocalName());
final Attr dateAttr = revisionStmt.getAttributeNode(REVISION.getArgumentName().getLocalName());
checkArgument(dateAttr != null, "No revision statement argument found in %s", revisionStmt);

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

private static final Logger LOG = LoggerFactory.getLogger(YinDomSchemaSource.class);
private static final TransformerFactory TRANSFORMER_FACTORY = TransformerFactory.newInstance();
private static final QName REVISION_STMT = REVISION.getStatementName();

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

checkArgument(RFC6020_YIN_MODULE.equals(qname.getModule()),
  "Root node namepsace %s does not match %s", rootNs, YangConstants.RFC6020_YIN_NAMESPACE);
checkArgument(MODULE.getStatementName().equals(qname)
  || SUBMODULE.getStatementName().equals(qname), "Root element %s is not a module nor a submodule", qname);
final Attr nameAttr = element.getAttributeNode(MODULE.getArgumentName().getLocalName());
checkArgument(nameAttr != null, "No %s name argument found in %s", element.getLocalName());
final Attr dateAttr = revisionStmt.getAttributeNode(REVISION.getArgumentName().getLocalName());
checkArgument(dateAttr != null, "No revision statement argument found in %s", revisionStmt);

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

private static final Logger LOG = LoggerFactory.getLogger(YinDomSchemaSource.class);
private static final TransformerFactory TRANSFORMER_FACTORY = TransformerFactory.newInstance();
private static final QName REVISION_STMT = REVISION.getStatementName();

代码示例来源:origin: org.opendaylight.yangtools/yang-parser-rfc7950

public static boolean needToCopyByUses(final StmtContext<?, ?, ?> stmtContext) {
  final StatementDefinition def = stmtContext.getPublicDefinition();
  if (REUSED_DEF_SET.contains(def)) {
    LOG.trace("Will reuse {} statement {}", def, stmtContext);
    return false;
  }
  if (NOCOPY_FROM_GROUPING_SET.contains(def)) {
    return !YangStmtMapping.GROUPING.equals(stmtContext.coerceParentContext().getPublicDefinition());
  }
  LOG.trace("Will copy {} statement {}", def, stmtContext);
  return true;
}

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

YangStmtMapping(final Class<? extends DeclaredStatement<?>> declared,
    final Class<? extends EffectiveStatement<?, ?>> effective, final String nameStr, final String argumentStr,
    final boolean yinElement) {
  declaredType = requireNonNull(declared);
  effectiveType = requireNonNull(effective);
  name = yinQName(nameStr);
  argument = yinQName(argumentStr);
  this.yinElement = yinElement;
}

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

private static boolean needToCopyByUses(final StmtContext<?, ?, ?> stmtContext) {
  final StatementDefinition def = stmtContext.getPublicDefinition();
  if (REUSED_DEF_SET.contains(def)) {
    LOG.debug("Will reuse {} statement {}", def, stmtContext);
    return false;
  }
  if (NOCOPY_FROM_GROUPING_SET.contains(def)) {
    return !YangStmtMapping.GROUPING.equals(stmtContext.coerceParentContext().getPublicDefinition());
  }
  LOG.debug("Will copy {} statement {}", def, stmtContext);
  return true;
}

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

@SuppressFBWarnings("NP_STORE_INTO_NONNULL_FIELD")
YangStmtMapping(final Class<? extends DeclaredStatement<?>> declared,
    final Class<? extends EffectiveStatement<?, ?>> effective, final String nameStr) {
  declaredType = requireNonNull(declared);
  effectiveType = requireNonNull(effective);
  name = yinQName(nameStr);
  argument = null;
  yinElement = false;
}

代码示例来源:origin: org.opendaylight.yangtools/yang-parser-rfc7950

private static boolean containsIfFeature(final EffectiveStatement<?, ?> effectiveStatement) {
    for (final EffectiveStatement<?, ?> effectiveSubstatement : effectiveStatement.effectiveSubstatements()) {
      if (YangStmtMapping.IF_FEATURE.equals(effectiveSubstatement.statementDefinition())) {
        return true;
      }
    }
    return false;
  }
}

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

@SuppressFBWarnings("NP_STORE_INTO_NONNULL_FIELD")
YangStmtMapping(final Class<? extends DeclaredStatement<?>> declared,
    final Class<? extends EffectiveStatement<?, ?>> effective, final String nameStr) {
  declaredType = requireNonNull(declared);
  effectiveType = requireNonNull(effective);
  name = yinQName(nameStr);
  argument = null;
  yinElement = false;
}

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

private static void disallowIfFeatureAndWhenOnListKeys(final StmtContext<?, ?, ?> leafStmtCtx) {
  leafStmtCtx.allSubstatements().forEach(leafSubstmtCtx -> {
    final StatementDefinition statementDef = leafSubstmtCtx.getPublicDefinition();
    SourceException.throwIf(YangStmtMapping.IF_FEATURE.equals(statementDef)
        || YangStmtMapping.WHEN.equals(statementDef), leafStmtCtx.getStatementSourceReference(),
        "%s statement is not allowed in %s leaf statement which is specified as a list key.",
        statementDef.getStatementName(), leafStmtCtx.getStatementArgument());
  });
}

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

public static boolean checkFeatureSupport(final StmtContext<?, ?, ?> stmtContext,
    final Set<QName> supportedFeatures) {
  boolean isSupported = false;
  boolean containsIfFeature = false;
  for (final StmtContext<?, ?, ?> stmt : stmtContext.declaredSubstatements()) {
    if (YangStmtMapping.IF_FEATURE.equals(stmt.getPublicDefinition())) {
      containsIfFeature = true;
      @SuppressWarnings("unchecked")
      final Predicate<Set<QName>> argument = (Predicate<Set<QName>>) stmt.coerceStatementArgument();
      if (argument.test(supportedFeatures)) {
        isSupported = true;
      } else {
        isSupported = false;
        break;
      }
    }
  }
  return !containsIfFeature || isSupported;
}

代码示例来源:origin: org.opendaylight.yangtools/yang-parser-rfc7950

private static boolean isAnyDefaultValueMarkedWithIfFeature(final TypeEffectiveStatement<?> typeStmt,
    final Set<String> defaultValues) {
  final Iterator<? extends EffectiveStatement<?, ?>> iter = typeStmt.effectiveSubstatements().iterator();
  while (iter.hasNext() && !defaultValues.isEmpty()) {
    final EffectiveStatement<?, ?> effectiveSubstatement = iter.next();
    if (YangStmtMapping.BIT.equals(effectiveSubstatement.statementDefinition())) {
      final QName bitQName = (QName) effectiveSubstatement.argument();
      if (defaultValues.remove(bitQName.getLocalName()) && containsIfFeature(effectiveSubstatement)) {
        return true;
      }
    } else if (YangStmtMapping.ENUM.equals(effectiveSubstatement.statementDefinition())
        && defaultValues.remove(effectiveSubstatement.argument())
        && containsIfFeature(effectiveSubstatement)) {
      return true;
    } else if (effectiveSubstatement instanceof TypeEffectiveStatement && isAnyDefaultValueMarkedWithIfFeature(
        (TypeEffectiveStatement<?>) effectiveSubstatement, defaultValues)) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: org.opendaylight.yangtools/yang-parser-rfc7950

private static void addStatement(final Mutable<?, ?, ?> stmtCtxToBeAdded,
    final StatementContextBase<?, ?, ?> targetCtx) {
  if (!StmtContextUtils.isUnknownStatement(stmtCtxToBeAdded)) {
    final StatementDefinition stmtToBeAdded = stmtCtxToBeAdded.getPublicDefinition();
    if (SINGLETON_STATEMENTS.contains(stmtToBeAdded) || YangStmtMapping.DEFAULT.equals(stmtToBeAdded)
        && YangStmtMapping.LEAF.equals(targetCtx.getPublicDefinition())) {
      for (final StmtContext<?, ?, ?> targetCtxSubstatement : targetCtx.allSubstatements()) {
        InferenceException.throwIf(stmtToBeAdded.equals(targetCtxSubstatement.getPublicDefinition()),
          stmtCtxToBeAdded.getStatementSourceReference(),
          "Deviation cannot add substatement %s to target node %s because it is already defined "
          + "in target and can appear only once.",
          stmtToBeAdded.getStatementName(), targetCtx.getStatementArgument());
      }
    }
  }
  copyStatement(stmtCtxToBeAdded, targetCtx);
}

代码示例来源:origin: org.opendaylight.yangtools/yang-parser-rfc7950

this.submoduleContextsToBuild = ImmutableSet.of();
  substatementsOfSubmodules = ImmutableList.of();
} else if (YangStmtMapping.MODULE.equals(ctx.getPublicDefinition())) {

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

/**
 * Validates the specified statement context with regards to if-feature and when statement on list keys.
 * The context can either be a leaf which is defined directly in the substatements of a keyed list or a uses
 * statement defined in a keyed list (a uses statement may add leaves into the list).
 *
 * <p>
 * If one of the list keys contains an if-feature or a when statement in YANG 1.1 model, an exception is thrown.
 *
 * @param ctx statement context to be validated
 */
public static void validateIfFeatureAndWhenOnListKeys(final StmtContext<?, ?, ?> ctx) {
  if (!isRelevantForIfFeatureAndWhenOnListKeysCheck(ctx)) {
    return;
  }
  final StmtContext<?, ?, ?> listStmtCtx = ctx.getParentContext();
  final StmtContext<Collection<SchemaNodeIdentifier>, ?, ?> keyStmtCtx =
      StmtContextUtils.findFirstDeclaredSubstatement(listStmtCtx, KeyStatement.class);
  if (YangStmtMapping.LEAF.equals(ctx.getPublicDefinition())) {
    if (isListKey(ctx, keyStmtCtx)) {
      disallowIfFeatureAndWhenOnListKeys(ctx);
    }
  } else if (YangStmtMapping.USES.equals(ctx.getPublicDefinition())) {
    StmtContextUtils.findAllEffectiveSubstatements(listStmtCtx, LeafStatement.class).forEach(leafStmtCtx -> {
      if (isListKey(leafStmtCtx, keyStmtCtx)) {
        disallowIfFeatureAndWhenOnListKeys(leafStmtCtx);
      }
    });
  }
}

代码示例来源:origin: org.opendaylight.yangtools/yang-parser-rfc7950

final StatementDefinition stmtToBeReplaced = stmtCtxToBeReplaced.getPublicDefinition();
if (YangStmtMapping.DEFAULT.equals(stmtToBeReplaced)
    && YangStmtMapping.LEAF_LIST.equals(targetCtx.getPublicDefinition())) {
  LOG.error("Deviation cannot replace substatement {} in target leaf-list {} because a leaf-list can "
      + "have multiple default statements. At line: {}", stmtToBeReplaced.getStatementName(),

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