Java HashMap Create toHashMapStrObj(Object object)

Here you can find the source of toHashMapStrObj(Object object)

Description

replacement of casting as from Object to HashMap<String, Object> without annoying warning.

License

Open Source License

Parameter

Parameter Description
object a parameter

Return

object it self which is casted as return type.

Declaration

@SuppressWarnings("unchecked")
public static HashMap<String, Object> toHashMapStrObj(Object object) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.HashMap;

public class Main {
    /**//from  w w  w. jav a  2s.c o  m
     * replacement of casting as from Object to
     * <tt>HashMap&lt;String, Object&gt;</tt> without annoying warning.
     * 
     * @param object
     * @return object it self which is casted as return type.
     */
    @SuppressWarnings("unchecked")
    public static HashMap<String, Object> toHashMapStrObj(Object object) {
        if (object == null) {
            return null;
        }
        return (HashMap<String, Object>) object;
    }
}

Related

  1. newHashMap(T key, U value)
  2. newHashMapWithCapacity(int expectedSize, float loadFactor)
  3. toHashMap( Entry[] entries)
  4. toHashMap(ArrayList list, int beginId)
  5. toHashMap(final Map map)