Example usage for java.util Collection contains

List of usage examples for java.util Collection contains

Introduction

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

Prototype

boolean contains(Object o);

Source Link

Document

Returns true if this collection contains the specified element.

Usage

From source file:com.base2.kagura.services.camel.kagura.AuthBean.java

public void canAccessReport(@Header("authToken") String authToken, @Header("reportId") String reportId,
        Exchange exchange) throws AuthorizationException, AuthenticationException {
    if (tokens.containsKey(authToken) && tokens.get(authToken).getLoggedIn()) {
        User user = authenticationProvider.getUser(tokens.get(authToken).getUsername());
        Collection<String> reports = authenticationProvider.getUserReports(user);
        exchange.getIn().setHeader("groups", user.getGroups());
        exchange.getIn().setHeader("userExtra", user.getExtraOptions());
        if (reports.contains(reportId))
            return;
        throw new AuthorizationException("User is not logged in.");
    }//from w ww.j  av a  2 s.com
    throw new AuthenticationException("User is not logged in.");
}

From source file:com.okta.swagger.codegen.OktaJavaClientImplCodegen.java

private String buildConstructorTypeExtra(CodegenProperty property) {
    Collection<String> autoCreateParams = Collections.singleton("profile");
    boolean createNested = property.vendorExtensions.containsKey(CREATE_NESTED_KEY)
            || autoCreateParams.contains(property.name);
    return ", " + property.datatype + ".class, " + createNested;
}

From source file:$.CustomContentModelIT.java

@Test
    public void testCustomContentModelPresence() {
        Collection<QName> allContentModels = getServiceRegistry().getDictionaryService().getAllModels();
        QName customContentModelQName = createQName(ACME_MODEL_LOCALNAME);
        assertTrue("Custom content model " + customContentModelQName.toString() + " is not present",
                allContentModels.contains(customContentModelQName));
    }// www .  j  a  v  a 2s  .c  om

From source file:ch.entwine.weblounge.common.impl.util.config.OptionsHelper.java

/**
 * Returns <code>true</code> if the the option with name <code>name</code> has
 * been configured./* w  ww.  ja v a  2 s . co m*/
 * 
 * @param name
 *          the option name
 * @return <code>true</code> if an option with that name exists
 * @see #getOptions()
 * @see #getOptionValue(java.lang.String)
 * @see #getOptionValue(java.lang.String, java.lang.String)
 */
public boolean hasOption(String name) {
    Map<Environment, List<String>> values = options.get(name);
    if (values == null)
        return false;
    Collection<Environment> environments = values.keySet();
    return environments.contains(environment) || environments.contains(Environment.Any);
}

From source file:gov.nih.nci.caarray.security.SecurityUtils.java

static void handleBiomaterialChanges(Collection<Project> projects, Collection<Protectable> protectables) {
    if (projects == null) {
        return;/*from w  w  w.  j a v a  2s  .c  o  m*/
    }

    try {
        for (final Project p : projects) {
            LOG.debug("Modifying biomaterial collections for project: " + p.getId());
            for (final Sample s : p.getExperiment().getSamples()) {
                if (protectables != null && protectables.contains(s)) {
                    handleNewSample(s, p);
                }
            }
        }
    } catch (final CSTransactionException e) {
        LOG.warn("Unable to update biomaterial collections: " + e.getMessage(), e);
    } catch (final CSObjectNotFoundException e) {
        LOG.warn("Unable to update biomaterial collections: " + e.getMessage(), e);
    }
}

From source file:com.ebook.storefront.filters.cms.CMSSiteFilter.java

/**
 * Filters the preview language to a language supported by the site. If the requested preview language is not
 * supported, returns the default site language instead.
 *
 * @param httpRequest//w  ww  .  j ava  2  s. c  o m
 *           current request
 * @param previewLanguage
 *           the preview language
 * @return LanguageModel the filtered language for previewing
 */
protected LanguageModel filterPreviewLanguageForSite(final HttpServletRequest httpRequest,
        final LanguageModel previewLanguage) {
    getBaseSiteService().setCurrentBaseSite(getCurrentCmsSite(), false);
    final Collection<LanguageModel> siteLanguages = getCommerceCommonI18NService().getAllLanguages();
    if (siteLanguages.contains(previewLanguage)) {
        // The preview language is supported
        return previewLanguage;
    }
    return getCommerceCommonI18NService().getDefaultLanguage();
}

