org.onosproject.yang.compiler.datamodel.YangDecimal64类的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(54)

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

YangDecimal64介绍

[英]Represents YANG decimal 64.
[中]表示杨十进制64。

代码示例

代码示例来源:origin: org.onosproject/onos-yang-compiler-datamodel

/**
 * Returns the object of YANG decimal64 from input string.
 *
 * @param valInString input String
 * @return Object of YANG decimal64
 */
static YangDecimal64 fromString(String valInString) {
  return new YangDecimal64(valInString);
}

代码示例来源:origin: org.onosproject/onos-yang-compiler-datamodel

/**
 * Checks whether specific string is valid decimal64 value.
 *
 * @param value decimal64 value
 */
private void validateDecimal64(String value, int fractionDigit, YangRangeRestriction rangeRestriction)
    throws DataModelException {
  YangDecimal64<YangRangeRestriction> decimal64 = YangDecimal64.fromString(value);
  decimal64.setFractionDigit(fractionDigit);
  decimal64.setRangeRestrictedExtendedInfo(rangeRestriction);
  decimal64.validateDecimal64();
}

代码示例来源:origin: org.onosproject/onos-yang-compiler-datamodel

(YangRangeRestriction) getRangeRestrictedExtendedInfo();
if (rangeRestriction == null) {
while (rangeListIterator.hasNext()) {
  YangRangeInterval rangeInterval = rangeListIterator.next();
  rangeInterval.setCharPosition(getCharPosition());
  rangeInterval.setLineNumber(getLineNumber());
  rangeInterval.setFileName(getFileName());
  if (!FractionDigits.isValueInDecimal64Range(
      ((YangDecimal64) rangeInterval.getStartValue()).getValue(),
      getFractionDigit())) {
    throw new DataModelException(getErrorMsg(
        "YANG file error : decimal64 validation failed.", "decimal64",
        getLineNumber(), getCharPosition(), getFileName() + "\""));
      ((YangDecimal64) rangeInterval.getEndValue()).getValue(),
      getFractionDigit())) {
    throw new DataModelException(getErrorMsg(
        "YANG file error : decimal64 validation failed.", "decimal64",
        getLineNumber(), getCharPosition(), getFileName() + "\""));

代码示例来源:origin: org.onosproject/onos-yang-compiler-datamodel

/**
 * Returns decimal64 default range restriction based on fraction-digits.
 * If range restriction is not provided then this default range value will be applicable.
 *
 * @return range restriction
 * @throws DataModelException a violation of data model rules
 */
public YangRangeRestriction getDefaultRangeRestriction() throws DataModelException {
  YangRangeRestriction refRangeRestriction = new YangRangeRestriction(null);
  YangRangeInterval rangeInterval = new YangRangeInterval<>();
  rangeInterval.setCharPosition(getCharPosition());
  rangeInterval.setLineNumber(getLineNumber());
  rangeInterval.setFileName(getFileName());
  FractionDigits.Range range = FractionDigits.getRange(fractionDigit);
  rangeInterval.setStartValue(new YangDecimal64(new BigDecimal((range.getMin()))));
  rangeInterval.setEndValue(new YangDecimal64(new BigDecimal((range.getMax()))));
  refRangeRestriction.addRangeRestrictionInterval(rangeInterval);
  return refRangeRestriction;
}

代码示例来源:origin: org.onosproject/onos-yang-compiler-parser

/**
 * It is called when parser enters grammar rule (decimal64), it perform
 * validations and updates the data model tree.
 *
 * @param listener listener's object
 * @param ctx      context object of the grammar rule
 */
public static void processDecimal64Entry(TreeWalkListener listener,
                     Decimal64SpecificationContext ctx) {
  // Check for stack to be non empty.
  checkStackIsNotEmpty(listener, MISSING_HOLDER, DECIMAL64_DATA, "", ENTRY);
  Parsable tmpNode = listener.getParsedDataStack().peek();
  if (tmpNode instanceof YangType) {
    YangType<YangDecimal64<YangRangeRestriction>> typeNode =
        (YangType<YangDecimal64<YangRangeRestriction>>) tmpNode;
    YangDecimal64 decimal64Node = new YangDecimal64();
    typeNode.setDataTypeExtendedInfo(decimal64Node);
    decimal64Node.setLineNumber(ctx.getStart().getLine());
    decimal64Node.setCharPosition(ctx.getStart().getCharPositionInLine());
    decimal64Node.setFileName(listener.getFileName());
  } else {
    throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, DECIMAL64_DATA, "", ENTRY));
  }
}

