Package com.cedarsoftware.util
Class MapUtilities
- java.lang.Object
-
- com.cedarsoftware.util.MapUtilities
-
public class MapUtilities extends Object
Usefule utilities for Maps- Author:
- Kenneth Partlow
Copyright (c) Cedar Software LLC
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> T
get(Map map, String key, T def)
Retrieves a value from a map by keystatic boolean
isEmpty(Map map)
Returns null safe isEmpty check for Map
-
-
-
Method Detail
-
get
public static <T> T get(Map map, String key, T def)
Retrieves a value from a map by key- Parameters:
map
- Map to retrieve item fromkey
- the key whose associated value is to be returneddef
- value to return if item was not found.- Returns:
- Returns a string value that was found at the location key. If the item is null then the def value is sent back. If the item is not the expected type, an exception is thrown.
- Throws:
ClassCastException
- if the item found is not a the expected type.
-
isEmpty
public static boolean isEmpty(Map map)
Returns null safe isEmpty check for Map- Parameters:
map
- Map to check, can be null- Returns:
- Returns true if map is empty or null
-
-