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 extends Comparable<? super E>> ImmutableSortedSet<E> copyOf(E[] elements) 

Source Link

Usage

From source file:com.techcavern.pircbotz.UserChannelDao.java

/**
 * Get all user's in the channel. There are some important things to note about this method:
 * <ul>// w  w  w.ja va2s .  co m
 * <li>This method may not return a full list of users if you call it
 * before the complete nick list has arrived from the IRC server.</li>
 * <li>If you wish to find out which users are in a channel as soon
 * as you join it, then you should listen for a {@link UserListEvent}
 * instead of calling this method, as the {@link UserListEvent} is only
 * dispatched as soon as the full user list has been received.</li>
 * <li>This method will return immediately, as it does not require any
 * interaction with the IRC server.</li>
 * </ul>
 *
 * @since PircBot 1.0.0
 *
 * @param chan The channel object to search in
 * @return A Set of all user's in the channel
 *
 * @see UserListEvent
 */
@Synchronized("accessLock")
public ImmutableSortedSet<U> getAllUsers() {
    return ImmutableSortedSet.copyOf(userNickMap.values());
}

From source file:org.onosproject.onosjar.OnosJarStepFactory.java

@Override
public void createCompileToJarStep(BuildContext context, ImmutableSortedSet<Path> sourceFilePaths,
        BuildTarget invokingRule, SourcePathResolver resolver, ProjectFilesystem filesystem,
        ImmutableSortedSet<Path> declaredClasspathEntries, Path outputDirectory,
        Optional<Path> workingDirectory, Path pathToSrcsList, Optional<SuggestBuildRules> suggestBuildRules,
        ImmutableList<String> postprocessClassesCommands, ImmutableSortedSet<Path> entriesToJar,
        Optional<String> mainClass, Optional<Path> manifestFile, Path outputJar,
        ClassUsageFileWriter usedClassesFileWriter, ImmutableList.Builder<Step> steps,
        BuildableContext buildableContext, ImmutableSet<Pattern> classesToRemoveFromJar) {

    ImmutableSet.Builder<Path> sourceFilePathBuilder = ImmutableSet.builder();
    sourceFilePathBuilder.addAll(sourceFilePaths);

    ImmutableSet.Builder<Pattern> blacklistBuilder = ImmutableSet.builder();
    blacklistBuilder.addAll(classesToRemoveFromJar);

    // precompilation steps
    //   - generate sources
    //     add all generated sources ot pathToSrcsList
    if (webContext != null && apiTitle != null && resources.isPresent()) {
        ImmutableSortedSet<Path> resourceFilePaths = findSwaggerModelDefs(resolver, resources.get());
        blacklistBuilder.addAll(resourceFilePaths.stream()
                .map(rp -> Pattern.compile(rp.getFileName().toString(), Pattern.LITERAL))
                .collect(Collectors.toSet()));
        Path genSourcesOutput = workingDirectory.get();

        SwaggerStep swaggerStep = new SwaggerStep(filesystem, sourceFilePaths, resourceFilePaths,
                genSourcesOutput, outputDirectory, webContext, apiTitle, apiVersion, apiPackage,
                apiDescription);/* ww w  .ja  v a  2 s  .co m*/
        sourceFilePathBuilder.add(swaggerStep.apiRegistratorPath());
        steps.add(swaggerStep);

        //            steps.addAll(sourceFilePaths.stream()
        //                    .filter(sp -> sp.startsWith("src/main/webapp/"))
        //                    .map(sp -> CopyStep.forFile(filesystem, sp, outputDirectory))
        //                    .iterator());
    }

    createCompileStep(context, ImmutableSortedSet.copyOf(sourceFilePathBuilder.build()), invokingRule, resolver,
            filesystem, declaredClasspathEntries, outputDirectory, workingDirectory, pathToSrcsList,
            suggestBuildRules, usedClassesFileWriter, steps, buildableContext);

    // post compilation steps

    // FIXME BOC: add mechanism to inject new Steps
    //context.additionalStepFactory(JavaStep.class);

    // build the jar
    steps.add(new JarDirectoryStep(filesystem, outputJar, ImmutableSortedSet.of(outputDirectory),
            mainClass.orNull(), manifestFile.orNull(), true, blacklistBuilder.build()));

    OSGiWrapper osgiStep = new OSGiWrapper(outputJar, //input jar
            outputJar, //Paths.get(outputJar.toString() + ".jar"), //output jar
            invokingRule.getBasePath(), // sources dir
            outputDirectory, // classes dir
            declaredClasspathEntries, // classpath
            bundleName, // bundle name
            groupId, // groupId
            bundleVersion, // bundle version
            bundleLicense, // bundle license
            importPackages, // import packages
            exportPackages, // export packages
            includeResources, // include resources
            webContext, // web context
            dynamicimportPackages, // dynamic import packages
            bundleDescription // bundle description
    );
    steps.add(osgiStep);

    //steps.add(CopyStep.forFile(filesystem, Paths.get(outputJar.toString() + ".jar"), outputJar));

}

