Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import com.google.common.collect.Ordering;

import javax.annotation.Nonnull;
import java.util.*;

public class Main {
    public static <T> boolean isSortedSet(@Nonnull Comparator<? extends T> elementComparator,
            @Nonnull Iterable<? extends T> it) {
        if (it instanceof SortedSet) {
            SortedSet<? extends T> sortedSet = (SortedSet<? extends T>) it;
            Comparator<?> comparator = sortedSet.comparator();
            if (comparator == null) {
                return elementComparator.equals(Ordering.natural());
            }
            return elementComparator.equals(comparator);
        }
        return false;
    }
}