Adopt odlparent-10.0.0/yangtools-8.0.0-SNAPSHOT
[mdsal.git] / binding / mdsal-binding-java-api-generator / src / main / java / org / opendaylight / mdsal / binding / java / api / generator / Decimal64RangeGenerator.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. 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.Decimal64;
11 import org.opendaylight.yangtools.yang.common.Uint16;
12 import org.opendaylight.yangtools.yang.common.Uint8;
13
14 final class Decimal64RangeGenerator extends AbstractBigRangeGenerator<Decimal64> {
15     Decimal64RangeGenerator() {
16         super(Decimal64.class);
17     }
18
19     @Override
20     protected String format(final Decimal64 value) {
21         return "org.opendaylight.yangtools.yang.common.Decimal64.valueOf(\"" + value + "\")";
22     }
23
24     @Override
25     @Deprecated
26     protected Decimal64 convert(final Number value) {
27         if (value instanceof Byte || value instanceof Short || value instanceof Integer
28             || value instanceof Uint8 || value instanceof Uint16) {
29             return Decimal64.valueOf(value.intValue());
30         } else {
31             return Decimal64.valueOf(value.longValue());
32         }
33     }
34 }