Populate model/ hierarchy
[yangtools.git] / model / yang-model-ri / src / main / java / org / opendaylight / yangtools / yang / model / ri / stmt / impl / decl / EmptyFractionDigitsStatement.java
1 /*
2  * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others.  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.model.ri.stmt.impl.decl;
9
10 import org.eclipse.jdt.annotation.NonNull;
11 import org.opendaylight.yangtools.yang.model.api.stmt.FractionDigitsStatement;
12 import org.opendaylight.yangtools.yang.model.spi.meta.AbstractDeclaredStatement.ArgumentToString;
13
14 public final class EmptyFractionDigitsStatement extends ArgumentToString<Integer> implements FractionDigitsStatement {
15     private static final @NonNull EmptyFractionDigitsStatement[] INSTANCES;
16
17     static {
18         final EmptyFractionDigitsStatement[] inst = new EmptyFractionDigitsStatement[18];
19         for (int i = 0; i < 18; ++i) {
20             inst[i] =  new EmptyFractionDigitsStatement(i + 1);
21         }
22         INSTANCES = inst;
23     }
24
25     private EmptyFractionDigitsStatement(final int argument) {
26         super(argument);
27     }
28
29     public static @NonNull EmptyFractionDigitsStatement of(final int argument) {
30         try {
31             return INSTANCES[argument - 1];
32         } catch (IndexOutOfBoundsException e) {
33             throw new IllegalArgumentException("Invalid fraction-digits argument " + argument, e);
34         }
35     }
36 }