Example usage for java.util Set contains

List of usage examples for java.util Set contains

Introduction

In this page you can find the example usage for java.util Set contains.

Prototype

boolean contains(Object o);

Source Link

Document

Returns true if this set contains the specified element.

Usage

From source file:info.archinnov.achilles.internals.parser.validator.BeanValidator.java

public static void validateIsAConcreteNonFinalClass(AptUtils aptUtils, TypeElement typeElement) {
    final Name name = typeElement.getQualifiedName();
    aptUtils.validateTrue(typeElement.getKind() == ElementKind.CLASS, "Bean type '%s' should be a class", name);
    final Set<Modifier> modifiers = typeElement.getModifiers();
    aptUtils.validateFalse(modifiers.contains(Modifier.ABSTRACT), "Bean type '%s' should not be abstract",
            name);/* ww  w .  j av  a2 s .co  m*/
    aptUtils.validateFalse(modifiers.contains(Modifier.FINAL), "Bean type '%s' should not be final", name);
}

From source file:com.technofovea.packbsp.crawling.AssetAlternative.java

/**
 * Returns a copy of the list which only contains the "top-most" entry for
 * each {@link AssetSource.Type}, and wraps hits within the {@link AssetAlternative} to
 * make future data comparisons easier./*ww  w .  j a  v  a 2  s .com*/
 * @param hits
 * @return
 */
public static List<AssetAlternative> screenTypes(List<AssetHit> hits) {
    Set<Type> seen = new HashSet<Type>();
    List<AssetAlternative> ret = new ArrayList<AssetAlternative>();

    for (AssetHit h : hits) {
        if (seen.contains(h.getSource().getType())) {
            continue;
        }
        seen.add(h.getSource().getType());
        ret.add(new AssetAlternative(h));
    }
    return ret;
}

From source file:graphs.Graphs.java

public static <V, E> String BreadthSearch(Graph<V, E> g) {
    StringBuilder b = new StringBuilder();

    Queue<V> Qu = new LinkedList<V>();
    Set<V> visited = new HashSet();
    Set<V> found = new HashSet();

    V start = (V) g.getVertices().toArray()[0];
    Qu.add(start);/*from  w ww  .j  a  va2s. c o m*/
    found.add(start);

    while (!Qu.isEmpty()) {
        V vertex = Qu.remove();
        for (V neighbor : g.getNeighbors(vertex)) {
            if (!found.contains(neighbor) && !visited.contains(neighbor)) {
                found.add(neighbor);
                Qu.add(neighbor);
            }
        }
        b.append(vertex.toString() + " ");
        visited.add(vertex);
    }

    return b.toString();
}

From source file:Main.java

public static <T> List<T> minius(Collection<T> c1, Set<T> s1) {

    if (c1 == null) {
        return Collections.emptyList();
    }//from   www .jav  a 2s. co m

    if (s1 == null || s1.size() == 0) {
        return new ArrayList<T>(c1);
    }
    List<T> list = new ArrayList<T>();
    for (T t : c1) {
        if (!s1.contains(t)) {
            list.add(t);
        }
    }
    return list;
}

From source file:com.astamuse.asta4d.web.form.flow.ext.ExcludingFieldRetrievableFormHelper.java

public static final void copyIncludeFieldsOnly(Object targetForm, ExcludingFieldRetrievableForm... froms) {
    try {/*ww w.  ja v  a  2s .c  om*/
        for (ExcludingFieldRetrievableForm from : froms) {
            List<AnnotatedPropertyInfo> fromProps = AnnotatedPropertyUtil.retrieveProperties(from.getClass());
            String[] excludes = from.getExcludeFields();
            Set<String> set = new HashSet<>();
            for (String s : excludes) {
                set.add(s);
            }
            for (AnnotatedPropertyInfo p : fromProps) {
                // do not copy excluded fields
                if (set.contains(p.getName())) {
                    continue;
                }
                AnnotatedPropertyUtil.assignValueByName(targetForm, p.getName(), p.retrieveValue(from));
            }

        }
    } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
        throw new RuntimeException(e);
    }
}

