Define a feature-parent
[yangtools.git] / xpath / yang-xpath-api / src / main / java / org / opendaylight / yangtools / yang / xpath / api / BigDecimalNumberExpr.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 static java.util.Objects.requireNonNull;
11
12 import java.io.Serial;
13 import java.math.BigDecimal;
14 import org.eclipse.jdt.annotation.Nullable;
15
16 final class BigDecimalNumberExpr extends YangNumberExpr {
17     @Serial
18     private static final long serialVersionUID = 1L;
19
20     private final BigDecimal number;
21
22     private BigDecimalNumberExpr(final BigDecimal number) {
23         this.number = requireNonNull(number);
24     }
25
26     static BigDecimalNumberExpr of(final BigDecimal number) {
27         return new BigDecimalNumberExpr(number);
28     }
29
30     @Override
31     public BigDecimal getNumber() {
32         return number;
33     }
34
35     @Override
36     public BigDecimalXPathMathSupport getSupport() {
37         return BigDecimalXPathMathSupport.INSTANCE;
38     }
39
40     @Override
41     public int hashCode() {
42         return number.hashCode();
43     }
44
45     @Override
46     public boolean equals(final @Nullable Object obj) {
47         return this == obj || obj instanceof BigDecimalNumberExpr other && number.equals(other.number);
48     }
49
50     @Override
51     public String toString() {
52         return number.toString();
53     }
54 }