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.wso2telco.gsma.authenticators.attributeshare.AbstractAttributeShare.java

public static List<String> getScopesToDisplay(List<String> attributeSet, String scope) {

    List<String> consentAttributeSet = attributeSet;
    List<String> displayAttributeSet;

    displayAttributeSet = scopeMap.get(scope).getDisplayAttributes();
    for (int j = 0; j < displayAttributeSet.size(); j++) {
        if (!consentAttributeSet.contains(displayAttributeSet.get(j))) {
            consentAttributeSet.add(displayAttributeSet.get(j));
        }/*from  w ww .java 2 s.  c o m*/
    }
    return consentAttributeSet;
}

From source file:Main.java

public static double calcStrArrayListSimilarity(final List<String> strAList1, final List<String> strAList2) {
    int containsCount = 0;
    List<String> biggerList;
    List<String> smallerList;
    if (strAList1.size() < strAList2.size()) {
        biggerList = strAList2;//from  ww w  . j  av a2s .  c  o  m
        smallerList = strAList1;
    } else if (strAList2.size() < strAList1.size()) {
        biggerList = strAList1;
        smallerList = strAList2;
    } else {
        biggerList = strAList1;
        smallerList = strAList2;
    }

    for (int i = 0; i < biggerList.size(); i++) {
        if (smallerList.contains(biggerList.get(i))) {
            containsCount++;
        }
    }

    return (double) containsCount / (double) smallerList.size();
}

From source file:com.sirma.itt.cmf.integration.workflow.TransientNode.java

/**
 * Gets a flattened list of all mandatory aspects for a given class.
 *
 * @param classDef the class/*from   ww  w . j ava2s  . c o m*/
 * @param aspects a list to hold the mandatory aspects
 */
private static void getMandatoryAspects(ClassDefinition classDef, List<QName> aspects) {
    for (AspectDefinition aspect : classDef.getDefaultAspects()) {
        QName aspectName = aspect.getName();
        if (!aspects.contains(aspectName)) {
            aspects.add(aspect.getName());
            getMandatoryAspects(aspect, aspects);
        }
    }
}

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

/**
 * @param allFields All existent fields for a given entry type
 * @param reqFields list containing required fields for an entry type
 * @param optFields list containing optional fields for an entry type
 * @param utiFields list containing utility fields for an entry type
 * @param origList  original list with the correct size filled with the default values for each field
 * @return origList changing the values of the fields that appear on reqFields, optFields, utiFields set to 'req',
 * 'opt' and 'uti' respectively//from   w w  w  .j ava  2  s .  co  m
 */
public static List<String> setFieldRequirement(List<String> allFields, List<String> reqFields,
        List<String> optFields, List<String> utiFields, List<String> origList) {

    String currentField;
    for (int i = 0; i < allFields.size(); i++) {
        currentField = allFields.get(i);
        if (reqFields.contains(currentField)) {
            origList.set(i, "req");
        } else if (optFields.contains(currentField)) {
            origList.set(i, "opt");
        } else if (utiFields.contains(currentField)) {
            origList.set(i, "uti");
        }
    }
    return origList;
}

From source file:org.openmrs.module.emrapi.concept.HibernateEmrConceptDAO.java

/**
 * Copied over from OpenMRS 1.9.8 to provide backwards compatibility.
 * // ww  w . j a  va  2  s.  c o m
 * It's no longer available in 1.11.
 * 
 * @param phrase
 * @param locale
 * @return
 */
public static List<String> getUniqueWords(String phrase, Locale locale) {
    String[] parts = splitPhrase(phrase);
    List<String> uniqueParts = new Vector<String>();

    if (parts != null) {
        List<String> conceptStopWords = Context.getConceptService().getConceptStopWords(locale);
        for (String part : parts) {
            if (!StringUtils.isBlank(part)) {
                String upper = part.trim().toUpperCase();
                if (!conceptStopWords.contains(upper) && !uniqueParts.contains(upper))
                    uniqueParts.add(upper);
            }
        }
    }

    return uniqueParts;
}

