001/* Copyright (C) 2013 TU Dortmund 002 * This file is part of AutomataLib, http://www.automatalib.net/. 003 * 004 * AutomataLib is free software; you can redistribute it and/or 005 * modify it under the terms of the GNU Lesser General Public 006 * License version 3.0 as published by the Free Software Foundation. 007 * 008 * AutomataLib is distributed in the hope that it will be useful, 009 * but WITHOUT ANY WARRANTY; without even the implied warranty of 010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 011 * Lesser General Public License for more details. 012 * 013 * You should have received a copy of the GNU Lesser General Public 014 * License along with AutomataLib; if not, see 015 * http://www.gnu.de/documents/lgpl.en.html. 016 */ 017package net.automatalib.commons.util; 018 019public abstract class WrapperUtil { 020 021 public static boolean booleanValue(Boolean b, boolean def) { 022 return (b != null) ? b.booleanValue() : def; 023 } 024 025 public static boolean booleanValue(Boolean b) { 026 return booleanValue(b, false); 027 } 028 029 public static short shortValue(Short s, short def) { 030 return (s != null) ? s.shortValue() : def; 031 } 032 033 public static int intValue(Integer i, int def) { 034 return (i != null) ? i.intValue() : def; 035 } 036 037 public static int intValue(Integer i) { 038 return intValue(i, 0); 039 } 040 041 public static long longValue(Long l, long def) { 042 return (l != null) ? l.longValue() : def; 043 } 044 045 public static long longValue(Long l) { 046 return longValue(l, 0L); 047 } 048 049 public static float floatValue(Float f, float def) { 050 return (f != null) ? f.floatValue() : def; 051 } 052 053 public static float floatValue(Float f) { 054 return floatValue(f, 0.0f); 055 } 056 057 public static double doubleValue(Double d, double def) { 058 return (d != null) ? d.doubleValue() : def; 059 } 060 061 public static double doubleValue(Double d) { 062 return doubleValue(d, 0.0); 063 } 064 065}