Pretty print HashSet in Java
<p>I could find questions closer to this one, but not exactly what i was looking for. The problem is possibly pretty simple for many experts: I have a <code>Hashset</code> containing my customized bean as its content:</p>

<pre><code>Set&lt;TableColumnBean&gt; mySet = new HashSet&lt;TableColumnBean&gt;();
//loop and add values to Hashset
for(String str : tableColumnBeanMap.keySet()){
    mySet.add(new TableColumnBean(tableColumnBeanMap.get(str).getTable, `tableColumnBeanMap.get(str).getColumn))`
}
</code></pre>

<p>Here tableColumnBeanMap is a Map which contains list of beans of the type <code>TableColumnBean</code>. <code>TableColumnBean</code> is a simple bean which has two properties table and column. At the end of the loop, i want to pretty print the contents of set, which will be useful to keep as a debug log option. I could think of looping over the set using java for loop and prinitng contents. But at other places i have used <code>Jackson</code> library like:</p>

<pre><code>new ObjectMapper().writeWithDefaultPrettyPrinter().writeValueAsString(myMap)
</code></pre>

<p>which works wonderfully on maps. Do we have something similar which works on Sets as well? (Something one liner like Jackson's pretty print would be nice - as it produces very nice to read output format and also doesn't clutter your code either).</p>