if (!isKeyType()) {
throw new RuntimeException("The type " + type.getName() + " is not Comparable.");
}
if (CopyableValue.class.isAssignableFrom(type)) {
return (TypeComparator<T>) new ValueComparator(sortOrderAscending, type);
}
else {
return (TypeComparator<T>) new CopyableValueComparator(sortOrderAscending, type);
}
}