Java Code Examples for java.util.Comparators#NullComparator

The following examples show how to use java.util.Comparators#NullComparator . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Comparator.java    From desugar_jdk_libs with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns a null-friendly comparator that considers {@code null} to be
 * less than non-null. When both are {@code null}, they are considered
 * equal. If both are non-null, the specified {@code Comparator} is used
 * to determine the order. If the specified comparator is {@code null},
 * then the returned comparator considers all non-null values to be equal.
 *
 * <p>The returned comparator is serializable if the specified comparator
 * is serializable.
 *
 * @param  <T> the type of the elements to be compared
 * @param  comparator a {@code Comparator} for comparing non-null values
 * @return a comparator that considers {@code null} to be less than
 *         non-null, and compares non-null objects with the supplied
 *         {@code Comparator}.
 * @since 1.8
 */
public static <T> Comparator<T> nullsFirst(Comparator<? super T> comparator) {
    return new Comparators.NullComparator<>(true, comparator);
}
 
Example 2
Source File: Comparator.java    From openjdk-jdk9 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns a null-friendly comparator that considers {@code null} to be
 * greater than non-null. When both are {@code null}, they are considered
 * equal. If both are non-null, the specified {@code Comparator} is used
 * to determine the order. If the specified comparator is {@code null},
 * then the returned comparator considers all non-null values to be equal.
 *
 * <p>The returned comparator is serializable if the specified comparator
 * is serializable.
 *
 * @param  <T> the type of the elements to be compared
 * @param  comparator a {@code Comparator} for comparing non-null values
 * @return a comparator that considers {@code null} to be greater than
 *         non-null, and compares non-null objects with the supplied
 *         {@code Comparator}.
 * @since 1.8
 */
public static <T> Comparator<T> nullsLast(Comparator<? super T> comparator) {
    return new Comparators.NullComparator<>(false, comparator);
}
 
Example 3
Source File: Comparator.java    From jdk8u-jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns a null-friendly comparator that considers {@code null} to be
 * greater than non-null. When both are {@code null}, they are considered
 * equal. If both are non-null, the specified {@code Comparator} is used
 * to determine the order. If the specified comparator is {@code null},
 * then the returned comparator considers all non-null values to be equal.
 *
 * <p>The returned comparator is serializable if the specified comparator
 * is serializable.
 *
 * @param  <T> the type of the elements to be compared
 * @param  comparator a {@code Comparator} for comparing non-null values
 * @return a comparator that considers {@code null} to be greater than
 *         non-null, and compares non-null objects with the supplied
 *         {@code Comparator}.
 * @since 1.8
 */
public static <T> Comparator<T> nullsLast(Comparator<? super T> comparator) {
    return new Comparators.NullComparator<>(false, comparator);
}
 
Example 4
Source File: Comparator.java    From Bytecoder with Apache License 2.0 2 votes vote down vote up
/**
 * Returns a null-friendly comparator that considers {@code null} to be
 * greater than non-null. When both are {@code null}, they are considered
 * equal. If both are non-null, the specified {@code Comparator} is used
 * to determine the order. If the specified comparator is {@code null},
 * then the returned comparator considers all non-null values to be equal.
 *
 * <p>The returned comparator is serializable if the specified comparator
 * is serializable.
 *
 * @param  <T> the type of the elements to be compared
 * @param  comparator a {@code Comparator} for comparing non-null values
 * @return a comparator that considers {@code null} to be greater than
 *         non-null, and compares non-null objects with the supplied
 *         {@code Comparator}.
 * @since 1.8
 */
public static <T> Comparator<T> nullsLast(Comparator<? super T> comparator) {
    return new Comparators.NullComparator<>(false, comparator);
}
 
Example 5
Source File: Comparator.java    From openjdk-8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns a null-friendly comparator that considers {@code null} to be
 * less than non-null. When both are {@code null}, they are considered
 * equal. If both are non-null, the specified {@code Comparator} is used
 * to determine the order. If the specified comparator is {@code null},
 * then the returned comparator considers all non-null values to be equal.
 *
 * <p>The returned comparator is serializable if the specified comparator
 * is serializable.
 *
 * @param  <T> the type of the elements to be compared
 * @param  comparator a {@code Comparator} for comparing non-null values
 * @return a comparator that considers {@code null} to be less than
 *         non-null, and compares non-null objects with the supplied
 *         {@code Comparator}.
 * @since 1.8
 */
public static <T> Comparator<T> nullsFirst(Comparator<? super T> comparator) {
    return new Comparators.NullComparator<>(true, comparator);
}
 
