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

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

Introduction

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

Prototype

boolean contains(Object o);

Source Link

Document

Returns true if this set contains the specified element.

Usage

From source file:org.apache.abdera2.activities.model.ASBase.java

public static Selector<Map.Entry<String, Object>> withFields(String... names) {
    final ImmutableSet<String> list = ImmutableSet.copyOf(names);
    return new AbstractSelector<Map.Entry<String, Object>>() {
        public boolean select(Object item) {
            Map.Entry<String, Object> entry = (Entry<String, Object>) item;
            return list.contains(entry.getKey());
        }//  w w  w.  jav  a2 s . c o  m
    };
}

From source file:org.apache.abdera2.activities.model.ASBase.java

public static Selector<Map.Entry<String, Object>> withoutFields(Iterable<String> names) {
    final ImmutableSet<String> list = ImmutableSet.copyOf(names);
    return new AbstractSelector<Map.Entry<String, Object>>() {
        public boolean select(Object item) {
            Map.Entry<String, Object> entry = (Entry<String, Object>) item;
            return !list.contains(entry.getKey());
        }/*from   ww w .  j a v  a 2  s.co  m*/
    };
}

From source file:org.apache.abdera2.activities.model.ASBase.java

public static Selector<Map.Entry<String, Object>> withoutFields(String... names) {
    final ImmutableSet<String> list = ImmutableSet.copyOf(names);
    return new AbstractSelector<Map.Entry<String, Object>>() {
        public boolean select(Object item) {
            Map.Entry<String, Object> entry = (Entry<String, Object>) item;
            return !list.contains(entry.getKey());
        }/*from w  w w.ja v  a 2  s.  com*/
    };
}

From source file:org.apache.abdera2.common.protocol.RequestOptions.java

@SuppressWarnings("unchecked")
public static Selector<Map.Entry<String, Set<String>>> withHeaders(String... names) {
    final ImmutableSet<String> set = ImmutableSet.copyOf(names);
    return new AbstractSelector<Map.Entry<String, Set<String>>>() {
        public boolean select(Object item) {
            Map.Entry<String, Set<String>> entry = (Entry<String, Set<String>>) item;
            return set.contains(entry.getKey());
        }//from w w  w. j ava  2 s. c  o  m
    };
}

From source file:org.apache.abdera2.common.protocol.RequestOptions.java

@SuppressWarnings("unchecked")
public static Selector<Map.Entry<String, Set<String>>> withoutHeaders(String... names) {
    final ImmutableSet<String> set = ImmutableSet.copyOf(names);
    return new AbstractSelector<Map.Entry<String, Set<String>>>() {
        public boolean select(Object item) {
            Map.Entry<String, Set<String>> entry = (Entry<String, Set<String>>) item;
            return !set.contains(entry.getKey());
        }/*w  ww.j  a va  2s .  c  om*/
    };
}

From source file:org.elasticsearch.gateway.GatewayMetaState.java

/**
 * Loads the current meta state for each index in the new cluster state and checks if it has to be persisted.
 * Each index state that should be written to disk will be returned. This is only run for data only nodes.
 * It will return only the states for indices that actually have a shard allocated on the current node.
 *
 * @param previouslyWrittenIndices    A list of indices for which the state was already written before
 * @param potentiallyUnwrittenIndices The list of indices for which state should potentially be written
 * @param previousMetaData            The last meta data we know of. meta data for all indices in previouslyWrittenIndices list is persisted now
 * @param newMetaData                 The new metadata
 * @return iterable over all indices states that should be written to disk
 *///from   w  w w .  j  av  a 2 s. co m
public static Iterable<GatewayMetaState.IndexMetaWriteInfo> resolveStatesToBeWritten(
        ImmutableSet<String> previouslyWrittenIndices, Set<String> potentiallyUnwrittenIndices,
        MetaData previousMetaData, MetaData newMetaData) {
    List<GatewayMetaState.IndexMetaWriteInfo> indicesToWrite = new ArrayList<>();
    for (String index : potentiallyUnwrittenIndices) {
        IndexMetaData newIndexMetaData = newMetaData.index(index);
        IndexMetaData previousIndexMetaData = previousMetaData == null ? null : previousMetaData.index(index);
        String writeReason = null;
        if (previouslyWrittenIndices.contains(index) == false || previousIndexMetaData == null) {
            writeReason = "freshly created";
        } else if (previousIndexMetaData.version() != newIndexMetaData.version()) {
            writeReason = "version changed from [" + previousIndexMetaData.version() + "] to ["
                    + newIndexMetaData.version() + "]";
        }
        if (writeReason != null) {
            indicesToWrite.add(new GatewayMetaState.IndexMetaWriteInfo(newIndexMetaData, previousIndexMetaData,
                    writeReason));
        }
    }
    return indicesToWrite;
}

