Populate xpath/ hierarchy
[yangtools.git] / xpath / yang-xpath-api / src / main / java / org / opendaylight / yangtools / yang / xpath / api / YangXPathMathSupport.java
1 /*
2  * Copyright (c) 2019 Pantheon Technologies, s.r.o.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.yang.xpath.api;
9
10 import com.google.common.annotations.Beta;
11 import java.io.Serializable;
12 import java.util.Optional;
13
14 /**
15  * Interface supporting mathematical operations. This interface should be implemented by subclassing
16  * {@link AbstractYangXPathMathSupport}, which provides type safety guards.
17  *
18  * @author Robert Varga
19  */
20 @Beta
21 public interface YangXPathMathSupport extends Serializable {
22     /**
23      * Create a {@link YangNumberExpr} backed by specified string.
24      *
25      * @param str 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
29      */
30     YangNumberExpr createNumber(String str);
31
32     /**
33      * Create a {@link YangNumberExpr} for specified integer.
34      *
35      * @param value integer value
36      * @return number expression
37      */
38     YangNumberExpr createNumber(int value);
39
40     /**
41      * Create a {@link YangNumberExpr} representing the negated value of a number.
42      *
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
47      */
48     YangNumberExpr negateNumber(YangNumberExpr number);
49
50     /**
51      * Attempt to evaluate an  operator and its left- and right-handside.
52      *
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
58      */
59     Optional<YangExpr> tryEvaluate(YangBinaryOperator operator, YangNumberExpr left, YangNumberExpr right);
60 }