Example 6
Source File: Comparator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns a null-friendly comparator that considers {@code null} to be
 * greater than non-null. When both are {@code null}, they are considered
 * equal. If both are non-null, the specified {@code Comparator} is used
 * to determine the order. If the specified comparator is {@code null},
 * then the returned comparator considers all non-null values to be equal.
 *
 * <p>The returned comparator is serializable if the specified comparator
 * is serializable.
 *
 * @param  <T> the type of the elements to be compared
 * @param  comparator a {@code Comparator} for comparing non-null values
 * @return a comparator that considers {@code null} to be greater than
 *         non-null, and compares non-null objects with the supplied
 *         {@code Comparator}.
 * @since 1.8
 */
public static <T> Comparator<T> nullsLast(Comparator<? super T> comparator) {
    return new Comparators.NullComparator<>(false, comparator);
}
 
Example 7
Source File: Comparator.java    From jdk8u_jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns a null-friendly comparator that considers {@code null} to be
 * greater than non-null. When both are {@code null}, they are considered
 * equal. If both are non-null, the specified {@code Comparator} is used
 * to determine the order. If the specified comparator is {@code null},
 * then the returned comparator considers all non-null values to be equal.
 *
 * <p>The returned comparator is serializable if the specified comparator
 * is serializable.
 *
 * @param  <T> the type of the elements to be compared
 * @param  comparator a {@code Comparator} for comparing non-null values
 * @return a comparator that considers {@code null} to be greater than
 *         non-null, and compares non-null objects with the supplied
 *         {@code Comparator}.
 * @since 1.8
 */
public static <T> Comparator<T> nullsLast(Comparator<? super T> comparator) {
    return new Comparators.NullComparator<>(false, comparator);
}
 
Example 8
Source File: Comparator.java    From hottub with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns a null-friendly comparator that considers {@code null} to be
 * greater than non-null. When both are {@code null}, they are considered
 * equal. If both are non-null, the specified {@code Comparator} is used
 * to determine the order. If the specified comparator is {@code null},
 * then the returned comparator considers all non-null values to be equal.
 *
 * <p>The returned comparator is serializable if the specified comparator
 * is serializable.
 *
 * @param  <T> the type of the elements to be compared
 * @param  comparator a {@code Comparator} for comparing non-null values
 * @return a comparator that considers {@code null} to be greater than
 *         non-null, and compares non-null objects with the supplied
 *         {@code Comparator}.
 * @since 1.8
 */
public static <T> Comparator<T> nullsLast(Comparator<? super T> comparator) {
    return new Comparators.NullComparator<>(false, comparator);
}
 
Example 9
Source File: Comparator.java    From jdk8u_jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns a null-friendly comparator that considers {@code null} to be
 * less than non-null. When both are {@code null}, they are considered
 * equal. If both are non-null, the specified {@code Comparator} is used
 * to determine the order. If the specified comparator is {@code null},
 * then the returned comparator considers all non-null values to be equal.
 *
 * <p>The returned comparator is serializable if the specified comparator
 * is serializable.
 *
 * @param  <T> the type of the elements to be compared
 * @param  comparator a {@code Comparator} for comparing non-null values
 * @return a comparator that considers {@code null} to be less than
 *         non-null, and compares non-null objects with the supplied
 *         {@code Comparator}.
 * @since 1.8
 */
public static <T> Comparator<T> nullsFirst(Comparator<? super T> comparator) {
    return new Comparators.NullComparator<>(true, comparator);
}
 
Example 10
Source File: Comparator.java    From Java8CN with Apache License 2.0 2 votes vote down vote up
/**
 * Returns a null-friendly comparator that considers {@code null} to be
 * less than non-null. When both are {@code null}, they are considered
 * equal. If both are non-null, the specified {@code Comparator} is used
 * to determine the order. If the specified comparator is {@code null},
 * then the returned comparator considers all non-null values to be equal.
 *
 * <p>The returned comparator is serializable if the specified comparator
 * is serializable.
 *
 * @param  <T> the type of the elements to be compared
 * @param  comparator a {@code Comparator} for comparing non-null values
 * @return a comparator that considers {@code null} to be less than
 *         non-null, and compares non-null objects with the supplied
 *         {@code Comparator}.
 * @since 1.8
 */
public static <T> Comparator<T> nullsFirst(Comparator<? super T> comparator) {
    return new Comparators.NullComparator<>(true, comparator);
}
 
