Example usage for java.util List contains

List of usage examples for java.util List contains

Introduction

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

Prototype

boolean contains(Object o);

Source Link

Document

Returns true if this list contains the specified element.

Usage

From source file:com.thoughtworks.go.matchers.ConsoleOutMatcher.java

public static TypeSafeMatcher<List> containsState(final Object jobState) {
    return new TypeSafeMatcher<List>() {
        private List states;

        public boolean matchesSafely(List states) {
            this.states = states;
            return states.contains(jobState);
        }/*from   w  w w .j a  v  a  2  s . co  m*/

        public void describeTo(Description description) {
            description.appendText("Expected console to contain [" + jobState + "] but was " + states);
        }
    };
}

From source file:gov.nih.nci.firebird.selenium2.pages.util.VerificationUtils.java

public static void checkForMessage(List<String> messages, String messageKey, Object... replacements) {
    String message = getPropertyText(messageKey, replacements);
    assertTrue(message + " not found in ValidationException: " + messages, messages.contains(message));
}

From source file:com.thoughtworks.go.matchers.ConsoleOutMatcher.java

public static TypeSafeMatcher<List> containsResult(final Object jobResult) {
    return new TypeSafeMatcher<List>() {
        private List results;

        public boolean matchesSafely(List states) {
            this.results = states;
            return states.contains(jobResult);
        }/*ww w. ja va2  s  .  c  o m*/

        public void describeTo(Description description) {
            description.appendText("Expected console to contain [" + jobResult + "] but was " + results);
        }
    };
}

From source file:net.sf.jabref.sql.SQLUtil.java

/**
 * Inserts the elements of a List into another List making sure not to duplicate entries in the resulting List
 *
 * @param list1 The List containing unique entries
 * @param list2 The second List to be inserted into the first List
 * @return The updated list1 with new unique entries
 *///from ww  w. ja va2  s  .c  o m
private static List<String> uniqueListInsert(List<String> list1, List<String> list2) {
    if (list2 != null) {
        for (String fromList2 : list2) {
            if (!list1.contains(fromList2) && (!"#".equals(fromList2))) {
                list1.add(fromList2);
            }
        }
    }
    return list1;
}

From source file:com.robertsmieja.test.utils.junit.GettersAndSettersUtils.java

static List<Field> getFields(Class<?> aClass, Predicate<Field> fieldPredicate) {
    List<Field> allFields = FieldUtils.getAllFieldsList(aClass);
    List<Field> excludedFields = FieldUtils.getFieldsListWithAnnotation(aClass, IgnoreForTests.class);
    return allFields.stream().filter(field -> !field.isSynthetic())
            .filter(field -> !excludedFields.contains(field)).filter(field -> !isFinal(field.getModifiers()))
            .filter(fieldPredicate).collect(Collectors.toList());
}

From source file:DeadlockDetectingLock.java

private static synchronized void freeIfHardwait(List l, Thread t) {
    if (l.contains(t))
        l.remove(t);/*w  w w.  ja v  a2 s .com*/
}

From source file:DeadlockDetectingLock.java

private static synchronized void markAsHardwait(List l, Thread t) {
    if (!l.contains(t))
        l.add(t);//from   ww  w  .jav  a  2s. com
}

From source file:Main.java

public static List<String>[] diff(List<String> list1, List<String> list2) {
    if (list1 == null)
        list1 = new ArrayList<String>();
    if (list2 == null)
        list2 = new ArrayList<String>();

    List<String> toAddList = new ArrayList<String>();
    List<String> toDelList = new ArrayList<String>();

    for (String str1 : list1) {
        if (!list2.contains(str1)) {
            toAddList.add(str1);/*from  w  w w  .  j av  a2 s. c om*/
        }
    }

    for (String str2 : list2) {
        if (!list1.contains(str2)) {
            toDelList.add(str2);
        }
    }

    return new List[] { toAddList, toDelList };
}

From source file:com.ge.predix.web.cors.CORSFilter.java

private static boolean containsHeader(final String accessControlRequestHeaders, final String header) {
    List<String> headers = Arrays.asList(accessControlRequestHeaders.replace(" ", "").toLowerCase().split(","));
    return headers.contains(header.toLowerCase());
}

From source file:com.cburch.draw.shapes.SvgReader.java

public static AbstractCanvasObject createShape(Element elt) {
    String name = elt.getTagName();
    AbstractCanvasObject ret;//w ww  .  java  2  s.c o m
    if (name.equals("ellipse")) {
        ret = createOval(elt);
    } else if (name.equals("line")) {
        ret = createLine(elt);
    } else if (name.equals("path")) {
        ret = createPath(elt);
    } else if (name.equals("polyline")) {
        ret = createPolyline(elt);
    } else if (name.equals("polygon")) {
        ret = createPolygon(elt);
    } else if (name.equals("rect")) {
        ret = createRectangle(elt);
    } else if (name.equals("text")) {
        ret = createText(elt);
    } else {
        return null;
    }
    List<Attribute<?>> attrs = ret.getAttributes();
    if (attrs.contains(DrawAttr.PAINT_TYPE)) {
        String stroke = elt.getAttribute("stroke");
        String fill = elt.getAttribute("fill");
        if (stroke.equals("") || stroke.equals("none")) {
            ret.setValue(DrawAttr.PAINT_TYPE, DrawAttr.PAINT_FILL);
        } else if (fill.equals("none")) {
            ret.setValue(DrawAttr.PAINT_TYPE, DrawAttr.PAINT_STROKE);
        } else {
            ret.setValue(DrawAttr.PAINT_TYPE, DrawAttr.PAINT_STROKE_FILL);
        }
    }
    attrs = ret.getAttributes(); // since changing paintType could change it
    if (attrs.contains(DrawAttr.STROKE_WIDTH) && elt.hasAttribute("stroke-width")) {
        Integer width = Integer.valueOf(elt.getAttribute("stroke-width"));
        ret.setValue(DrawAttr.STROKE_WIDTH, width);
    }
    if (attrs.contains(DrawAttr.STROKE_COLOR)) {
        String color = elt.getAttribute("stroke");
        String opacity = elt.getAttribute("stroke-opacity");
        if (!color.equals("none")) {
            ret.setValue(DrawAttr.STROKE_COLOR, getColor(color, opacity));
        }
    }
    if (attrs.contains(DrawAttr.FILL_COLOR)) {
        String color = elt.getAttribute("fill");
        if (color.equals(""))
            color = "#000000";
        String opacity = elt.getAttribute("fill-opacity");
        if (!color.equals("none")) {
            ret.setValue(DrawAttr.FILL_COLOR, getColor(color, opacity));
        }
    }
    return ret;
}