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.legstar.cob2xsd.Cob2Xsd.java

/**
 * If data item COBOL name is already used, we add it to the non unique
 * list. This recurse to the item children.
 * <p/>//from www  . j  a  v  a  2  s . c  o m
 * We don't add COBOL FILLERs as they are always considered non unique.
 * 
 * @param cobolDataItem a COBOL data item
 * @param cobolNames the list of all COBOL names used so far
 * @param nonUniqueCobolNames the list of non unique COBOL names
 */
protected static void getNonUniqueCobolNames(final CobolDataItem cobolDataItem, final List<String> cobolNames,
        final List<String> nonUniqueCobolNames) {

    String cobolName = cobolDataItem.getCobolName();
    if (!cobolName.equalsIgnoreCase("FILLER")) {
        if (cobolNames.contains(cobolName)) {
            if (!nonUniqueCobolNames.contains(cobolName)) {
                nonUniqueCobolNames.add(cobolName);
            }
        } else {
            cobolNames.add(cobolName);
        }
    }
    for (CobolDataItem child : cobolDataItem.getChildren()) {
        getNonUniqueCobolNames(child, cobolNames, nonUniqueCobolNames);
    }
}

From source file:ReflectionUtil.java

private static void getPackageNamesFromDir(File base, File dir, List<String> pkgs) {
    boolean foundClass = false;
    for (File file : dir.listFiles()) {
        if (file.isDirectory()) {
            getPackageNamesFromDir(base, file, pkgs);
        } else if (!foundClass && file.getName().endsWith(".class")) {
            foundClass = true;//from   w  ww .  j  a  v  a  2 s.  c  o  m
            String pkg = "";
            file = dir;
            while (!file.equals(base)) {
                if (!"".equals(pkg)) {
                    pkg = "." + pkg;
                }
                pkg = file.getName() + pkg;
                file = file.getParentFile();
            }
            if (!pkgs.contains(pkg)) {
                pkgs.add(pkg);
            }
        }
    }
}

From source file:io.pravega.controller.store.stream.tables.TableHelper.java

private static List<Integer> diff(List<Integer> list1, List<Integer> list2) {
    return list1.stream().filter(z -> !list2.contains(z)).collect(Collectors.toList());
}

From source file:jp.ikedam.jenkins.plugins.extensible_choice_parameter.FilenameChoiceListProviderSimpleTest.java

static private void assertFileListEquals(String message, List<String> expected, List<String> fileList) {
    assertEquals(message, expected.size(), fileList.size());
    for (String file : fileList) {
        if (file.contains("\\")) {
            // fix windows path to unix path
            file = file.replace('\\', '/');
        }/*  w  w  w. j av  a 2  s. c o  m*/
        assertTrue(String.format("%s: must contains %s", message, file), expected.contains(file));
    }
}

From source file:edu.duke.cabig.c3pr.utils.SecurityUtils.java

/**
 * Checks if is super user.// ww w.j a v a2  s.  c o  m
 * 
 * @param authentication the authentication
 * 
 * @return true, if is super user
 */
public static boolean isSuperUser(Authentication authentication) {
    List<RoleTypes> allRoles = Arrays.asList(RoleTypes.values());
    List<RoleTypes> roles = SecurityUtils.getRoleTypes(authentication);
    List<RoleTypes> nonC3PRRoles = SecurityUtils.getNonC3PRRoles();
    for (RoleTypes role : allRoles) {
        if (nonC3PRRoles.contains(role)) {
            continue;
        }
        if (!roles.contains(role)) {
            return false;
        } else if (!hasAllSiteAccess(role)) {
            return false;
        }
    }
    return true;
}

From source file:gov.nih.nci.caIMAGE.util.NewDropdownUtil.java

/**
 * Add Other to the list in the first spot if it's not already there.
 * Removes it and put's it in the first spot if it is.
 *//*from w w  w .j a  v a2 s  .  c o  m*/
private static void addOtherOption(List inList) {

    DropdownOption theDropdownOption = new DropdownOption(Constants.Dropdowns.OTHER_OPTION,
            Constants.Dropdowns.OTHER_OPTION);

    if (!inList.contains(theDropdownOption)) {
        inList.add(0, theDropdownOption);
    } else {
        inList.remove(theDropdownOption);
        inList.add(0, theDropdownOption);
    }
}

From source file:dk.netarkivet.harvester.webinterface.DomainDefinition.java

/**
 * Returns the seed lists associated with the supplied configurations.
 *
 * @param configurations The configurations to find seed lists for
 * @return The seed lists used in the supplied configurations.
 *//*from   www. j  a  v  a2s  .  c  o m*/
public static List<SeedList> getSeedLists(List<DomainConfiguration> configurations) {
    List<SeedList> seedsLists = new LinkedList<SeedList>();
    for (DomainConfiguration configuration : configurations) {
        Iterator<SeedList> seedListIterator = configuration.getSeedLists();
        while (seedListIterator.hasNext()) {
            SeedList seedList = seedListIterator.next();
            if (!seedsLists.contains(seedList)) {
                seedsLists.add(seedList);
            }
        }
    }

    return seedsLists;
}

From source file:com.wso2telco.gsma.authenticators.Utility.java