Example 11
Source File: Comparator.java    From jdk1.8-source-analysis with Apache License 2.0 2 votes vote down vote up
/**
 * Returns a null-friendly comparator that considers {@code null} to be
 * less than non-null. When both are {@code null}, they are considered
 * equal. If both are non-null, the specified {@code Comparator} is used
 * to determine the order. If the specified comparator is {@code null},
 * then the returned comparator considers all non-null values to be equal.
 *
 * <p>The returned comparator is serializable if the specified comparator
 * is serializable.
 *
 * @param  <T> the type of the elements to be compared
 * @param  comparator a {@code Comparator} for comparing non-null values
 * @return a comparator that considers {@code null} to be less than
 *         non-null, and compares non-null objects with the supplied
 *         {@code Comparator}.
 * @since 1.8
 */
public static <T> Comparator<T> nullsFirst(Comparator<? super T> comparator) {
    return new Comparators.NullComparator<>(true, comparator);
}
 
Example 12
Source File: Comparator.java    From JDKSourceCode1.8 with MIT License 2 votes vote down vote up
/**
 * Returns a null-friendly comparator that considers {@code null} to be
 * greater than non-null. When both are {@code null}, they are considered
 * equal. If both are non-null, the specified {@code Comparator} is used
 * to determine the order. If the specified comparator is {@code null},
 * then the returned comparator considers all non-null values to be equal.
 *
 * <p>The returned comparator is serializable if the specified comparator
 * is serializable.
 *
 * @param  <T> the type of the elements to be compared
 * @param  comparator a {@code Comparator} for comparing non-null values
 * @return a comparator that considers {@code null} to be greater than
 *         non-null, and compares non-null objects with the supplied
 *         {@code Comparator}.
 * @since 1.8
 */
public static <T> Comparator<T> nullsLast(Comparator<? super T> comparator) {
    return new Comparators.NullComparator<>(false, comparator);
}
 
Example 13
Source File: Comparator.java    From JDKSourceCode1.8 with MIT License 2 votes vote down vote up
/**
 * Returns a null-friendly comparator that considers {@code null} to be
 * less than non-null. When both are {@code null}, they are considered
 * equal. If both are non-null, the specified {@code Comparator} is used
 * to determine the order. If the specified comparator is {@code null},
 * then the returned comparator considers all non-null values to be equal.
 *
 * <p>The returned comparator is serializable if the specified comparator
 * is serializable.
 *
 * @param  <T> the type of the elements to be compared
 * @param  comparator a {@code Comparator} for comparing non-null values
 * @return a comparator that considers {@code null} to be less than
 *         non-null, and compares non-null objects with the supplied
 *         {@code Comparator}.
 * @since 1.8
 */
public static <T> Comparator<T> nullsFirst(Comparator<? super T> comparator) {
    return new Comparators.NullComparator<>(true, comparator);
}
 
Example 14
Source File: Comparator.java    From jdk8u60 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns a null-friendly comparator that considers {@code null} to be
 * greater than non-null. When both are {@code null}, they are considered
 * equal. If both are non-null, the specified {@code Comparator} is used
 * to determine the order. If the specified comparator is {@code null},
 * then the returned comparator considers all non-null values to be equal.
 *
 * <p>The returned comparator is serializable if the specified comparator
 * is serializable.
 *
 * @param  <T> the type of the elements to be compared
 * @param  comparator a {@code Comparator} for comparing non-null values
 * @return a comparator that considers {@code null} to be greater than
 *         non-null, and compares non-null objects with the supplied
 *         {@code Comparator}.
 * @since 1.8
 */
public static <T> Comparator<T> nullsLast(Comparator<? super T> comparator) {
    return new Comparators.NullComparator<>(false, comparator);
}
 
Example 15
Source File: Comparator.java    From jdk8u60 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns a null-friendly comparator that considers {@code null} to be
 * less than non-null. When both are {@code null}, they are considered
 * equal. If both are non-null, the specified {@code Comparator} is used
 * to determine the order. If the specified comparator is {@code null},
 * then the returned comparator considers all non-null values to be equal.
 *
 * <p>The returned comparator is serializable if the specified comparator
 * is serializable.
 *
 * @param  <T> the type of the elements to be compared
 * @param  comparator a {@code Comparator} for comparing non-null values
 * @return a comparator that considers {@code null} to be less than
 *         non-null, and compares non-null objects with the supplied
 *         {@code Comparator}.
 * @since 1.8
 */
public static <T> Comparator<T> nullsFirst(Comparator<? super T> comparator) {
    return new Comparators.NullComparator<>(true, comparator);
}
 
