Magnesium platform upgrade
[lispflowmapping.git] / mappingservice / lisp-proto / src / main / java / org / opendaylight / lispflowmapping / lisp / util / NumberUtil.java
1 /*
2  * Copyright (c) 2014 Contextream, 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.lispflowmapping.lisp.util;
9
10 import org.opendaylight.yangtools.yang.common.Uint8;
11
12 public final class NumberUtil {
13     // Utility class, should not be instantiated
14     private NumberUtil() {
15     }
16
17     public static int asInt(Integer number) {
18         if (number != null) {
19             return number;
20         }
21         return 0;
22     }
23
24     public static byte asByte(Byte number) {
25         if (number != null) {
26             return number;
27         }
28         return 0;
29     }
30
31     public static short asShort(Short number) {
32         if (number != null) {
33             return number;
34         }
35         return 0;
36     }
37
38     public static short asShort(Uint8 number) {
39         if (number != null) {
40             return number.toJava();
41         }
42         return 0;
43     }
44
45     public static long asLong(Long number) {
46         if (number != null) {
47             return number;
48         }
49         return 0;
50     }
51
52 }