本文整理了Java中org.opendaylight.yangtools.yang.xpath.api.YangLocationPath
类的一些代码示例,展示了YangLocationPath
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YangLocationPath
类的具体详情如下:
包路径:org.opendaylight.yangtools.yang.xpath.api.YangLocationPath
类名称:YangLocationPath
暂无
代码示例来源:origin: org.opendaylight.yangtools/yang-xpath-api
public static final YangLocationPath of(final boolean absolute, final Step... steps) {
return of(absolute, Arrays.asList(steps));
}
代码示例来源:origin: opendaylight/yangtools
@Override
public final boolean equals(final @Nullable Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof YangLocationPath)) {
return false;
}
final YangLocationPath other = (YangLocationPath) obj;
return isAbsolute() == other.isAbsolute() && getSteps().equals(other.getSteps());
}
代码示例来源:origin: opendaylight/yangtools
private YangExpr parseUnion(final UnionExprNoRootContext expr) {
final ParseTree first = expr.getChild(0);
final YangExpr path;
if (first instanceof PathExprNoRootContext) {
path = parsePathExpr((PathExprNoRootContext) first);
if (expr.getChildCount() == 1) {
return path;
}
} else {
path = YangLocationPath.root();
}
verifyChildCount(expr, 3);
final YangExpr union = parseUnion(getChild(expr, UnionExprNoRootContext.class, 2));
// Deduplicate expressions so we do not perform useless unioning
final Set<YangExpr> expressions = new LinkedHashSet<>();
expressions.add(path);
if (union instanceof YangNaryExpr) {
// If the result is a union expression, integrate it into this expression
final YangNaryExpr nary = (YangNaryExpr) union;
if (nary.getOperator() == YangNaryOperator.UNION) {
expressions.addAll(nary.getExpressions());
} else {
expressions.add(union);
}
} else {
expressions.add(union);
}
return YangNaryOperator.UNION.exprWith(expressions);
}
代码示例来源:origin: opendaylight/yangtools
private Collection<YangExpr> parsePathArgumentPredicate(final instanceIdentifierParser.PredicateContext expr) {
final ParseTree first = expr.getChild(0);
if (first instanceof LeafListPredicateContext) {
return ImmutableSet.of(YangBinaryOperator.EQUALS.exprWith(YangLocationPath.self(),
parseEqStringValue(getChild(((LeafListPredicateContext) first)
.getChild(LeafListPredicateExprContext.class, 0), EqQuotedStringContext.class, 1))));
} else if (first instanceof PosContext) {
return ImmutableSet.of(YangBinaryOperator.EQUALS.exprWith(Functions.POSITION,
createNumber(((PosContext) first).getToken(instanceIdentifierParser.PositiveIntegerValue, 0)
.getText())));
}
final int length = expr.getChildCount();
final List<YangExpr> ret = new ArrayList<>(length);
for (int i = 0; i < length; ++i) {
final KeyPredicateExprContext pred = getChild(expr, KeyPredicateContext.class, i)
.getChild(KeyPredicateExprContext.class, 0);
ret.add(YangBinaryOperator.EQUALS.exprWith(
YangQNameExpr.of(parseInstanceIdentifierQName(getChild(pred, NodeIdentifierContext.class, 0))),
parseEqStringValue(getChild(pred, EqQuotedStringContext.class, 1))));
}
return ret;
}
代码示例来源:origin: org.opendaylight.yangtools/yang-xpath-impl
private YangExpr parseUnion(final UnionExprNoRootContext expr) {
final ParseTree first = expr.getChild(0);
final YangExpr path;
if (first instanceof PathExprNoRootContext) {
path = parsePathExpr((PathExprNoRootContext) first);
if (expr.getChildCount() == 1) {
return path;
}
} else {
path = YangLocationPath.root();
}
verifyChildCount(expr, 3);
final YangExpr union = parseUnion(getChild(expr, UnionExprNoRootContext.class, 2));
// Deduplicate expressions so we do not perform useless unioning
final Set<YangExpr> expressions = new LinkedHashSet<>();
expressions.add(path);
if (union instanceof YangNaryExpr) {
// If the result is a union expression, integrate it into this expression
final YangNaryExpr nary = (YangNaryExpr) union;
if (nary.getOperator() == YangNaryOperator.UNION) {
expressions.addAll(nary.getExpressions());
} else {
expressions.add(union);
}
} else {
expressions.add(union);
}
return YangNaryOperator.UNION.exprWith(expressions);
}
代码示例来源:origin: org.opendaylight.yangtools/yang-xpath-impl
private Collection<YangExpr> parsePathArgumentPredicate(final instanceIdentifierParser.PredicateContext expr) {
final ParseTree first = expr.getChild(0);
if (first instanceof LeafListPredicateContext) {
return ImmutableSet.of(YangBinaryOperator.EQUALS.exprWith(YangLocationPath.self(),
parseEqStringValue(getChild(((LeafListPredicateContext) first)
.getChild(LeafListPredicateExprContext.class, 0), EqQuotedStringContext.class, 1))));
} else if (first instanceof PosContext) {
return ImmutableSet.of(YangBinaryOperator.EQUALS.exprWith(Functions.POSITION,
createNumber(((PosContext) first).getToken(instanceIdentifierParser.PositiveIntegerValue, 0)
.getText())));
}
final int length = expr.getChildCount();
final List<YangExpr> ret = new ArrayList<>(length);
for (int i = 0; i < length; ++i) {
final KeyPredicateExprContext pred = getChild(expr, KeyPredicateContext.class, i)
.getChild(KeyPredicateExprContext.class, 0);
ret.add(YangBinaryOperator.EQUALS.exprWith(
YangQNameExpr.of(parseInstanceIdentifierQName(getChild(pred, NodeIdentifierContext.class, 0))),
parseEqStringValue(getChild(pred, EqQuotedStringContext.class, 1))));
}
return ret;
}
代码示例来源:origin: opendaylight/yangtools
public static final YangLocationPath of(final boolean absolute, final Step... steps) {
return of(absolute, Arrays.asList(steps));
}
代码示例来源:origin: org.opendaylight.yangtools/yang-xpath-api
@Override
public final boolean equals(final @Nullable Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof YangLocationPath)) {
return false;
}
final YangLocationPath other = (YangLocationPath) obj;
return isAbsolute() == other.isAbsolute() && getSteps().equals(other.getSteps());
}
代码示例来源:origin: opendaylight/yangtools
private YangExpr parseMultiplicative(final MultiplicativeExprContext expr) {
final ParseTree first = expr.getChild(0);
final YangExpr left;
if (first instanceof UnaryExprNoRootContext) {
left = parseUnary((UnaryExprNoRootContext) first);
} else {
left = YangLocationPath.root();
}
if (expr.getChildCount() == 1) {
return left;
}
verifyChildCount(expr, 3);
final YangBinaryOperator operator = parseOperator(expr.getChild(1));
final YangExpr right = parseMultiplicative(getChild(expr, MultiplicativeExprContext.class, 2));
final Optional<YangExpr> simple = simplifyNumbers(operator, left, right);
return simple.isPresent() ? simple.get() : operator.exprWith(left, right);
}
代码示例来源:origin: org.opendaylight.yangtools/yang-xpath-impl
private YangLocationPath parseRelativeLocationPath(final RelativeLocationPathContext expr) {
return YangLocationPath.of(false, parseLocationPathSteps(expr));
}
代码示例来源:origin: org.opendaylight.yangtools/yang-xpath-api
@Override
public final int hashCode() {
return Boolean.hashCode(isAbsolute()) * 31 + getSteps().hashCode();
}
代码示例来源:origin: org.opendaylight.yangtools/yang-xpath-impl
private YangExpr parseMultiplicative(final MultiplicativeExprContext expr) {
final ParseTree first = expr.getChild(0);
final YangExpr left;
if (first instanceof UnaryExprNoRootContext) {
left = parseUnary((UnaryExprNoRootContext) first);
} else {
left = YangLocationPath.root();
}
if (expr.getChildCount() == 1) {
return left;
}
verifyChildCount(expr, 3);
final YangBinaryOperator operator = parseOperator(expr.getChild(1));
final YangExpr right = parseMultiplicative(getChild(expr, MultiplicativeExprContext.class, 2));
final Optional<YangExpr> simple = simplifyNumbers(operator, left, right);
return simple.isPresent() ? simple.get() : operator.exprWith(left, right);
}
代码示例来源:origin: opendaylight/yangtools
private YangLocationPath parseRelativeLocationPath(final RelativeLocationPathContext expr) {
return YangLocationPath.of(false, parseLocationPathSteps(expr));
}
代码示例来源:origin: opendaylight/yangtools
@Override
public final int hashCode() {
return Boolean.hashCode(isAbsolute()) * 31 + getSteps().hashCode();
}
代码示例来源:origin: org.opendaylight.yangtools/yang-xpath-api
public static final YangLocationPath of(final boolean absolute, final Collection<Step> steps) {
if (steps.isEmpty()) {
return of(absolute);
}
final List<Step> copy = ImmutableList.copyOf(steps);
return absolute ? new AbsoluteWithSteps(copy) : new WithSteps(copy);
}
代码示例来源:origin: org.opendaylight.yangtools/yang-xpath-api
@Override
public final String toString() {
final ToStringHelper helper = MoreObjects.toStringHelper(YangLocationPath.class);
helper.add("absolute", isAbsolute());
final List<Step> steps = getSteps();
if (!steps.isEmpty()) {
helper.add("steps", steps);
}
return helper.toString();
}
}
代码示例来源:origin: opendaylight/yangtools
public static final YangLocationPath of(final boolean absolute, final Collection<Step> steps) {
if (steps.isEmpty()) {
return of(absolute);
}
final List<Step> copy = ImmutableList.copyOf(steps);
return absolute ? new AbsoluteWithSteps(copy) : new WithSteps(copy);
}
代码示例来源:origin: opendaylight/yangtools
@Override
public final String toString() {
final ToStringHelper helper = MoreObjects.toStringHelper(YangLocationPath.class);
helper.add("absolute", isAbsolute());
final List<Step> steps = getSteps();
if (!steps.isEmpty()) {
helper.add("steps", steps);
}
return helper.toString();
}
}
代码示例来源:origin: opendaylight/yangtools
@Override
public YangLocationPath interpretAsInstanceIdentifier(final YangLiteralExpr expr) throws XPathExpressionException {
if (expr instanceof InstanceIdentifierLiteralExpr) {
return YangLocationPath.of(true, ((InstanceIdentifierLiteralExpr)expr).getSteps());
}
throw new XPathExpressionException("Invalid instance-identifier " + expr);
}
代码示例来源:origin: org.opendaylight.yangtools/yang-xpath-impl
@Override
public YangLocationPath interpretAsInstanceIdentifier(final YangLiteralExpr expr) throws XPathExpressionException {
if (expr instanceof InstanceIdentifierLiteralExpr) {
return YangLocationPath.of(true, ((InstanceIdentifierLiteralExpr)expr).getSteps());
}
throw new XPathExpressionException("Invalid instance-identifier " + expr);
}
内容来源于网络,如有侵权,请联系作者删除!