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:de.tor.tribes.util.VillageUtils.java

public static String[] getContinents(Tribe pTribe) {
    if (pTribe == null || pTribe.equals(Barbarians.getSingleton())) {
        return new String[0];
    }/*w w  w  .j  a  v a 2s .  co  m*/
    List<String> continents = new ArrayList<>();

    for (Village v : pTribe.getVillageList()) {
        int cont = v.getContinent();
        String sCont = "K" + ((cont < 10) ? "0" + cont : cont);
        if (!continents.contains(sCont)) {
            continents.add(sCont);
        }
    }
    Collections.sort(continents, String.CASE_INSENSITIVE_ORDER);
    return continents.toArray(new String[continents.size()]);
}

From source file:org.apache.cxf.fediz.service.idp.service.jpa.RoleDAOJPAImpl.java

public static Role entity2domain(RoleEntity entity, List<String> expandList) {
    Role role = new Role();
    role.setId(entity.getId());//from  ww w.  java2s  . c o  m
    role.setName(entity.getName());
    role.setDescription(entity.getDescription());

    if (expandList != null && (expandList.contains("all") || expandList.contains("entitlements"))) {
        for (EntitlementEntity item : entity.getEntitlements()) {
            Entitlement entitlement = EntitlementDAOJPAImpl.entity2domain(item);
            role.getEntitlements().add(entitlement);
        }
    }

    return role;
}

From source file:com.aurel.track.admin.customize.category.filter.MenuitemFilterBL.java

/**
 * Gets the filter IDs to subscribe by default a user
 * @return/*from  w w  w  . j  a v  a 2s .  c om*/
 */
public static List<Integer> getFilterIDsToSubscribe() {
    List<Integer> filterIDs = new LinkedList<Integer>();
    List<String> filterNames = loadFilterNamesToSubscribe();
    if (filterNames.contains(PREDEFINED_QUERY_NAME.ALL_ITEMS)) {
        filterIDs.add(PREDEFINED_QUERY.ALL_ITEMS);
    }
    if (filterNames.contains(PREDEFINED_QUERY_NAME.OUTSTANDING)) {
        filterIDs.add(PREDEFINED_QUERY.OUTSTANDING);
    }
    if (filterNames.contains(PREDEFINED_QUERY_NAME.MY_ITEMS)) {
        filterIDs.add(PREDEFINED_QUERY.MY_ITEMS);
    }
    if (filterNames.contains(PREDEFINED_QUERY_NAME.MANAGER_ITEMS)) {
        filterIDs.add(PREDEFINED_QUERY.MANAGERS_ITEMS);
    }
    if (filterNames.contains(PREDEFINED_QUERY_NAME.RESPONSIBLE_ITEMS)) {
        filterIDs.add(PREDEFINED_QUERY.RESPONSIBLES_ITEMS);
    }
    if (filterNames.contains(PREDEFINED_QUERY_NAME.AUTHOR_ITEMS)) {
        filterIDs.add(PREDEFINED_QUERY.AUTHOR_ITEMS);
    }
    if (filterNames.contains(PREDEFINED_QUERY_NAME.WATCHER_ITEMS)) {
        filterIDs.add(PREDEFINED_QUERY.WATCHER_ITEMS);
    }
    if (filterNames.contains(PREDEFINED_QUERY_NAME.MEETINGS)) {
        filterIDs.add(PREDEFINED_QUERY.MEETINGS);
    }
    if (filterNames.contains(PREDEFINED_QUERY_NAME.UNSCHEDULED)) {
        filterIDs.add(PREDEFINED_QUERY.UNSCHEDULED);
    }
    if (filterNames.contains(PREDEFINED_QUERY_NAME.CLOSED_RECENTLY)) {
        filterIDs.add(PREDEFINED_QUERY.CLOSED_RECENTLY);
    }
    if (filterNames.contains(PREDEFINED_QUERY_NAME.ADDED_RECENTLY)) {
        filterIDs.add(PREDEFINED_QUERY.ADDED_RECENTLY);
    }
    if (filterNames.contains(PREDEFINED_QUERY_NAME.UPDATED_RECENTLY)) {
        filterIDs.add(PREDEFINED_QUERY.UPDATED_RECENTLY);
    }
    if (filterNames.contains(PREDEFINED_QUERY_NAME.SCRUM_BOARD)) {
        filterIDs.add(PREDEFINED_QUERY.SCRUM_BOARD);
    }
    if (filterNames.contains(PREDEFINED_QUERY_NAME.KANBAN_BOARD)) {
        filterIDs.add(PREDEFINED_QUERY.KANBAN_BOARD);
    }
    //get them from the database to be sure that all of them still exist (was not deleted)
    List<TQueryRepositoryBean> filterBeans = FilterBL.loadByPrimaryKeys(filterIDs);
    return GeneralUtils.createIntegerListFromBeanList(filterBeans);
}

