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.BigInteger;
9   
10  import dev.metaschema.core.metapath.cst.IExpressionVisitor;
11  import dev.metaschema.core.metapath.item.atomic.IIntegerItem;
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">Integer Literal
17   * Expression</a> supporting the creation of a Metapath constant literal
18   * {@link IIntegerItem}.
19   */
20  public class IntegerLiteral
21      extends AbstractLiteralExpression<IIntegerItem> {
22  
23    /**
24     * Construct a new expression that always returns the same integer value.
25     *
26     * @param text
27     *          the parsed text of the expression
28     * @param value
29     *          the literal value
30     */
31    public IntegerLiteral(@NonNull String text, @NonNull BigInteger value) {
32      super(text, IIntegerItem.valueOf(value));
33    }
34  
35    @Override
36    public Class<IIntegerItem> getBaseResultType() {
37      return IIntegerItem.class;
38    }
39  
40    @Override
41    public <RESULT, CONTEXT> RESULT accept(IExpressionVisitor<RESULT, CONTEXT> visitor, CONTEXT context) {
42      return visitor.visitIntegerLiteral(this, context);
43    }
44  }