From source file:com.spectralogic.ds3autogen.c.CCodeGenerator.java

/**
 * Find all types that are used as an array member, for generation of a parser for a list of a type.  Only applies
 * to types that are wrapped in a common element.
 *//*from  w  w w  .j  a v  a  2s  .  c  o m*/
public static ImmutableSet<String> getArrayMemberTypes(final Ds3ApiSpec spec,
        final ImmutableSet<String> enumTypes) {
    return spec.getTypes().values().stream().flatMap(type -> type.getElements().stream())
            .filter(element -> element.getType().equalsIgnoreCase("array")) // only want types that array member types
            .filter(element -> !element.getComponentType().contains("UUID")) // ignore UUID
            .filter(element -> element.getDs3Annotations().stream()
                    .flatMap(anno -> anno.getDs3AnnotationElements().stream())
                    .anyMatch(annoElem -> annoElem.getValue().equals("SINGLE_BLOCK_FOR_ALL_ELEMENTS"))) // only want wrapped array types
            .filter(element -> !enumTypes.contains(EnumHelper.getDs3Type(element.getComponentType()))) // ignore enums
            .map(element -> StructHelper.getResponseTypeName(element.getComponentType()))
            .collect(GuavaCollectors.immutableSet());
}

From source file:com.facebook.buck.android.exopackage.NativeExoHelper.java

@VisibleForTesting
public static ImmutableMultimap<String, Path> filterLibrariesForAbi(Path nativeLibsDir,
        ImmutableMultimap<String, Path> allLibraries, String abi, ImmutableSet<String> ignoreLibraries) {
    ImmutableMultimap.Builder<String, Path> filteredLibraries = ImmutableMultimap.builder();
    for (Map.Entry<String, Path> entry : allLibraries.entries()) {
        Path relativePath = nativeLibsDir.relativize(entry.getValue());
        // relativePath is of the form libs/x86/foo.so, or assetLibs/x86/foo.so etc.
        Preconditions.checkState(relativePath.getNameCount() == 3);
        Preconditions.checkState(relativePath.getName(0).toString().equals("libs")
                || relativePath.getName(0).toString().equals("assetLibs"));
        String libAbi = relativePath.getParent().getFileName().toString();
        String libName = relativePath.getFileName().toString();
        if (libAbi.equals(abi) && !ignoreLibraries.contains(libName)) {
            filteredLibraries.put(entry);
        }/* w w  w  .ja va2s  .com*/
    }
    return filteredLibraries.build();
}

From source file:com.github.jsdossier.Config.java

private static Path getSourcePrefixPath(FileSystem fileSystem, ImmutableSet<Path> sources,
        ImmutableSet<Path> modules) {
    Path prefix = Paths.getCommonPrefix(fileSystem.getPath("").toAbsolutePath(),
            Iterables.concat(sources, modules));
    if (sources.contains(prefix) || modules.contains(prefix)) {
        prefix = prefix.getParent();//from   w  w w  . j a  v a2s  .  c  o m
    }
    return prefix;
}

From source file:com.github.jsdossier.Config.java

private static Predicate<DependencyInfo> isInSources(final Iterable<Path> sources, Path closureBaseDir) {
    final Function<DependencyInfo, Path> pathTransform = toPath(closureBaseDir);
    final ImmutableSet<Path> sourcesSet = FluentIterable.from(sources).transform(toAbsolutePath()).toSet();
    return new Predicate<DependencyInfo>() {
        @Override/*  www .  j a v a2s.  co  m*/
        public boolean apply(DependencyInfo input) {
            return sourcesSet.contains(pathTransform.apply(input));
        }
    };
}