Split out isBitsType()
[mdsal.git] / binding / mdsal-binding-java-api-generator / src / main / java / org / opendaylight / mdsal / binding / java / api / generator / Uint16RangeGenerator.java
1 /*
2  * Copyright (c) 2019 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.mdsal.binding.java.api.generator;
9
10 import org.opendaylight.yangtools.yang.common.Uint16;
11 import org.opendaylight.yangtools.yang.common.Uint8;
12
13 final class Uint16RangeGenerator extends AbstractUnsignedRangeGenerator<Uint16> {
14     Uint16RangeGenerator() {
15         super(Uint16.class, int.class.getName(), Uint16.ZERO, Uint16.MAX_VALUE);
16     }
17
18     @Override
19     @Deprecated
20     protected Uint16 convert(final Number value) {
21         if (value instanceof Byte || value instanceof Short || value instanceof Integer || value instanceof Uint8) {
22             return Uint16.valueOf(value.intValue());
23         }
24         return Uint16.valueOf(value.toString());
25     }
26
27     @Override
28     protected String format(final Uint16 value) {
29         return value.toCanonicalString();
30     }
31 }