public static Optional<Comparator<Val>> getComparatorForTypes(final Type type1,
                                                                  final Type type2,
                                                                  final boolean isCaseInsensitive) {
        if (type1 == null || type2 == null) {
            return Optional.empty();
        } else {
            return getComparatorFactory(type1, type2)
                    .map(comparatorFactory -> comparatorFactory.getComparator(isCaseInsensitive));
        }
    }
type1 and type2 can be in any order
stroom-query/stroom-query-language/src/main/java/stroom/query/language/functions/ValComparators.java