converting Comparable from and to Comparator?
<p>I often have a <code>Comparator</code> type while I need a <code>Comparable</code> and the other way around. Is there a reusable JDK API to convert from one another? Something along the lines of:</p>

<pre><code>    public static &lt;C&gt; Comparable&lt;C&gt; toComparable(final Comparator&lt;C&gt; comparator) {
        // does not compile because Hidden can not extend C, 
        // but just to illustrate the idea
        final class Hidden extends C implements Comparable&lt;C&gt; {
            @Override
            public int compareTo(C another) {
                return comparator.compare((C) this, another);
            }
        };
        return new Hidden();
    }

    public static &lt;C extends Comparable&lt;C&gt;&gt; Comparator&lt;C&gt; toComparator(final Class&lt;C&gt; comparableClass) {
        return new Comparator&lt;C&gt;() {
            @Override
            public int compare(C first, C second) {
                assert comparableClass.equals(first.getClass());
                assert comparableClass.equals(second.getClass());
                return first.compareTo(second);
            }
        };
    }
</code></pre>