From source file:org.smartdeveloperhub.vocabulary.util.Module.java

public Set<String> priorVersions() {
    return ImmutableSortedSet.copyOf(this.priorVersions);
}

From source file:com.facebook.buck.rules.BuildInfoRecorder.java

/**
 * Creates a zip file of the metadata and recorded artifacts and stores it in the artifact cache.
 *///from  w  ww  .  j a  va 2  s. c  o m
public void performUploadToArtifactCache(ArtifactCache artifactCache, BuckEventBus eventBus) {
    // Skip all of this if caching is disabled. Although artifactCache.store() will be a noop,
    // building up the zip is wasted I/O.
    if (!artifactCache.isStoreSupported()) {
        return;
    }

    ImmutableSet.Builder<Path> pathsToIncludeInZipBuilder = ImmutableSet.<Path>builder()
            .addAll(Iterables.transform(metadataToWrite.keySet(), new Function<String, Path>() {
                @Override
                public Path apply(String key) {
                    return pathToMetadataDirectory.resolve(key);
                }
            })).addAll(pathsToOutputFiles);

    try {
        for (Path outputDirectory : pathsToOutputDirectories) {
            pathsToIncludeInZipBuilder.addAll(getEntries(outputDirectory));
        }
    } catch (IOException e) {
        throw new RuntimeException(e);
    }

    ImmutableSet<Path> pathsToIncludeInZip = pathsToIncludeInZipBuilder.build();
    File zip;
    try {
        zip = File.createTempFile(buildTarget.getFullyQualifiedName().replace('/', '_'), ".zip");
        projectFilesystem.createZip(pathsToIncludeInZip, zip);
    } catch (IOException e) {
        eventBus.post(LogEvent.info("Failed to create zip for %s containing:\n%s", buildTarget,
                Joiner.on('\n').join(ImmutableSortedSet.copyOf(pathsToIncludeInZip))));
        e.printStackTrace();
        return;
    }
    artifactCache.store(ruleKey, zip);
    zip.delete();
}

From source file:com.google.enterprise.connector.instantiator.TypeMap.java

public Set<String> getConnectorTypeNames() {
    return ImmutableSortedSet.copyOf(innerMap.keySet());
}

From source file:org.smartdeveloperhub.vocabulary.util.Module.java

public Set<String> imports() {
    return ImmutableSortedSet.copyOf(this.imports);
}

From source file:com.facebook.buck.apple.AppleBinaryDescription.java

private Collection<ImmutableSortedSet<Flavor>> generateThinDelegateFlavors(
        ImmutableSet<Flavor> delegateFlavors) {
    return MultiarchFileInfos.generateThinFlavors(platformFlavorsToAppleCxxPlatforms.getFlavors(),
            ImmutableSortedSet.copyOf(delegateFlavors));
}

From source file:google.registry.rdap.RdapNameserverSearchAction.java

