org.plumelib.util.ToStringComparator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of plume-util Show documentation
Show all versions of plume-util Show documentation
Utility libraries for Java. Complements Guava, Apache Commons, etc.
package org.plumelib.util;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import org.checkerframework.checker.mustcall.qual.MustCallUnknown;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.checker.signedness.qual.Signed;
/**
* A comparator that orders values based on the lexicographic ordering of their toString().
*
* It handles null values, sorting them according to their printed representation "null".
*/
// Once https://github.com/typetools/checker-framework/issues/1970 is fixed, Comparator's type
// argument should be marked as @Contravariant and this should be declared as "extends
// Comparator<@Nullable Object>".
public class ToStringComparator implements Comparator