public static String getMultiScopeQueryParam(AuthenticationContext context) {
    List<String> availableMultiScopes = Arrays.asList("profile", "email", "address", "phone",
            "mc_identity_phonenumber_hashed");

    String originalScope = ((Map) context.getProperty("authMap")).get("Scope").toString();

    String[] originalScopesRequested = originalScope.split(" ");

    String multiScopes = "";

    if (originalScopesRequested.length > 1) {

        StringBuilder filteredMultiScopesQuery = new StringBuilder();
        filteredMultiScopesQuery.append("&multiScopes=");

        for (String requestedScope : originalScopesRequested) {
            if (availableMultiScopes.contains(requestedScope)) {
                filteredMultiScopesQuery.append(requestedScope);
                filteredMultiScopesQuery.append(" ");
            }/*  w  w w.j  ava2s .c o  m*/
        }

        multiScopes = filteredMultiScopesQuery.toString().trim().replace(" ", "+");
    }

    return multiScopes;
}

From source file:password.pwm.util.queue.SmsQueueManager.java

private static void determineIfResultSuccessful(final Configuration config, final int resultCode,
        final String resultBody) throws PwmOperationalException {
    final List<String> resultCodeTests = config.readSettingAsStringArray(PwmSetting.SMS_SUCCESS_RESULT_CODE);
    if (resultCodeTests != null && !resultCodeTests.isEmpty()) {
        final String resultCodeStr = String.valueOf(resultCode);
        if (!resultCodeTests.contains(resultCodeStr)) {
            throw new PwmOperationalException(new ErrorInformation(PwmError.ERROR_SMS_SEND_ERROR,
                    "response result code " + resultCode + " is not a configured successful result code"));
        }// w w  w .  j  a  v a 2  s  .c  o m
    }

    final List<String> regexBodyTests = config.readSettingAsStringArray(PwmSetting.SMS_RESPONSE_OK_REGEX);
    if (regexBodyTests == null || regexBodyTests.isEmpty()) {
        return;

    }

    if (resultBody == null || resultBody.isEmpty()) {
        throw new PwmOperationalException(new ErrorInformation(PwmError.ERROR_SMS_SEND_ERROR,
                "result has no body but there are configured regex response matches, so send not considered successful"));
    }

    for (final String regex : regexBodyTests) {
        final Pattern p = Pattern.compile(regex, Pattern.DOTALL);
        final Matcher m = p.matcher(resultBody);
        if (m.matches()) {
            LOGGER.trace("result body matched configured regex match setting: " + regex);
            return;
        }
    }

    throw new PwmOperationalException(new ErrorInformation(PwmError.ERROR_SMS_SEND_ERROR,
            "result body did not matching any configured regex match settings"));
}

From source file:org.jfree.chart.demo.SampleXYSymbolicDataset.java

/**
 * This function modify <CODE>dataset1</CODE> and <CODE>dataset1</CODE> in
 * order that they share the same X symbolic value list.
 * <P>/*  www .  j a va 2s .  co m*/
 * The sharing X symbolic value list is obtained adding the X symbolic data list of the fist data set to the X symbolic data list of the second data set.
 * <P>
 * This function is use with the <I>combined plot</I> functions of JFreeChart.
 * 
 * @param dataset1
 *           the first data set to combine.
 * @param dataset2
 *           the second data set to combine.
 * @return the shared X symbolic array.
 */
public static String[] combineXSymbolicDataset(final XisSymbolic dataset1, final XisSymbolic dataset2) {
    final SampleXYSymbolicDataset sDataset1 = (SampleXYSymbolicDataset) dataset1;
    final SampleXYSymbolicDataset sDataset2 = (SampleXYSymbolicDataset) dataset2;
    final String[] sDatasetSymbolicValues1 = sDataset1.getXSymbolicValues();
    final String[] sDatasetSymbolicValues2 = sDataset2.getXSymbolicValues();

    // Combine the two list of symbolic value of the two data set
    final int s1length = sDatasetSymbolicValues1.length;
    final int s2length = sDatasetSymbolicValues2.length;
    final List xSymbolicValuesCombined = new Vector();
    for (int i = 0; i < s1length; i++) {
        xSymbolicValuesCombined.add(sDatasetSymbolicValues1[i]);
    }
    for (int i = 0; i < s2length; i++) {
        if (!xSymbolicValuesCombined.contains(sDatasetSymbolicValues2[i])) {
            xSymbolicValuesCombined.add(sDatasetSymbolicValues2[i]);
        }
    }

    // Change the Integer reference of the second data set
    int newIndex;
    for (int i = 0; i < sDataset2.getSeriesCount(); i++) {
        for (int j = 0; j < sDataset2.getItemCount(i); j++) {
            newIndex = xSymbolicValuesCombined.indexOf(sDataset2.getXSymbolicValue(i, j));
            sDataset2.setXValue(i, j, new Integer(newIndex));
        }
    }

    // Set the new list of symbolic value on the two data sets
    final String[] xSymbolicValuesCombinedA = new String[xSymbolicValuesCombined.size()];
    xSymbolicValuesCombined.toArray(xSymbolicValuesCombinedA);
    sDataset1.setXSymbolicValues(xSymbolicValuesCombinedA);
    sDataset2.setXSymbolicValues(xSymbolicValuesCombinedA);

    return xSymbolicValuesCombinedA;
}