Example usage for com.google.common.collect ImmutableSortedSet copyOf

List of usage examples for com.google.common.collect ImmutableSortedSet copyOf

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableSortedSet copyOf.

Prototype

public static <E> ImmutableSortedSet<E> copyOf(Comparator<? super E> comparator,
            Iterator<? extends E> elements) 

Source Link

Usage

From source file:com.palantir.atlasdb.table.description.render.ColumnRenderers.java

static SortedSet<NamedColumnDescription> namedColumns(TableMetadata table) {
    return ImmutableSortedSet
            .copyOf(Ordering.natural().onResultOf(new Function<NamedColumnDescription, String>() {
                @Override//from   w w w .j  a  va 2 s .c o  m
                public String apply(NamedColumnDescription col) {
                    return col.getLongName();
                }
            }), table.getColumns().getNamedColumns());
}

From source file:com.facebook.buck.ide.intellij.lang.java.ParsingJavaPackageFinder.java

/**
 * Creates a hybrid {@link JavaPackageFinder} which will resolve packages for the selected paths
 * based on parsing the source files and use the fallbackPackageFinder for everything else.
 *
 * @param javaFileParser parser to read Java sources with.
 * @param projectFilesystem filesystem./* w ww.  j a  va 2  s.co  m*/
 * @param filesToParse set of files to parse.
 * @param fallbackPackageFinder package finder to use when the package can't be inferred from
 *     source.
 * @return the described PackageFinder.
 */
public static JavaPackageFinder preparse(final JavaFileParser javaFileParser,
        ProjectFilesystem projectFilesystem, ImmutableSet<Path> filesToParse,
        JavaPackageFinder fallbackPackageFinder) {
    JavaPackagePathCache packagePathCache = new JavaPackagePathCache();
    for (Path path : ImmutableSortedSet.copyOf(new PathComponentCountOrder(), filesToParse)) {
        Optional<String> packageNameFromSource = Optionals.bind(projectFilesystem.readFileIfItExists(path),
                javaFileParser::getPackageNameFromSource);
        if (packageNameFromSource.isPresent()) {
            Path javaPackagePath = findPackageFolderWithJavaPackage(packageNameFromSource.get());
            packagePathCache.insert(path, javaPackagePath);
        }
    }
    return new CacheBasedPackageFinder(fallbackPackageFinder, packagePathCache);
}

From source file:com.facebook.buck.ide.intellij.ParsingJavaPackageFinder.java

/**
 * Creates a hybrid {@link JavaPackageFinder} which will resolve packages for the selected paths
 * based on parsing the source files and use the fallbackPackageFinder for everything else.
 *
 * @param javaFileParser parser to read Java sources with.
 * @param projectFilesystem filesystem.//from  w  w  w  .j a v  a  2 s  . c om
 * @param filesToParse set of files to parse.
 * @param fallbackPackageFinder package finder to use when the package can't be inferred from
 *                              source.
 * @return the described PackageFinder.
 */
public static JavaPackageFinder preparse(final JavaFileParser javaFileParser,
        ProjectFilesystem projectFilesystem, ImmutableSet<Path> filesToParse,
        JavaPackageFinder fallbackPackageFinder) {
    PackagePathCache packagePathCache = new PackagePathCache();
    for (Path path : ImmutableSortedSet.copyOf(new PathComponentCountOrder(), filesToParse)) {
        Optional<String> packageNameFromSource = Optionals.bind(projectFilesystem.readFileIfItExists(path),
                javaFileParser::getPackageNameFromSource);
        if (packageNameFromSource.isPresent()) {
            Path javaPackagePath = findPackageFolderWithJavaPackage(packageNameFromSource.get());
            packagePathCache.insert(path, javaPackagePath);
        }
    }
    return new CacheBasedPackageFinder(fallbackPackageFinder, packagePathCache);
}

From source file:org.apache.calcite.util.NameSet.java

