MCPcopy Create free account
hub / github.com/antlr/codebuff / orNaturalOrder

Method orNaturalOrder

corpus/java/training/guava/collect/Maps.java:701–707  ·  view source on GitHub ↗

Returns the specified comparator if not null; otherwise returns Ordering.natural(). This method is an abomination of generics; the only purpose of this method is to contain the ugly type-casting in one place.

(@Nullable Comparator<? super E> comparator)

Source from the content-addressed store, hash-verified

699 * purpose of this method is to contain the ugly type-casting in one place.
700 */
701 @SuppressWarnings("unchecked")
702 static <E> Comparator<? super E> orNaturalOrder(@Nullable Comparator<? super E> comparator) {
703 if (comparator != null) { // can't use ? : because of javac bug 5080917
704 return comparator;
705 }
706 return (Comparator<E>) Ordering.natural();
707 }
708
709 /**
710 * Returns a live {@link Map} view whose keys are the contents of {@code set}

Callers 1

differenceMethod · 0.95

Calls 1

naturalMethod · 0.95

Tested by

no test coverage detected