From source file:keepinchecker.utility.EmailUtilities.java

protected static int getPort(String mailServer) {
    int port = 0;

    List<String> fiveEightySevenPortDomains = Arrays.asList(GOOGLE_MAIL_SERVER, MICROSOFT_MAIL_SERVER,
            YAHOO_MAIL_SERVER, AOL_MAIL_SERVER, COMCAST_MAIL_SERVER);
    List<String> fourSixtyFivePortDomains = Arrays.asList(VERIZON_MAIL_SERVER, ATT_MAIL_SERVER);

    if (fiveEightySevenPortDomains.contains(mailServer)) {
        port = PORT_FIVE_EIGHTY_SEVEN;/*  w w  w  .j a  v  a  2s  . co m*/
    } else if (fourSixtyFivePortDomains.contains(mailServer)) {
        port = PORT_FOUR_SIXTY_FIVE;
    }

    return port;
}

From source file:it.eng.spagobi.engines.worksheet.bo.WorkSheetDefinition.java

public static void addDomainValuesFilters(List<Attribute> toReturn, List<Attribute> sheetFilters) {
    Iterator<Attribute> it = sheetFilters.iterator();
    while (it.hasNext()) {
        Attribute aFilter = it.next();
        if (toReturn.contains(aFilter)) {
            int index = toReturn.indexOf(aFilter);
            Attribute previousFilter = toReturn.get(index);
            List<String> previousValues = previousFilter.getValuesAsList();
            List<String> newValues = aFilter.getValuesAsList();
            List<String> sum = ListUtils.sum(previousValues, newValues);
            previousFilter.setValues(sum);
        } else {//w  w w .j a va 2  s  .c  o  m
            Attribute clone = aFilter.clone();
            toReturn.add(clone);
        }
    }
}

From source file:com.flexive.shared.structure.export.StructureExporterTools.java

/**
 * Performs a linear list comparison and returns a combination of both,
 *
 * @param src the source List<T> (of, for example, assignment ids)
 * @param cmp the List<T> with which src will be compared
 * @return returns null if both parameters are null, returns src if cmp is null, returns cmp if src is null or returns the combined List<T>
 *///ww  w.jav a 2 s .  c o  m
public static <T> List<T> listCompare(List<T> src, List<T> cmp) {
    if (src != null) {
        if (cmp != null) {
            for (T i : cmp) {
                if (!src.contains(i))
                    src.add(i);
            }
            return src;
        }
    }
    return cmp;
}

From source file:net.fenyo.gnetwatch.GenericTools.java

/**
 * Removes the part of a graph that is covered by another graph.
 * Note that the second graph need not to be a subgraph of the first one.
 * @param addr g1 initial graph.//  w w w  . j a v  a2 s  . co m
 * @param addr g2 graph defining links to remove to the initial graph.
 * @return void.
 */
static public void substractGraph(java.util.List<Pair<VisualElement, VisualElement>> g1,
        java.util.List<Pair<VisualElement, VisualElement>> g2) {
    final java.util.List<Pair<VisualElement, VisualElement>> gtemp = new LinkedList<Pair<VisualElement, VisualElement>>(
            g1);
    for (final Pair<VisualElement, VisualElement> p : gtemp)
        if (g2.contains(p))
            g1.remove(p);
}

From source file:com.afis.jx.ckfinder.connector.utils.ImageUtils.java

/**
 * checks if file is image./*from w  w w .  j ava  2  s . c o m*/
 *
 * @param file file to check
 * @return true if file is image.
 */
public static boolean isImage(final File file) {
    List<String> list = Arrays.asList(ALLOWED_EXT);
    String fileExt;
    if (file != null) {
        fileExt = FileUtils.getFileExtension(file.getName().toLowerCase());
        return (fileExt != null) ? list.contains(fileExt) : false;
    } else {
        return false;
    }
}