From source file:com.github.rvesse.airline.utils.AirlineUtils.java

public static <T> Set<T> intersection(Set<T> a, Set<T> b) {
    Set<T> intersection = new HashSet<T>();
    for (T item : a) {
        if (b.contains(item))
            intersection.add(item);/*from w w  w. ja v a  2s.  c  o m*/
    }
    return intersection;
}

From source file:com.asakusafw.compiler.bootstrap.OperatorCompilerDriver.java

private static List<File> toSources(File sourcePath, List<Class<?>> operatorClasses) throws IOException {
    assert sourcePath != null;
    assert operatorClasses != null;
    Set<File> results = new LinkedHashSet<File>();
    for (Class<?> aClass : operatorClasses) {
        File source = findSource(sourcePath, aClass);
        if (results.contains(source) == false) {
            results.add(source);//from ww  w  .j a v  a2s. co m
        }
    }
    return Lists.from(results);
}

From source file:net.sourceforge.jencrypt.lib.Utils.java

/**
 * Decode two bytes to Set of PosixFilePermission objects.
 * //from   w  ww  .j av  a 2s. c om
 * @param perms
 * @return
 */
public static byte[] permsToByte(Set<PosixFilePermission> perms) {

    int b1 = 0, b2 = 0;
    // @formatter:off
    if (perms.contains(OWNER_READ))
        b1 = (b1 | 1);
    if (perms.contains(OWNER_WRITE))
        b1 = (b1 | 2);
    if (perms.contains(OWNER_EXECUTE))
        b1 = (b1 | 4);

    if (perms.contains(GROUP_READ))
        b1 = (b1 | 8);
    if (perms.contains(GROUP_WRITE))
        b1 = (b1 | 16);
    if (perms.contains(GROUP_EXECUTE))
        b1 = (b1 | 32);

    if (perms.contains(OTHERS_READ))
        b1 = (b1 | 64);
    if (perms.contains(OTHERS_WRITE))
        b1 = (b1 | 128);
    if (perms.contains(OTHERS_EXECUTE))
        b2 = (b2 | 1);
    // @formatter:on

    return new byte[] { (byte) b1, (byte) b2 };
}

From source file:com.digitalreasoning.herman.JarCreater.java

public static void createJar(File outputJarFile, List<Entry> entries) throws IOException {
    if (!outputJarFile.getParentFile().exists()) {
        outputJarFile.getParentFile().mkdirs();
    }// ww  w. j  a  v a2 s  .  c o  m
    if (!outputJarFile.exists()) {
        outputJarFile.createNewFile();
    }

    FileOutputStream fOut = new FileOutputStream(outputJarFile);
    JarOutputStream jarOut = new JarOutputStream(fOut);
    Set<String> packageSet = new HashSet<String>();
    try {
        for (Entry folderFile : entries) {
            InputStream inputStream = folderFile.resource.openStream();

            try {
                if (!packageSet.contains(folderFile.parentFolderName)) {
                    jarOut.putNextEntry(new ZipEntry(folderFile.parentFolderName));
                    jarOut.closeEntry();
                    packageSet.add(folderFile.parentFolderName);
                }

                jarOut.putNextEntry(new ZipEntry(folderFile.parentFolderName
                        + (folderFile.parentFolderName.endsWith("/") ? "" : "/") + folderFile.fileName));
                IOUtils.copy(inputStream, jarOut);
                jarOut.closeEntry();
            } finally {
                inputStream.close();
            }

        }

    } finally {
        jarOut.close();
        fOut.close();
    }
}

From source file:MainClass.java

public static void test(Set s) {
    System.out.println(s.getClass().getName().replaceAll("\\w+\\.", ""));
    fill(s);/*  w w w  .j av a  2 s .c o m*/
    fill(s);
    fill(s);
    System.out.println(s); // No duplicates!

    s.addAll(s);
    s.add("one");
    s.add("one");
    s.add("one");
    System.out.println(s);

    System.out.println("s.contains(\"one\"): " + s.contains("one"));
}