gpt4 book ai didi

org.opendaylight.yangtools.yang.model.api.YangStmtMapping.equals()方法的使用及代码示例

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

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

YangStmtMapping.equals介绍

暂无

代码示例

代码示例来源: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-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

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-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

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(),

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