title: Pass a Map<String, String> to a method requiring Map<String, Object>
body: <p>I have a method with the following signature</p>
  
  <pre><code>public static ActionDefinition reverse(String action, Map&lt;String, Object&gt; args)
  </code></pre>
  
  <p>And I have method that returns the following:</p>
  
  <pre><code>public static Map&lt;String, String&gt; toMap(String value)
  </code></pre>
  
  <p>Is there some way I can cast the output of toMap to be used in reverse, something like:</p>
  
  <pre><code>ActionDefinition ad = reverse("Action.method", toMap("param1=value1,param2=value2"));
  </code></pre>
  
  <p>I'd need to do something like</p>
  
  <pre><code>(Map&lt;String, Object&gt;) toMap("param1=value1,param2=value2");
  </code></pre>
  
  <p>but I couldn't fin the way to do it</p>
  
  <p>I also tried with the following method</p>
  
  <pre><code>public static Map&lt;String, String&gt; toMap(String value) {
      Map&lt;String, Object&gt; source = toMap(value);
      Map&lt;String, String&gt; map = new LinkedHashMap&lt;String, String&gt;();
  
      for(Map.Entry&lt;String, Object&gt; entry: source.entrySet()) {
          map.put(entry.getKey(), (String) entry.getValue());
      }
  
      return map;
  }
  </code></pre>
  
  <p>but I guess that due to type erasure, I get that the method is duplicated...</p>
  
  <p>any idea?</p>
  
  <p>--</p>
  
  <p>edit</p>
  
  <p>I forgot to state that I can't change reverse method, as many have suggested so far...</p>