From source file:com.hbs.common.josn.JSONUtil.java

/**
 * Recursive method to visit all the interfaces of a class (and its superclasses and super-interfaces) if they
 * haven't already been visited./*from  www  .j a va  2s  .co m*/
 *
 * Always visits itself if it hasn't already been visited
 *
 * @param thisClass         the current class to visit (if not already done so)
 * @param classesVisited    classes already visited
 * @param visitor           this vistor is called for each class/interface encountered
 * @return true if recursion can continue, false if it should be aborted
 */
@SuppressWarnings("unchecked")
private static boolean visitUniqueInterfaces(Class thisClass, ClassVisitor visitor,
        List<Class> classesVisited) {
    boolean okayToContinue = true;

    if (!classesVisited.contains(thisClass)) {
        classesVisited.add(thisClass);
        okayToContinue = visitor.visit(thisClass);

        if (okayToContinue) {
            Class[] interfaces = thisClass.getInterfaces();
            int index = 0;
            while ((index < interfaces.length) && (okayToContinue)) {
                okayToContinue = visitUniqueInterfaces(interfaces[index++], visitor, classesVisited);
            }

            if (okayToContinue) {
                Class superClass = thisClass.getSuperclass();
                if ((superClass != null) && (!Object.class.equals(superClass))) {
                    okayToContinue = visitUniqueInterfaces(superClass, visitor, classesVisited);
                }
            }
        }
    }
    return okayToContinue;
}

From source file:com.sccl.attech.common.service.BaseService.java

/**
 * ?//  w ww  .  j  a va2  s  .  co  m
 * @param user ?UserUtils.getUser()??
 * @param officeAlias ??dc.createAlias("office", "office");
 * @param userAlias ???
 * @return ?
 */
protected static Junction dataScopeFilter(User user, String officeAlias, String userAlias) {

    // ????
    List<String> dataScope = Lists.newArrayList();
    Junction junction = Restrictions.disjunction();

    // ???
    if (!user.isAdmin()) {
        for (Role r : user.getRoleList()) {
            if (!dataScope.contains(r.getDataScope()) && StringUtils.isNotBlank(officeAlias)) {
                boolean isDataScopeAll = false;
                if (Role.DATA_SCOPE_ALL.equals(r.getDataScope())) {
                    isDataScopeAll = true;
                } else if (Role.DATA_SCOPE_COMPANY_AND_CHILD.equals(r.getDataScope())) {
                    junction.add(Restrictions.eq("company.id", user.getCompany().getId()));
                    //junction.add(Restrictions.like(officeAlias+".parentIds", "%"+user.getCompany().getParentIds()+","+user.getCompany().getId()+"%"));
                }
                //               else if (Role.DATA_SCOPE_COMPANY.equals(r.getDataScope())){
                //                  junction.add(Restrictions.eq(officeAlias+".id", user.getCompany().getId()));
                //                  junction.add(Restrictions.and(Restrictions.eq(officeAlias+".id", user.getCompany().getId()),
                //                        Restrictions.eq(officeAlias+".type", "2"))); // ?
                //               }
                else if (Role.DATA_SCOPE_OFFICE_AND_CHILD.equals(r.getDataScope())) {
                    junction.add(Restrictions.eq(officeAlias + ".id", user.getOffice().getId()));
                    junction.add(Restrictions.like(officeAlias + ".parentIds",
                            "%" + user.getOffice().getParentIds() + "," + user.getOffice().getId() + "%"));
                } else if (Role.DATA_SCOPE_OFFICE.equals(r.getDataScope())) {
                    junction.add(Restrictions.eq(officeAlias + ".id", user.getOffice().getId()));
                } else if (Role.DATA_SCOPE_CUSTOM.equals(r.getDataScope())) {
                    junction.add(Restrictions.in(officeAlias + ".id", r.getOfficeIdList()));
                }
                //else if (Role.DATA_SCOPE_SELF.equals(r.getDataScope())){
                if (!isDataScopeAll) {
                    if (StringUtils.isNotBlank(userAlias)) {
                        junction.add(Restrictions.eq(userAlias + ".id", user.getId()));
                    } else {
                        junction.add(Restrictions.isNull(officeAlias + ".id"));
                    }
                } else {
                    // ?????
                    junction = Restrictions.disjunction();
                    break;
                }

                dataScope.add(r.getDataScope());
            }
        }
    }

    return junction;
}