/** Creates a NameSet that is an immutable copy of a given collection. */
public static NameSet immutableCopyOf(Set<String> names) {
    return new NameSet(ImmutableSortedSet.copyOf(NameSet.COMPARATOR, names));
}

From source file:com.facebook.buck.jvm.java.MavenUberJar.java

private static BuildRuleParams adjustParams(BuildRuleParams params, TraversedDeps traversedDeps) {
    return params.copyWithDeps(
            Suppliers.ofInstance(ImmutableSortedSet.copyOf(Ordering.natural(), traversedDeps.packagedDeps)),
            Suppliers.ofInstance(ImmutableSortedSet.of()));
}

From source file:org.sonar.server.computation.qualityprofile.QPMeasureData.java

public QPMeasureData(Iterable<QualityProfile> qualityProfiles) {
    this.profiles = ImmutableSortedSet.copyOf(QualityProfileComparator.INSTANCE, qualityProfiles);
}

From source file:com.facebook.buck.features.project.intellij.lang.java.ParsingJavaPackageFinder.java

/**
 * Creates a hybrid {@link JavaPackageFinder} which will resolve packages for the selected paths
 * based on parsing the source files and use the fallbackPackageFinder for everything else.
 *
 * @param javaFileParser parser to read Java sources with.
 * @param projectFilesystem filesystem.//from ww w .j  ava  2  s  .  com
 * @param filesToParse set of files to parse.
 * @param fallbackPackageFinder package finder to use when the package can't be inferred from
 *     source.
 * @return the described PackageFinder.
 */
public static JavaPackageFinder preparse(JavaFileParser javaFileParser, ProjectFilesystem projectFilesystem,
        ImmutableSet<Path> filesToParse, JavaPackageFinder fallbackPackageFinder) {
    JavaPackagePathCache packagePathCache = new JavaPackagePathCache();
    PackagePathResolver packagePathResolver = new PackagePathResolver(javaFileParser, projectFilesystem);

    ImmutableSortedSet.copyOf(new PathComponentCountOrder(), filesToParse).parallelStream()
            .map(path -> new Pair<>(path, packagePathResolver.getPackagePathFromSource(path)))
            .filter(pair -> pair.getSecond().isPresent()).collect(Collectors.toList())
            .forEach(pair -> packagePathCache.insert(pair.getFirst(), pair.getSecond().get()));

    return new CacheBasedPackageFinder(fallbackPackageFinder, packagePathCache);
}

From source file:com.palantir.atlasdb.keyvalue.api.ColumnSelection.java

public static ColumnSelection create(Iterable<byte[]> selectedColumns) {
    if (Iterables.isEmpty(Preconditions.checkNotNull(selectedColumns))) {
        return allColumnsSelected;
    }//from w w w  .  j a  v a 2s  .c o m

    // Copy contents of 'selectedColumns' into a new set with proper deep comparison semantics.
    return new ColumnSelection(
            ImmutableSortedSet.copyOf(UnsignedBytes.lexicographicalComparator(), selectedColumns));
}

From source file:com.google.template.soy.types.aggregate.UnionType.java

private UnionType(Iterable<? extends SoyType> members) {
    this.members = ImmutableSortedSet.copyOf(MEMBER_ORDER, members);
    Preconditions.checkArgument(this.members.size() != 1);
    for (SoyType type : this.members) {
        if (type.getKind() == Kind.UNKNOWN) {
            throw new IllegalArgumentException("Cannot create unions containing unknown: " + this.members);
        }/*  w  w w .  j a  v  a  2 s . c  o m*/
    }
}

From source file:com.facebook.presto.bytecode.control.SwitchStatement.java

private SwitchStatement(String comment, BytecodeExpression expression, Iterable<CaseStatement> cases,
        BytecodeNode defaultBody) {//from ww  w .j a  v a 2s .  c  o m
    this.comment = comment;
    this.expression = requireNonNull(expression, "expression is null");
    this.cases = ImmutableSortedSet.copyOf(comparing(CaseStatement::getKey), cases);
    this.defaultBody = defaultBody;
}