From source file:com.aurel.track.exchange.excel.ExcelFieldMatchAction.java

/**
 * Save the field mappings for the next use
 * @return//from w  w w.  ja  v a  2 s  .c  om
 */
public String save() {
    workbook = ExcelFieldMatchBL.loadWorkbook(excelMappingsDirectory, fileName);
    SortedMap<Integer, String> columnIndexToColumNameMap = ExcelFieldMatchBL.getFirstRowHeaders(workbook,
            selectedSheet);
    Map<String, Integer> columNameToFieldIDMap = ExcelFieldMatchBL
            .getColumnNameToFieldIDMap(columnIndexToFieldIDMap, columnIndexToColumNameMap);
    Set<Integer> lastSavedIdentifierFieldIDIsSet = new HashSet<Integer>();
    //add the explicitly selected field identifiers
    if (columnIndexIsIdentifierMap != null) {
        //at least a field was set as unique identifier
        Iterator<Integer> iterator = columnIndexIsIdentifierMap.keySet().iterator();
        while (iterator.hasNext()) {
            Integer columnIndex = iterator.next();
            Integer fieldID = columnIndexToFieldIDMap.get(columnIndex);
            Boolean isIdentifier = columnIndexIsIdentifierMap.get(columnIndex);
            if ((isIdentifier != null && isIdentifier.booleanValue())) {
                lastSavedIdentifierFieldIDIsSet.add(fieldID);
            }
        }
    }
    //add the implicitly selected field identifiers
    //the mandatory identifiers are disabled (to forbid unselecting them),
    //but it means that they will not be submitted by columnIndexIsIdentifierMap
    //so we should add them manually if a mandatoryIdentifierFields is mapped
    Set<Integer> mandatoryIdentifierFields = ExcelFieldMatchBL.getMandatoryIdentifierFields();
    Iterator<Integer> iterator = mandatoryIdentifierFields.iterator();
    Collection<Integer> submittedFieldIDs = columnIndexToFieldIDMap.values();
    while (iterator.hasNext()) {
        Integer mandatoryIdentifierField = iterator.next();
        if (submittedFieldIDs.contains(mandatoryIdentifierField)) {
            lastSavedIdentifierFieldIDIsSet.add(mandatoryIdentifierField);
        }
    }
    try {
        FileOutputStream fos = new FileOutputStream(new File(excelMappingsDirectory, mappingFileName));
        ObjectOutputStream out = new ObjectOutputStream(fos);
        out.writeObject(columNameToFieldIDMap);
        out.writeObject(lastSavedIdentifierFieldIDIsSet);
        out.close();
    } catch (FileNotFoundException e) {
        LOGGER.warn("Creating the output stream for mapping failed with " + e.getMessage());
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
    } catch (IOException e) {
        LOGGER.warn("Saving the mapping failed with " + e.getMessage());
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
    }
    return NEXT;
}

From source file:com.replaymod.replaystudio.collection.PacketList.java

@Override
public boolean removeAll(Collection<?> c) {
    boolean changed = false;
    PacketListIterator iter = iterator();
    while (iter.hasNext()) {
        if (c.contains(iter.next())) {
            iter.remove();//from   w ww  .  j  a v a2  s.com
            changed = true;
        }
    }
    return changed;
}

From source file:com.replaymod.replaystudio.collection.PacketList.java

@Override
public boolean retainAll(Collection<?> c) {
    boolean changed = false;
    PacketListIterator iter = iterator();
    while (iter.hasNext()) {
        if (!c.contains(iter.next())) {
            iter.remove();//from w w w . j  a v a 2  s  . c  o m
            changed = true;
        }
    }
    return changed;
}

From source file:org.trpr.platform.servicefw.impl.spring.web.HomeController.java

private Set<String> findUniqueUrls(Collection<String> inputs) {
    Set<String> result = new HashSet<String>(inputs);
    for (String url : inputs) {
        String extended = url + ".*";
        if (inputs.contains(extended)) {
            result.remove(extended);//  www.  j  a va 2s . c  o  m
        }
        extended = url + "/";
        if (inputs.contains(extended)) {
            result.remove(extended);
        }
    }
    return result;
}