代码示例来源:origin: org.onosproject/onos-yang-compiler-parser

/**
 * It is called when parser enters grammar rule (fraction-digits), it perform
 * validations and updates the data model tree.
 *
 * @param listener listener's object
 * @param ctx      context object of the grammar rule
 */
public static void processFractionDigitsEntry(TreeWalkListener listener,
                       FractionDigitStatementContext ctx) {
  // Check for stack to be non empty.
  checkStackIsNotEmpty(listener, MISSING_HOLDER, FRACTION_DIGITS_DATA,
             ctx.fraction().getText(), ENTRY);
  int value = getValidFractionDigits(ctx);
  Parsable tmpNode = listener.getParsedDataStack().peek();
  if (tmpNode instanceof YangType) {
    YangType<YangDecimal64<YangRangeRestriction>> typeNode =
        (YangType<YangDecimal64<YangRangeRestriction>>) tmpNode;
    YangDecimal64 decimal64Node = typeNode.getDataTypeExtendedInfo();
    decimal64Node.setFractionDigit(value);
    if (!decimal64Node.isValidFractionDigit()) {
      throw new ParserException(constructErrorMsg(ctx, INVALID_CONTENT));
    }
  } else {
    throw new ParserException(constructErrorMsg(ctx, INVALID_HOLDER));
  }
}

代码示例来源:origin: org.onosproject/onos-yang-compiler-parser

.getDataTypeExtendedInfo();
  ranRes = processRangeRestriction(
      deci64.getDefaultRangeRestriction(), line, pos, true,
      ranRes, dataType, lis.getFileName());
} else {
  ((YangDecimal64<YangRangeRestriction>) type
      .getDataTypeExtendedInfo())
      .setRangeRestrictedExtendedInfo(ranRes);
} else {
  type.setDataTypeExtendedInfo(ranRes);

代码示例来源:origin: org.onosproject/onos-yang-compiler-datamodel

validateDecimal64(value, decimal64.getFractionDigit(),
         decimal64.getRangeRestrictedExtendedInfo());
break;
  YangDecimal64<YangRangeRestriction> decimal64 = decimal64Type.getDataTypeExtendedInfo();
  validateDecimal64(value, decimal64.getFractionDigit(),
           decimal64.getRangeRestrictedExtendedInfo());

代码示例来源:origin: org.onosproject/onos-yang-compiler-datamodel

private ResolvableStatus getResolveStatusForDecimal64(T extended)
    throws DataModelException {
  if (extended != null) {
    if (((YangDecimal64) extended).getRangeRestrictedExtendedInfo() == null) {
      resolveRangeRestriction(null);
    } else {
      if (!(((YangDecimal64) extended)
          .getRangeRestrictedExtendedInfo() instanceof YangRangeRestriction)) {
        throwError();
          (YangDecimal64) extended).getRangeRestrictedExtendedInfo());

代码示例来源:origin: org.onosproject/onos-yang-compiler-datamodel

(YangRangeRestriction) getRangeRestrictedExtendedInfo();
if (rangeRestriction != null) {
  while (rangeListIterator.hasNext()) {
    YangRangeInterval rangeInterval = rangeListIterator.next();
    rangeInterval.setCharPosition(getCharPosition());
    rangeInterval.setLineNumber(getLineNumber());
    rangeInterval.setFileName(getFileName());
    BigDecimal startValue = ((YangDecimal64) rangeInterval.getStartValue()).getValue();
    BigDecimal endValue = ((YangDecimal64) rangeInterval.getEndValue()).getValue();
    if (value.compareTo(startValue) >= ZERO &&
        value.compareTo(endValue) <= ZERO) {
    throw new DataModelException(getErrorMsg(
        "YANG file error : decimal64 validation failed.", "decimal64",
        getLineNumber(), getCharPosition(), getFileName() + "\""));
  if (!FractionDigits.isValueInDecimal64Range(value, getFractionDigit())) {
    throw new DataModelException(
        "YANG file error : value is not in decimal64 range.");

代码示例来源:origin: org.onosproject/onos-yang-compiler-datamodel

/**
 * Returns object of YANG decimal64.
 *
 * @param value of decimal64
 * @return YANG decimal64 object
 */
public static YangDecimal64 of(BigDecimal value) {
  return new YangDecimal64(value);
}

代码示例来源:origin: org.onosproject/onos-yang-compiler-datamodel

return (T) new YangDecimal64(valueInStr);

相关文章