<p>Does any one know of some kind of Comparator factory in Java, with a </p>

<pre><code>public Comparator getComparatorForClass(Class clazz) {}
</code></pre>

<p>It would return Comparators for stuff like String, Double, Integer but would have a</p>

<pre><code>public void addComparatorForClass(Class clazz, Comparator comparator) {}
</code></pre>

<p>For arbitrary types.</p>

Instead of:
```
```
factory.getComparatorForClass(x.getClass()).compare(x, y)
```
```
you could simply implement
```
Comparable
```
and write:
```
```
x.compareTo(y)
```
```
String, the primitive wrappers, and standard collections already implement
```
Comparable
```
.