Example usage for java.util List removeAll

List of usage examples for java.util List removeAll

Introduction

In this page you can find the example usage for java.util List removeAll.

Prototype

boolean removeAll(Collection<?> c);

Source Link

Document

Removes from this list all of its elements that are contained in the specified collection (optional operation).

Usage

From source file:com.alibaba.dubbo.governance.web.sysinfo.module.screen.Dump.java

private List<String> getNoProviders() {
    List<String> providerServices = providerDAO.findServices();
    List<String> consumerServices = consumerDAO.findServices();
    List<String> noProviderServices = new ArrayList<String>();
    if (consumerServices != null) {
        noProviderServices.addAll(consumerServices);
        noProviderServices.removeAll(providerServices);
    }//from w w w  .j  av a 2  s.c om
    return noProviderServices;
}

From source file:count.ly.messaging.CountlyStore.java

/**
 * Removes the specified events from the local store. Does nothing if the event collection
 * is null or empty./*w  w  w. ja  v  a 2 s  .c o  m*/
 * @param eventsToRemove collection containing the events to remove from the local store
 */
public synchronized void removeEvents(final Collection<Event> eventsToRemove) {
    if (eventsToRemove != null && eventsToRemove.size() > 0) {
        final List<Event> events = eventsList();
        if (events.removeAll(eventsToRemove)) {
            preferences_.edit().putString(EVENTS_PREFERENCE, joinEvents(events, DELIMITER)).commit();
        }
    }
}

From source file:com.thoughtworks.go.server.service.MagicalMaterialAndMaterialConfigConversionTest.java

private void assertThatAllMaterialConfigsInCodeAreTestedHere(List<Class> reflectionsSubTypesOf,
        List<Class> allExpectedMaterialConfigImplementations) {
    List<Class> missingImplementations = new ArrayList<>(reflectionsSubTypesOf);
    missingImplementations.removeAll(allExpectedMaterialConfigImplementations);
    String message = "You need to add a DataPoint for these materials in this test: " + missingImplementations;

    assertThat(message, reflectionsSubTypesOf.size(), is(allExpectedMaterialConfigImplementations.size()));
    assertThat(message, reflectionsSubTypesOf, hasItems(allExpectedMaterialConfigImplementations
            .toArray(new Class[allExpectedMaterialConfigImplementations.size()])));
}

From source file:dk.statsbiblioteket.util.watch.FolderWatcher.java

public synchronized void run() {
    try {//from ww  w. j  a va2 s.c  om
        while (watch) {
            try {
                List<File> newContent = getContent();
                if (oldContent == null && newContent != null) {
                    alert(newContent, FolderEvent.EventType.watchedCreated);
                } else if (oldContent != null && newContent == null) {
                    alert(newContent, FolderEvent.EventType.watchedRemoved);
                } else if (oldContent != null & newContent != null) {
                    List<File> added = new ArrayList<File>(newContent);
                    added.removeAll(oldContent);
                    if (added.size() > 0) {
                        alert(getStableContent(oldContent), FolderEvent.EventType.added);
                    }
                    List<File> removed = new ArrayList<File>(oldContent);
                    removed.removeAll(newContent);
                    if (removed.size() > 0) {
                        alert(removed, FolderEvent.EventType.removed);
                    }
                }
                oldContent = newContent;
            } catch (IOException e) {
                log.error("An I/O exception occured when polling for " + "changes for folder '" + watchedFolder
                        + "'. Polling continues", e);
            }
            try {
                wait(pollInterval * 1000);
            } catch (InterruptedException e) {
                log.warn("Sleeping " + pollInterval * 1000 + " seconds was " + "interrupted", e);
            }
        }
        log.debug("Stopping watching '" + watchedFolder + "'");
    } catch (Exception e) {
        log.error("an unexpected exception occured while watching folder '" + watchedFolder
                + "'. Watcher is closing down", e);
    }
}

From source file:com.couchbase.workshop.IndexChecker.java

/**
 * Helper method to make sure that all needed indexes are created if they aren't already.
 *
 * @throws Exception/*  w  ww.  j  a v  a  2s  .c  om*/
 */
private void ensureIndexes() throws Exception {
    LOGGER.info("Loading current Indexes for bucket {}", bucket.name());

    List<Index> current = currentIndexes();

    LOGGER.info("Found {} indexes on bucket {}", current.size(), bucket.name());
    LOGGER.debug("Found Indexes: {}", current);

    List<Index> wanted = wantedIndexes();

    LOGGER.info("Found {} indexes to potentially create on bucket {}", wanted.size(), bucket.name());
    LOGGER.debug("Wanted Indexes: {}", wanted);

    wanted.removeAll(current);

    LOGGER.info("Creating {} new indexes.", wanted.size());

    createIndexes(wanted);
}

From source file:net.sourceforge.fenixedu.domain.elections.DelegateElection.java

private Collection<Student> getNotCandidates() {
    List<Student> result = new ArrayList<Student>(super.getStudentsSet());
    result.removeAll(getCandidatesSet());
    return result;
}

From source file:org.openwms.core.uaa.SecurityServiceImpl.java

/**
 * {@inheritDoc}//from w  w w. jav  a2s.  c  om
 * <p>
 * Triggers {@code UserChangedEvent} after completion.
 */
@Override
@FireAfterTransaction(events = { UserChangedEvent.class })
public List<Grant> mergeGrants(String moduleName, List<Grant> grants) {
    Assert.notNull(moduleName, translator.translate(ExceptionCodes.MODULENAME_NOT_NULL));
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Merging grants of module:" + moduleName);
    }
    List<Grant> persisted = securityObjectRepository.findAllOfModule(moduleName + "%");
    List<Grant> result = new ArrayList<>(persisted);
    grants.forEach(g -> {
        if (persisted.contains(g))
            persisted.remove(g);
        else
            result.add(securityObjectRepository.save(g));
    });
    result.removeAll(persisted);
    if (!persisted.isEmpty()) {
        securityObjectRepository.delete(persisted);
    }
    return result;
}

From source file:net.gplatform.sudoor.server.security.model.auth.SSAuth.java

public String removeRole(String username, String[] roles) {
    UserDetails olduds = getUserDetailsManager().loadUserByUsername(username);
    List<GrantedAuthority> newAuth = new ArrayList<GrantedAuthority>();
    newAuth.addAll(olduds.getAuthorities());
    newAuth.removeAll(createSimpleGrantedAuthorities(roles));
    UserDetails newuds = new User(olduds.getUsername(), olduds.getPassword(), true, true, true, true, newAuth);
    getUserDetailsManager().updateUser(newuds);
    return "SUCCESS";
}

From source file:com.axelor.studio.service.builder.FormBuilderService.java

/**
 * Method to update onSave string with new actions.
 * //from w  w  w .  jav  a 2 s.c  om
 * @param actions
 *            String of actions separated by comma.
 * @return String of updated actions with onSave.
 */
public static String getUpdatedAction(String oldAction, String action) {

    if (Strings.isNullOrEmpty(oldAction)) {
        return action;
    }
    if (Strings.isNullOrEmpty(action)) {
        return oldAction;
    }

    List<String> oldActions = new ArrayList<String>();
    oldActions.addAll(Arrays.asList(oldAction.split(",")));

    List<String> newActions = new ArrayList<String>();
    newActions.addAll(Arrays.asList(action.split(",")));
    newActions.removeAll(oldActions);

    oldActions.addAll(newActions);

    return Joiner.on(",").join(oldActions);
}