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 static java.util.Objects.requireNonNull;
12 import com.google.common.annotations.Beta;
15 * {@link YangXPathParser} number compliance knobs. This enumeration defines what assumptions the parser can make --
16 * affecting its optimization properties around
17 * <a href="https://en.wikipedia.org/wiki/Constant_folding">constant folding</a> when number expressions are
21 public enum YangXPathMathMode {
23 * All number expressions are treated as {@code double}. This in spirit of XPath 1.0 -- any number expression
24 * starts its life as a double, making all operations subject to IEEE754 rounding and range rules.
26 IEEE754(DoubleXPathMathSupport.INSTANCE),
29 * All number expressions are treated as infinite-precision numbers. This follows the spirit of YANG 1.1 --
30 * where mostly have integral types and decimal64 mapped to BigDecimal. Non-decimal numbers are mapped either to
31 * {@code int}, {@code long} or {@code BigInteger}.
33 EXACT(BigDecimalXPathMathSupport.INSTANCE);
36 * FIXME: 7.0.0: specify and implement this:
38 * All number expressions are treated either as {@code org.opendaylight.yangtools.yang.common} types with
39 * precision required to hold them. Decimal types are mapped to {@link Decimal64} with all range restrictions
40 * and rounding error implied by it.
44 private YangXPathMathSupport support;
46 YangXPathMathMode(final YangXPathMathSupport support) {
47 this.support = requireNonNull(support);
51 * Return {@link YangXPathMathSupport} which provides support for the this mode.
53 * @return YangXPathMathSupport supporting this mode.
55 public YangXPathMathSupport getSupport() {