Example usage for com.google.common.collect ImmutableSet of

List of usage examples for com.google.common.collect ImmutableSet of

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableSet of.

Prototype

@SuppressWarnings({ "unchecked" })
    public static <E> ImmutableSet<E> of() 

Source Link

Usage

From source file:de.cosmcode.palava.media.ConcreteAsset.java

@Override
public Set<ConcreteDirectory> getDirectories() {
    return ImmutableSet.of();
}

From source file:net.minecrell.serverlistplus.core.favicon.FaviconSearch.java

public static Set<String> findInFolder(ServerListPlusCore core, List<String> folders) {
    if (Helper.isNullOrEmpty(folders))
        return ImmutableSet.of();
    final Path pluginFolder = core.getPlugin().getPluginFolder();

    final PathMatcher image = pluginFolder.getFileSystem().getPathMatcher(IMAGE_PATTERN);
    DirectoryStream.Filter<Path> filter = new PathMatcherFilter(image);

    final Set<String> favicons = new HashSet<>();
    boolean recursive = core.getConf(PluginConf.class).Favicon.RecursiveFolderSearch;

    for (String folderPath : folders) {
        Path folder = pluginFolder.resolve(folderPath);
        if (!Files.isDirectory(folder)) {
            core.getLogger().log(WARN, "Invalid favicon folder in configuration: " + folder);
            continue;
        }/*  w ww . j  a  v  a2  s  . c  om*/

        if (recursive) { // Also check sub folders
            try { // Walk down the file tree
                Files.walkFileTree(folder, EnumSet.of(FileVisitOption.FOLLOW_LINKS), Integer.MAX_VALUE,
                        new SimpleFileVisitor<Path>() {
                            @Override
                            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
                                    throws IOException {
                                if (image.matches(file.getFileName()))
                                    favicons.add(pluginFolder.relativize(file).toString());
                                return FileVisitResult.CONTINUE;
                            }
                        });
            } catch (IOException e) {
                core.getLogger().log(WARN, "Unable to walk through file tree: {} -> {}", folder,
                        Helper.causedException(e));
            }
        } else { // Only this one folder
            try (DirectoryStream<Path> dir = Files.newDirectoryStream(folder, filter)) {
                for (Path file : dir)
                    favicons.add(pluginFolder.relativize(file).toString());
            } catch (IOException e) {
                core.getLogger().log(WARN, "Unable to get directory listing: {} -> {}", folder,
                        Helper.causedException(e));
            }
        }
    }

    return favicons;
}

From source file:org.onosproject.openstacknetworking.impl.OpenstackNodeServiceAdapter.java

@Override
public Set<OpenstackNode> completeNodes() {
    return ImmutableSet.of();
}

From source file:org.voltcore.messaging.FaultMessage.java

public FaultMessage(final long reportingSite, final long failedSite) {
    this.failedSite = failedSite;
    this.reportingSite = reportingSite;
    this.witnessed = true;
    this.survivors = ImmutableSet.of();
    this.decided = false;
}

From source file:com.google.inject.multibindings.MultibindingsScanner.java

/**
 * @deprecated This method returns an empty scanner since the preexisting functionality is
 *     installed by default./*w  w  w.ja  v  a  2 s  .  c  o m*/
 */
@Deprecated
public static ModuleAnnotatedMethodScanner scanner() {
    return new ModuleAnnotatedMethodScanner() {
        @Override
        public Set<? extends Class<? extends Annotation>> annotationClasses() {
            return ImmutableSet.of();
        }

        @Override
        public <T> Key<T> prepareMethod(Binder binder, Annotation annotation, Key<T> key,
                InjectionPoint injectionPoint) {
            throw new IllegalStateException("Unexpected annotation: " + annotation);
        }
    };
}

From source file:com.google.devtools.build.lib.packages.SkylarkNativeAspect.java

@Override
public ImmutableSet<String> getParamAttributes() {
    return ImmutableSet.of();
}

From source file:com.cloudera.science.ml.core.formula.Term.java

private Term() {
    // private constructor for the intercept term
    this.names = ImmutableSet.of();
}

From source file:ratpack.file.internal.ActivationBackedMimeTypes.java

private static Set<String> extractKnownMimeTypes() {
    try {/*from w  w w . j ava2 s.  c o m*/
        Function<Object, String> getMimeTypeFunction = new GetMimeTypeFunction();
        Field typeHashField = makeFieldAccessible(Class.forName("com.sun.activation.registries.MimeTypeFile"),
                "type_hash");
        Field mimeTypeFilesField = makeFieldAccessible(MimetypesFileTypeMap.class, "DB");
        Object mimeTypeFiles = mimeTypeFilesField.get(MIME_TYPES_MAP);
        Set<String> mimeTypes = Sets.newHashSet();
        for (int i = 0; i < Array.getLength(mimeTypeFiles); i++) {
            Object mimeTypeFile = Array.get(mimeTypeFiles, i);
            if (mimeTypeFile != null) {
                Map<?, ?> typeHash = (Map) typeHashField.get(mimeTypeFile);
                Iterables.addAll(mimeTypes, Iterables.transform(typeHash.values(), getMimeTypeFunction));
            }
        }
        return ImmutableSet.copyOf(mimeTypes);
    } catch (ReflectiveOperationException | NullPointerException ex) {
        return ImmutableSet.of();
    }
}

From source file:org.onosproject.cluster.PartitionDiff.java

public PartitionDiff(Partition oldValue, Partition newValue) {
    this.oldValue = oldValue;
    this.newValue = newValue;
    this.partitionId = oldValue.getId();
    this.currentMembers = oldValue == null ? ImmutableSet.of() : ImmutableSet.copyOf(oldValue.getMembers());
    this.newMembers = newValue == null ? ImmutableSet.of() : ImmutableSet.copyOf(newValue.getMembers());
}

From source file:com.spotify.ffwd.output.FakeBatchablePluginSinkBase.java

protected Metric convertBatchMetric(final Batch batch, final Batch.Point point) {
    final Map<String, String> allTags = new HashMap<>(batch.getCommonTags());
    allTags.putAll(point.getTags());/*from ww w . ja va2s . co m*/

    final Map<String, String> allResource = new HashMap<>(batch.getCommonResource());
    allResource.putAll(point.getResource());

    return new Metric(point.getKey(), point.getValue(), new Date(point.getTimestamp()), ImmutableSet.of(),
            allTags, allResource, null);
}