2 * Copyright (c) 2019 Pantheon Technologies, s.r.o. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.yang.xpath.api;
10 import com.google.common.annotations.Beta;
11 import java.util.Optional;
14 public interface YangXPathMathSupport<N extends YangNumberExpr<N, ?>> {
16 * Create a {@link YangNumberExpr} backed by specified string.
19 * @return number expression
20 * @throws NullPointerException if {@code str} is null
21 * @throws NumberFormatException if the string does not represent a valid number
23 N createNumber(String str);
26 * Create a {@link YangNumberExpr} representing the negated value of a number.
28 * @param number input number
29 * @return negated number expression
30 * @throws NullPointerException if {@code number} is null
31 * @throws IllegalArgumentException if {@code number} has unrecognized type
33 N negateNumber(YangNumberExpr<?, ?> number);
36 * Attempt to evaluate an operator and its left- and right-handside.
38 * @param operator Operator to apply
39 * @param left Left hand-side
40 * @param right Right hand-side
41 * @return Evaluation result, if evaluation succeeded
42 * @throws NullPointerException if any of the arguments is null
44 Optional<YangExpr> tryEvaluate(YangBinaryOperator operator, YangNumberExpr<?, ?> left, YangNumberExpr<?, ?> right);