From source file:eu.europeana.portal.portal2.speedtests.TermProvider.java

public static List<String> getRandomWords(int count) {

    List<String> queries = null;
    try {// w ww .j  av  a2  s.co  m
        queries = FileUtils.readLines(new File("/home/peterkiraly/words.txt"));
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    List<String> random = new ArrayList<String>();
    String query;
    while (random.size() < count) {
        int startRecord = (int) (Math.random() * queries.size());
        query = queries.get(startRecord).trim().replaceAll("[\"'()]", "").replace("/", "\\/");
        if (query.length() >= 3 && !random.contains(query)) {
            random.add(query);
        }
    }

    return random;
}

From source file:jterm.command.Dir.java

@Command(name = "ls", syntax = "ls [-f] [-h] [directory]")
public static void ls(List<String> options) {
    File[] files = new File(JTerm.currentDirectory).listFiles();
    if (files == null) {
        return;/* w  w w .j av  a2s.  c o  m*/
    }

    JTerm.out.println(TextColor.INFO, "[Contents of \"" + JTerm.currentDirectory + "\"]");
    Arrays.stream(files).forEach(options.contains("-f") ? FULL_PRINTER : SIMPLE_PRINTER);
}

From source file:de.micromata.genome.junittools.wicket.TpsbWicketTools.java

public static <T extends WicketTestBuilder<?>> T validateLabelContainingText(T builder,
        MarkupContainer startComponent, String text) {
    List<String> labels = collectLabelTexte(builder, startComponent);
    if (labels.contains(text) == false) {
        builder.fail("Cannot find label with text: " + text);
    }// www .j a va2s.  c  o  m
    return builder;
}

From source file:models.GlobalTransPoint.java

private static void arrangeItems(Map<Integer, List<GlobalTransPoint>> map, GlobalTransPoint item,
        Integer parId) {//from w w w  . ja  v  a 2s  .  c  o  m
    List<GlobalTransPoint> list = map.get(parId);
    if (list == null)
        list = new ArrayList<GlobalTransPoint>();

    if (!list.contains(item)) {
        list.add(item);
    }
    map.put(parId, list);
}

From source file:net.automatalib.visualization.jung.JungGraphVisualizationProvider.java

protected static NodeVisualization createNodeVisualization(Map<String, String> props, int id) {
    String label = props.get(NodeAttrs.LABEL);
    if (label == null) {
        label = "v" + id;
    }//from  w  w  w  . j  ava 2  s .c  o m
    Color drawColor = getColor(props, "color", Color.BLACK);
    Color fillColor = getColor(props, "fillcolor", Color.WHITE);

    String shapeName = props.get(NodeAttrs.SHAPE);
    if (shapeName == null) {
        shapeName = "circle";
    }
    ShapeLibrary shapeLib = ShapeLibrary.getInstance();

    Shape shape = shapeLib.createShape(shapeName);
    if (shape == null) {
        System.err.println("Could not create shape " + shapeName);
        shape = shapeLib.createShape("circle");
    }

    String[] styles = {};
    String styleAttr = props.get("style");
    if (styleAttr != null) {
        styles = styleAttr.toLowerCase().split(",");
    }
    List<String> styleList = Arrays.asList(styles);

    float penWidth = 1.0f;
    Stroke stroke;
    if (styleList.contains("bold")) {
        penWidth = 3.0f;
    }

    if (styleList.contains("dashed")) {
        float[] dash = { 10.0f };
        stroke = new BasicStroke(penWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash, 0.0f);
    } else if (styleList.contains("dotted")) {
        float[] dash = { penWidth, penWidth + 7.0f };
        stroke = new BasicStroke(penWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash, 0.0f);
    } else {
        stroke = new BasicStroke(penWidth);
    }

    return new NodeVisualization(label, drawColor, fillColor, shape, stroke);
}