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:info.magnolia.ui.framework.availability.shorthandrules.AccessGrantedRule.java

@Override
public boolean isAvailable(Collection<?> itemIds) {
    User user = MgnlContext.getUser();/*from   w  w w .j  a v  a  2 s  .  c o m*/
    // Validate that the user has all the required roles
    Collection<String> userRoles = user.getAllRoles();
    Collection<String> roles = accessDefinition.getRoles();
    if (roles.isEmpty() || userRoles.contains(DEFAULT_SUPERUSER_ROLE)
            || CollectionUtils.containsAny(userRoles, roles)) {
        return true;
    }
    return false;
}

From source file:com.macasaet.lambda.fluent.Examples.java

/**
 * This is the standard way of defining {@link Predicate Predicates} in Guava. Notice that even in this simple case
 * of a single method invocation, the Predicate definition uses five lines.
 *//*from w  w w  . j  a  va 2  s  .  c o m*/
@Test
public final void definePredicateWithAnonymousInnerClass() {
    final Predicate<? super AnyMatrix> matrixIsSquare = new Predicate<AnyMatrix>() {
        public boolean apply(final AnyMatrix input) {
            return input.isSquare();
        }
    };

    final Collection<? extends AnyMatrix> result = filter(matrices, matrixIsSquare);

    assertTrue(result.contains(squareMatrix));
    assertFalse(result.contains(nonSquareMatrix));
}

From source file:cz.muni.fi.airportservicelayer.services.FlightServiceImpl.java

private <T> boolean subset(Collection<T> subSet, Collection<T> supperSet) {
    for (T t : subSet) {
        if (!supperSet.contains(t)) {
            return false;
        }/* w  w w. j av a 2 s  . c  o  m*/
    }

    return true;
}

From source file:ru.codemine.ccms.service.EmployeeService.java

public boolean isCurrentUserHasRole(String role) {
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    if (auth != null) {
        Collection<? extends GrantedAuthority> authorities = auth.getAuthorities();

        return authorities.contains(new SimpleGrantedAuthority(role));
    }/*  ww w . j  a v  a2 s.  c  o m*/

    return false;
}

From source file:org.netxilia.api.impl.dependencies.SheetAliasDependencyManager.java

public void saveSheet(SheetData sheetData, Collection<SheetData.Property> properties) {
    if (properties != null && properties.contains(SheetData.Property.aliases)) {
        // check which alias changed
        // make a diff between the stored version of aliases and the new list

        MapDifference<Alias, AreaReference> diff = Maps.difference(previousAliases, sheetData.getAliases());
        previousAliases = new HashMap<Alias, AreaReference>(sheetData.getAliases());
        workbookAliasDependencyManager.refreshAliases(sheet.getName(), diff.entriesDiffering().keySet(),
                diff.entriesOnlyOnLeft().keySet());

    }//from ww  w. ja v  a  2 s . c  o m
}

From source file:com.googlecode.t7mp.steps.CopyUserConfigStep.java

private void mergeProperties(Properties target, Properties source, Collection<String> excludes) {
    for (Object key : source.keySet()) {
        if (!excludes.contains(key)) {
            target.setProperty((String) key, (String) source.get(key));
        } else {//from   w w w.j  a  v  a 2 s  . co m
            log.debug("Skip property " + key + " from user catalina.properties");
        }
    }
}

From source file:com.facebook.internal.JsonUtilTest.java

@Test
public void testJsonObjectValues() throws JSONException {
    JSONObject jsonObject = new JSONObject();
    jsonObject.put("hello", "world");
    jsonObject.put("hocus", "pocus");

    Collection<Object> values = JsonUtil.jsonObjectValues(jsonObject);

    assertEquals(2, values.size());/* w ww .  j av  a  2s  .  c  o m*/
    assertTrue(values.contains("world"));
}

From source file:com.leverno.ysbos.harvest.HarvesterTest.java

public void testGetFilesFor() throws Exception {
    FileHarvester harvester = new FileHarvester();
    Collection<File> files = harvester.getFilesFor(rootFolder);

    assertNotNull(files);//from ww  w  . j av a  2 s . c  o m
    assertEquals(2, files.size());
    assertTrue(files.contains(fileOne));
    assertTrue(files.contains(fileTwo));
}

From source file:com.liferay.ide.project.core.util.ProjectImportUtil.java

/**
 * This method was added as part of the IDE-381 fix, this method will collect all the binaries based on the binaries
 * list//from ww w . ja  v  a2 s. c om
 *
 * @return true if the directory has some binaries
 */
public static boolean collectBinariesFromDirectory(Collection<File> binaryProjectFiles, File directory,
        boolean recurse, IProgressMonitor monitor) {
    if (monitor.isCanceled()) {
        return false;
    }

    monitor.subTask(NLS.bind(Msgs.checking, directory.getPath()));

    List<String> wildCards = Arrays.asList(ISDKConstants.BINARY_PLUGIN_PROJECT_WILDCARDS);

    WildcardFileFilter wildcardFileFilter = new WildcardFileFilter(wildCards);

    Collection<File> contents = FileUtils.listFiles(directory, wildcardFileFilter,
            DirectoryFileFilter.INSTANCE);

    if (contents == null) {
        return false;
    } else {
        for (File file : contents) {
            if (!binaryProjectFiles.contains(file) && isValidLiferayPlugin(file)) {
                binaryProjectFiles.add(file);
            }
        }
    }

    return true;
}

From source file:com.aionlightning.commons.services.CronServiceTest.java

@Test
public void testGetRunnables() {
    Runnable test = newRunnable();
    cronService.schedule(test, "* 5 * * * ?");
    Collection<Runnable> col = cronService.getRunnables().keySet();
    assertTrue(col.contains(test));
}