Example 16
Source File: Comparator.java    From jdk8u-dev-jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns a null-friendly comparator that considers {@code null} to be
 * less than non-null. When both are {@code null}, they are considered
 * equal. If both are non-null, the specified {@code Comparator} is used
 * to determine the order. If the specified comparator is {@code null},
 * then the returned comparator considers all non-null values to be equal.
 *
 * <p>The returned comparator is serializable if the specified comparator
 * is serializable.
 *
 * @param  <T> the type of the elements to be compared
 * @param  comparator a {@code Comparator} for comparing non-null values
 * @return a comparator that considers {@code null} to be less than
 *         non-null, and compares non-null objects with the supplied
 *         {@code Comparator}.
 * @since 1.8
 */
public static <T> Comparator<T> nullsFirst(Comparator<? super T> comparator) {
    return new Comparators.NullComparator<>(true, comparator);
}
 
Example 17
Source File: Comparator.java    From TencentKona-8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns a null-friendly comparator that considers {@code null} to be
 * less than non-null. When both are {@code null}, they are considered
 * equal. If both are non-null, the specified {@code Comparator} is used
 * to determine the order. If the specified comparator is {@code null},
 * then the returned comparator considers all non-null values to be equal.
 *
 * <p>The returned comparator is serializable if the specified comparator
 * is serializable.
 *
 * @param  <T> the type of the elements to be compared
 * @param  comparator a {@code Comparator} for comparing non-null values
 * @return a comparator that considers {@code null} to be less than
 *         non-null, and compares non-null objects with the supplied
 *         {@code Comparator}.
 * @since 1.8
 */
public static <T> Comparator<T> nullsFirst(Comparator<? super T> comparator) {
    return new Comparators.NullComparator<>(true, comparator);
}
 
Example 18
Source File: Comparator.java    From j2objc with Apache License 2.0 2 votes vote down vote up
/**
 * Returns a null-friendly comparator that considers {@code null} to be
 * less than non-null. When both are {@code null}, they are considered
 * equal. If both are non-null, the specified {@code Comparator} is used
 * to determine the order. If the specified comparator is {@code null},
 * then the returned comparator considers all non-null values to be equal.
 *
 * <p>The returned comparator is serializable if the specified comparator
 * is serializable.
 *
 * @param  <T> the type of the elements to be compared
 * @param  comparator a {@code Comparator} for comparing non-null values
 * @return a comparator that considers {@code null} to be less than
 *         non-null, and compares non-null objects with the supplied
 *         {@code Comparator}.
 * @since 1.8
 */
public static <T> Comparator<T> nullsFirst(Comparator<? super T> comparator) {
    return new Comparators.NullComparator<>(true, comparator);
}
 
Example 19
Source File: Comparator.java    From jdk8u-jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns a null-friendly comparator that considers {@code null} to be
 * less than non-null. When both are {@code null}, they are considered
 * equal. If both are non-null, the specified {@code Comparator} is used
 * to determine the order. If the specified comparator is {@code null},
 * then the returned comparator considers all non-null values to be equal.
 *
 * <p>The returned comparator is serializable if the specified comparator
 * is serializable.
 *
 * @param  <T> the type of the elements to be compared
 * @param  comparator a {@code Comparator} for comparing non-null values
 * @return a comparator that considers {@code null} to be less than
 *         non-null, and compares non-null objects with the supplied
 *         {@code Comparator}.
 * @since 1.8
 */
public static <T> Comparator<T> nullsFirst(Comparator<? super T> comparator) {
    return new Comparators.NullComparator<>(true, comparator);
}
 
Example 20
Source File: Comparator.java    From jdk8u-dev-jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns a null-friendly comparator that considers {@code null} to be
 * greater than non-null. When both are {@code null}, they are considered
 * equal. If both are non-null, the specified {@code Comparator} is used
 * to determine the order. If the specified comparator is {@code null},
 * then the returned comparator considers all non-null values to be equal.
 *
 * <p>The returned comparator is serializable if the specified comparator
 * is serializable.
 *
 * @param  <T> the type of the elements to be compared
 * @param  comparator a {@code Comparator} for comparing non-null values
 * @return a comparator that considers {@code null} to be greater than
 *         non-null, and compares non-null objects with the supplied
 *         {@code Comparator}.
 * @since 1.8
 */
public static <T> Comparator<T> nullsLast(Comparator<? super T> comparator) {
    return new Comparators.NullComparator<>(false, comparator);
}