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

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

Introduction

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

Prototype

public static boolean contains(Iterable<?> iterable, @Nullable Object element) 

Source Link

Document

Returns true if iterable contains any object for which equals(element) is true.

Usage

From source file:org.jclouds.examples.blobstore.hdfs.MainApp.java

public static void main(String[] args) throws IOException {

    if (args.length < PARAMETERS)
        throw new IllegalArgumentException(INVALID_SYNTAX);

    // Args/*  w w  w . j  a  va 2 s.c  om*/
    String provider = args[0];
    if (!Iterables.contains(BlobStoreUtils.getSupportedProviders(), provider))
        throw new IllegalArgumentException(
                "provider " + provider + " not in supported list: " + BlobStoreUtils.getSupportedProviders());
    String identity = args[1];
    String credential = args[2];
    String hdfsUrl = args[3];
    String containerName = args[4];
    String objectName = args[5];
    boolean plainhttp = args.length >= 7 && "plainhttp".equals(args[6]);
    String threadcount = args.length >= 8 ? args[7] : null;

    MainApp app = new MainApp();
    app.upload(provider, identity, credential, hdfsUrl, containerName, objectName, plainhttp, threadcount);
    System.exit(0);
}

From source file:edu.umn.msi.tropix.common.collect.Predicates2.java

public static <T> Predicate<T> isIn(final Iterable<?> iterable) {
    return new Predicate<T>() {
        public boolean apply(final T object) {
            return Iterables.contains(iterable, object);
        }/*from ww w.j av a  2  s .c  o m*/
    };
}

From source file:org.springframework.social.showcase.signin.SignInUtils.java

public static boolean isSignedIn() {
    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
    if (authentication == null) {
        return false;
    }/*from  ww w.j  a  v  a2  s. c  om*/

    Iterable<String> authorities = Iterables.transform(authentication.getAuthorities(), authorityName);

    return Iterables.contains(authorities, "ROLE_USER");
}

From source file:com.atlassian.jira.rest.client.IterableMatcher.java

public static <T> TypeSafeMatcher<Iterable<T>> contains(final T element) {
    return new TypeSafeMatcher<Iterable<T>>() {
        @Override// w w w  . j  a  v a 2s.com
        public boolean matchesSafely(Iterable<T> given) {
            return Iterables.contains(given, element);
        }

        @Override
        public void describeTo(Description description) {
            description.appendText("an iterable containing element " + element);
        }

    };
}

From source file:com.eightkdata.mongowp.bson.abst.AbstractIterableBasedBsonArray.java

@Override
public boolean contains(BsonValue<?> element) {
    return Iterables.contains(this, element);
}

From source file:org.eclipse.viatra.query.patternlanguage.emf.internal.DuplicationChecker.java

private static Predicate<IContainer> contains(final IResourceDescription resourceDescription) {
    return container -> Iterables.contains(container.getResourceDescriptions(), resourceDescription);
}

From source file:org.solovyev.common.collections.multimap.ObjectAddedUpdater.java

@Nullable
@Override/*from   www.  j a  va2s . c o  m*/
public List<V> update(@Nonnull List<V> values) {
    if (values == ThreadSafeMultimap.NO_VALUE) {
        return null;
    } else if (!Iterables.contains(values, newObject)) {
        final List<V> result = ThreadSafeMultimap.copy(values);
        result.add(newObject);
        return result;
    } else {
        return null;
    }
}

From source file:org.solovyev.common.collections.multimap.ObjectRemovedUpdater.java

@Nullable
@Override// www. j a va2s. c o  m
public List<V> update(@Nonnull List<V> values) {
    if (values == ThreadSafeMultimap.NO_VALUE) {
        return null;
    } else if (Iterables.contains(values, removedObject)) {
        final List<V> result = ThreadSafeMultimap.copy(values);
        result.remove(removedObject);
        return result;
    } else {
        return null;
    }
}

From source file:io.pelle.mango.client.base.util.CollectionUtils.java

public static <T> T addIfNotExists(Collection<T> collection, Predicate<T> predicate, T element) {

    if (!Iterables.contains(collection, predicate)) {
        collection.add(element);//from   www .j  a v  a 2  s .  c  o m
    }

    return element;
}

From source file:org.solovyev.common.collections.multimap.ObjectsAddedUpdater.java

@Nullable
@Override/*  w w  w  .  j a v a  2s .c o  m*/
public List<V> update(@Nonnull List<V> values) {
    if (values == ThreadSafeMultimap.NO_VALUE) {
        return null;
    } else {
        List<V> result = null;
        for (V newObject : newObjects) {
            if (!Iterables.contains(values, newObject)) {
                if (result == null) {
                    result = ThreadSafeMultimap.copy(values);
                }
                result.add(newObject);
            }
        }
        return result;
    }
}