1   /*
2    * SPDX-FileCopyrightText: none
3    * SPDX-License-Identifier: CC0-1.0
4    */
5   
6   package dev.metaschema.core.metapath.cst.items;
7   
8   import java.math.BigDecimal;
9   
10  import dev.metaschema.core.metapath.cst.IExpressionVisitor;
11  import dev.metaschema.core.metapath.item.atomic.IDecimalItem;
12  import edu.umd.cs.findbugs.annotations.NonNull;
13  
14  /**
15   * An implementation of the
16   * <a href="https://www.w3.org/TR/xpath-31/#id-literals">Decimal Literal
17   * Expression</a> supporting the creation of a Metapath constant literal
18   * {@link IDecimalItem}.
19   */
20  public class DecimalLiteral
21      extends AbstractLiteralExpression<IDecimalItem> {
22  
23    /**
24     * Construct a new expression that always returns the same decimal value.
25     *
26     * @param text
27     *          the parsed text of the expression
28     * @param value
29     *          the literal value
30     */
31    public DecimalLiteral(@NonNull String text, @NonNull BigDecimal value) {
32      super(text, IDecimalItem.valueOf(value));
33    }
34  
35    @Override
36    public Class<IDecimalItem> getBaseResultType() {
37      return IDecimalItem.class;
38    }
39  
40    @Override
41    public <RESULT, CONTEXT> RESULT accept(IExpressionVisitor<RESULT, CONTEXT> visitor, CONTEXT context) {
42      return visitor.visitDecimalLiteral(this, context);
43    }
44  }