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.io.Serializable;
12 import java.util.Optional;
15 * Interface supporting mathematical operations. This interface should be implemented by subclassing
16 * {@link AbstractYangXPathMathSupport}, which provides type safety guards.
18 * @author Robert Varga
21 public interface YangXPathMathSupport extends Serializable {
23 * Create a {@link YangNumberExpr} backed by specified string.
26 * @return number expression
27 * @throws NullPointerException if {@code str} is null
28 * @throws NumberFormatException if the string does not represent a valid number
30 YangNumberExpr createNumber(String str);
33 * Create a {@link YangNumberExpr} for specified integer.
35 * @param value integer value
36 * @return number expression
38 YangNumberExpr createNumber(int value);
41 * Create a {@link YangNumberExpr} representing the negated value of a number.
43 * @param number input number
44 * @return negated number expression
45 * @throws NullPointerException if {@code number} is null
46 * @throws IllegalArgumentException if {@code number} has unrecognized type
48 YangNumberExpr negateNumber(YangNumberExpr number);
51 * Attempt to evaluate an operator and its left- and right-handside.
53 * @param operator Operator to apply
54 * @param left Left hand-side
55 * @param right Right hand-side
56 * @return Evaluation result, if evaluation succeeded
57 * @throws NullPointerException if any of the arguments is null
59 Optional<YangExpr> tryEvaluate(YangBinaryOperator operator, YangNumberExpr left, YangNumberExpr right);