X-Git-Url: http://gitweb.fperrin.net/?p=DictionaryPC.git;a=blobdiff_plain;f=src%2Fcom%2Fhughes%2Futil%2FMapUtil.java;h=0976288f631e3057e349c8e1c2c0beed6a0b5f19;hp=a62a86ec0e557acbd11df56b854995898d015552;hb=945daa063c34b972b075860414a395ddfb560576;hpb=3170fb3a0fde1930a1f391164de212e6758aea43 diff --git a/src/com/hughes/util/MapUtil.java b/src/com/hughes/util/MapUtil.java index a62a86e..0976288 100644 --- a/src/com/hughes/util/MapUtil.java +++ b/src/com/hughes/util/MapUtil.java @@ -16,40 +16,11 @@ package com.hughes.util; import java.util.Map; -@SuppressWarnings({"WeakerAccess", "unused"}) public class MapUtil { - - public static V safeGet(final Map map, K key, V defaultValue) { - if (!map.containsKey(key)) { - return defaultValue; - } - return map.get(key); - } - - public static V safeGetOrPut(final Map map, K key, V defaultValue) { - if (!map.containsKey(key)) { - map.put(key, defaultValue); - } - return map.get(key); - } - - public static V safeGet(final Map map, K key, Class valueClass) { - if (!map.containsKey(key)) { - try { - map.put(key, valueClass.newInstance()); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - return map.get(key); - } - public static V safeRemove(final Map map, K key, V defaultValue) { if (!map.containsKey(key)) { return defaultValue; } return map.remove(key); } - - }