/** Searches for nameservers by name, returning a JSON array of nameserver info maps. */
private RdapSearchResults searchByName(final RdapSearchPattern partialStringQuery, final DateTime now) {
    // Handle queries without a wildcard -- just load by foreign key.
    if (!partialStringQuery.getHasWildcard()) {
        HostResource hostResource = loadByForeignKey(HostResource.class, partialStringQuery.getInitialString(),
                now);//from  w  w  w .j av a  2s  .  com
        if (hostResource == null) {
            throw new NotFoundException("No nameservers found");
        }
        return RdapSearchResults.create(ImmutableList.of(rdapJsonFormatter.makeRdapJsonForHost(hostResource,
                false, rdapLinkBase, rdapWhoisServer, now, OutputDataType.FULL)));
        // Handle queries with a wildcard, but no suffix. There are no pending deletes for hosts, so we
        // can call queryUndeleted.
    } else if (partialStringQuery.getSuffix() == null) {
        return makeSearchResults(
                // Add 1 so we can detect truncation.
                queryUndeleted(HostResource.class, "fullyQualifiedHostName", partialStringQuery,
                        rdapResultSetMaxSize + 1).list(),
                now);
        // Handle queries with a wildcard and a suffix. In this case, it is more efficient to do things
        // differently. We use the suffix to look up the domain, then loop through the subordinate hosts
        // looking for matches.
    } else {
        DomainResource domainResource = loadByForeignKey(DomainResource.class, partialStringQuery.getSuffix(),
                now);
        if (domainResource == null) {
            throw new NotFoundException("No domain found for specified nameserver suffix");
        }
        ImmutableList.Builder<HostResource> hostListBuilder = new ImmutableList.Builder<>();
        for (String fqhn : ImmutableSortedSet.copyOf(domainResource.getSubordinateHosts())) {
            // We can't just check that the host name starts with the initial query string, because then
            // the query ns.exam*.example.com would match against nameserver ns.example.com.
            if (partialStringQuery.matches(fqhn)) {
                HostResource hostResource = loadByForeignKey(HostResource.class, fqhn, now);
                if (hostResource != null) {
                    hostListBuilder.add(hostResource);
                }
            }
        }
        return makeSearchResults(hostListBuilder.build(), now);
    }
}

From source file:org.geoserver.security.iride.IrideRoleService.java

@Override
public SortedSet<GeoServerRole> getRolesForUser(final String username) throws IOException {
    LOGGER.trace("User: {}", username);

    final TreeSet<GeoServerRole> roles = new TreeSet<>();

    final IrideIdentity irideIdentity = IrideIdentity.parseIrideIdentity(username);
    if (irideIdentity != null) {
        final IrideRole[] irideRoles = this.getIrideService().findRuoliForPersonaInApplication(irideIdentity,
                new IrideApplication(this.config.applicationName));
        for (final IrideRole irideRole : irideRoles) {
            roles.add(this.createRoleObject(irideRole.toMnemonicRepresentation()));
        }//  ww w  .ja v a 2s .c om
    }

    // Rely on the fallback RoleService (if configured) when no IRIDE roles are available for the given user
    if (roles.isEmpty() && this.config.hasFallbackRoleServiceName()) {
        LOGGER.info("No IRIDE roles available for the given user {}: falling back to RoleService '{}'",
                username, this.config.fallbackRoleServiceName);

        final GeoServerRoleService fallbackRoleService = this.getSecurityManager()
                .loadRoleService(this.config.fallbackRoleServiceName);
        if (fallbackRoleService != null) {
            roles.addAll(fallbackRoleService.getRolesForUser(username));
        } else {
            LOGGER.warn("A fallback RoleService '{}' was specified, but none was found!",
                    this.config.fallbackRoleServiceName);
        }
    }

    LOGGER.trace("Added {} roles for User {}", roles.size(), username);

    return ImmutableSortedSet.copyOf(roles);
}

From source file:org.jooby.internal.MutantImpl.java

@Override
public <T extends Comparable<T>> SortedSet<T> toSortedSet(final Class<T> type) {
    T[] array = asArray(type);/*from   w ww .  jav a  2s.c  o  m*/
    return ImmutableSortedSet.copyOf(array);
}