Example usage for java.util Set removeAll

List of usage examples for java.util Set removeAll

Introduction

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

Prototype

boolean removeAll(Collection<?> c);

Source Link

Document

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

Usage

From source file:backtype.storm.blobstore.BlobStoreTest.java

public static void assertStoreHasExactly(BlobStore store, Subject who, String... keys)
        throws IOException, KeyNotFoundException, AuthorizationException {
    Set<String> expected = new HashSet<String>(Arrays.asList(keys));
    Set<String> found = new HashSet<String>();
    Iterator<String> c = store.listKeys();
    while (c.hasNext()) {
        String keyName = c.next();
        found.add(keyName);//w w w.  j  a v  a  2 s  .c o  m
    }
    Set<String> extra = new HashSet<String>(found);
    extra.removeAll(expected);
    assertTrue("Found extra keys in the blob store " + extra, extra.isEmpty());
    Set<String> missing = new HashSet<String>(expected);
    missing.removeAll(found);
    assertTrue("Found keys missing from the blob store " + missing, missing.isEmpty());
}

From source file:com.github.sevntu.checkstyle.internal.ChecksTest.java

private static Set<String> getFinalProperties(Class<?> clss) {
    final Set<String> properties = getProperties(clss);

    if (AbstractJavadocCheck.class.isAssignableFrom(clss)) {
        properties.removeAll(JAVADOC_CHECK_PROPERTIES);
    } else if (AbstractCheck.class.isAssignableFrom(clss)) {
        properties.removeAll(CHECK_PROPERTIES);
    } else if (AbstractFileSetCheck.class.isAssignableFrom(clss)) {
        properties.removeAll(FILESET_PROPERTIES);

        // override
        properties.add("fileExtensions");
    }/*from   w w w .j  ava 2  s.c o m*/

    return properties;
}

From source file:controllers.Common.java

@Util
public static void flashParamsExcept(String... paramNames) {
    Set<String> names = Sets.newHashSet(params.all().keySet());
    names.removeAll(Arrays.asList(paramNames));
    String[] array = new String[names.size()];
    params.flash(names.toArray(array));/*w  ww . j a v  a 2  s.  co  m*/
}

From source file:edu.uci.ics.hyracks.algebricks.core.algebra.util.OperatorPropertiesUtil.java

/**
 * Adds the free variables of the operator path from
 * op to dest, where dest is a direct/indirect input operator of op in the query plan.
 * /*from  w w w  . j a va2s.c om*/
 * @param op
 *            , the start operator.
 * @param dest
 *            , the destination operator (a direct/indirect input operator).
 * @param freeVars
 *            - The collection to which the free variables will be added.
 */
public static void getFreeVariablesInPath(ILogicalOperator op, ILogicalOperator dest,
        Set<LogicalVariable> freeVars) throws AlgebricksException {
    Set<LogicalVariable> producedVars = new ListSet<LogicalVariable>();
    VariableUtilities.getLiveVariables(op, freeVars);
    collectUsedAndProducedVariablesInPath(op, dest, freeVars, producedVars);
    freeVars.removeAll(producedVars);
}

From source file:com.qmetry.qaf.automation.testng.report.ReporterUtil.java

private static int getSkipCnt(ITestContext context) {
    if ((context != null) && (context.getSkippedTests() != null)) {
        if (context.getSkippedTests().getAllResults() != null) {
            Collection<ITestNGMethod> skippedTest = context.getSkippedTests().getAllMethods();
            Set<ITestNGMethod> set = new HashSet<ITestNGMethod>(skippedTest);
            if (ApplicationProperties.RETRY_CNT.getIntVal(0) > 0) {
                set.removeAll(context.getPassedTests().getAllMethods());
                set.removeAll(context.getFailedTests().getAllMethods());
                return set.size();
            }//  w w  w  . j a v a  2s  .c o  m
            return context.getSkippedTests().getAllResults().size();
        }
        return context.getSkippedTests().size();
    }
    return 0;
}

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

static Map<String, Integer> prepareBestMatchByLabel(Set<String> excelColumnNames,
        Map<String, Integer> previousMappings, Locale locale) {
    if (excelColumnNames == null) {
        return previousMappings;
    }//from  w ww .  j av a 2  s . com
    //do not match the previously matched columns
    excelColumnNames.removeAll(previousMappings.keySet());

    if (!excelColumnNames.isEmpty()) {
        //match by localized config labels
        addMatch(excelColumnNames, getLocalizedDefaultFieldConfigsMap(locale), previousMappings);
    }
    if (!excelColumnNames.isEmpty()) {
        //match by not localized config labels
        addMatch(excelColumnNames, getDefaultFieldConfigsMap(), previousMappings);
    }
    if (!excelColumnNames.isEmpty()) {
        //match by field names
        addMatch(excelColumnNames, getFieldNameBasedFieldConfigsMap(), previousMappings);
    }
    return previousMappings;
}

From source file:models.Watch.java

public static Set<User> findActualWatchers(final Set<User> baseWatchers, final Resource resource) {
    Set<User> actualWatchers = new HashSet<>();
    actualWatchers.addAll(baseWatchers);

    // Add every user who watches the project to which this resource belongs
    if (!(resource instanceof GlobalResource)) {
        Project project = resource.getProject();
        actualWatchers.addAll(findWatchers(project.asResource()));
    }//from   ww w. j a v a2s .c  o  m

    // For this resource, add every user who watch explicitly and remove who unwatch explicitly.
    actualWatchers.addAll(findWatchers(resource));
    actualWatchers.removeAll(findUnwatchers(resource));

    // Filter the watchers who has no permission to read this resource.
    CollectionUtils.filter(actualWatchers, new Predicate() {
        @Override
        public boolean evaluate(Object watcher) {
            return AccessControl.isAllowed((User) watcher, resource, Operation.READ);
        }
    });
    return actualWatchers;
}

From source file:net.i2p.util.I2PSSLSocketFactory.java

/**
 * Adapted from Jetty SslContextFactory.java
 *
 * @param toEnable Add all these to what is enabled, if supported
 * @param toExclude Remove all these from what is enabled
 * @since 0.9.16//from w ww.  j av  a  2  s .  c  o m
 */
private static String[] select(String[] enabledArr, String[] supportedArr, List<String> toEnable,
        List<String> toExclude) {
    Log log = I2PAppContext.getGlobalContext().logManager().getLog(I2PSSLSocketFactory.class);
    Set<String> selected = new HashSet<String>(enabledArr.length);
    selected.addAll(Arrays.asList(enabledArr));
    selected.removeAll(toExclude);
    Set<String> supported = new HashSet<String>(supportedArr.length);
    supported.addAll(Arrays.asList(supportedArr));
    for (String s : toEnable) {
        if (supported.contains(s)) {
            if (selected.add(s)) {
                if (log.shouldLog(Log.INFO))
                    log.info("Added, previously disabled: " + s);
            }
        } else if (log.shouldLog(Log.INFO)) {
            log.info("Not supported in this JVM: " + s);
        }
    }
    if (selected.isEmpty()) {
        // shouldn't happen, Java 6 supports TLSv1
        log.logAlways(Log.WARN, "No TLS support for SSLEepGet, falling back");
        return enabledArr;
    }
    if (log.shouldLog(Log.DEBUG)) {
        List<String> foo = new ArrayList<String>(selected);
        Collections.sort(foo);
        log.debug("Selected: " + foo);
    }
    return selected.toArray(new String[selected.size()]);
}

From source file:com.ibm.mf.geofence.GeofencingJSONUtils.java

/**
 * Parse a list of geofences.//from  w w w. j  ava2 s  .  c om
 * @param json json object representing the list of fences.
 * @return a list of {@link MFGeofence} instances.
 * @throws Exception if a parsing error occurs.
 */
static GeofenceList parseGeofences(JSONObject json) throws Exception {
    Set<PersistentGeofence> localGeofences = new HashSet<>(
            PersistentGeofence.listAll(PersistentGeofence.class));
    List<PersistentGeofence> result = new ArrayList<>();
    JSONArray features = json.getJSONArray("features");
    for (int i = 0; i < features.length(); i++) {
        JSONObject feature = features.getJSONObject(i);
        result.add(parseGeofence(feature));
    }
    int totalFeatures = result.size();
    // shoud now contain only the fences to delete
    localGeofences.removeAll(result);
    int n = localGeofences.size();
    List<String> deletedCodes = null;
    if (n > 0) {
        deletedCodes = new ArrayList<>(n);
        for (PersistentGeofence fence : localGeofences) {
            deletedCodes.add(fence.getCode());
            fence.delete();
        }
        log.debug(String.format("deleted %d geofences from local DB", n));
    }
    /*
    if (json.has("properties")) {
    JSONObject properties = json.getJSONObject("properties");
    List<String> deletedCodes = null;
    if (properties.has("deleted")) {
        JSONArray deletedCodesJson = properties.getJSONArray("deleted");
        deletedCodes = new ArrayList<>(deletedCodesJson.length());
        for (int i=0; i<deletedCodesJson.length(); i++) {
            deletedCodes.add(deletedCodesJson.getString(i));
        }
        if (!deletedCodes.isEmpty()) {
            n = GeofencingUtils.deleteGeofences(deletedCodes);
            log.debug(String.format("deleted %d geofences from local DB", n));
        }
    }
    int totalGeofences = properties.has("totalFeatures") ? properties.getInt("totalFeatures") : -1;
    return new GeofenceList(result, totalGeofences, deletedCodes);
    }
    */
    return new GeofenceList(result, totalFeatures, deletedCodes);
}

From source file:com.taobao.android.builder.tools.manifest.AtlasProxy.java

public static void addAtlasProxyClazz(Document document, Set<String> nonProxyChannels, Result result) {

    Element root = document.getRootElement();// 

    List<? extends Node> serviceNodes = root.selectNodes("//@android:process");

    String packageName = root.attribute("package").getStringValue();

    Set<String> processNames = new HashSet<>();
    processNames.add(packageName);/*from  ww  w  .jav a 2  s.  co m*/

    for (Node node : serviceNodes) {
        if (null != node && StringUtils.isNotEmpty(node.getStringValue())) {
            String value = node.getStringValue();
            processNames.add(value);
        }
    }

    processNames.removeAll(nonProxyChannels);

    List<String> elementNames = Lists.newArrayList("activity", "service", "provider");

    Element applicationElement = root.element("application");

    for (String processName : processNames) {

        for (String elementName : elementNames) {

            String processClazzName = processName.replace(":", "").replace(".", "_");
            String fullClazzName = "ATLASPROXY_" + processClazzName + "_" + StringUtils.capitalize(elementName);

            if ("activity".equals(elementName)) {
                result.proxyActivities.add(fullClazzName);
            } else if ("service".equals(elementName)) {
                result.proxyServices.add(fullClazzName);
            } else {
                result.proxyProviders.add(fullClazzName);
            }

            Element newElement = applicationElement.addElement(elementName);
            newElement.addAttribute("android:name", ATLAS_PROXY_PACKAGE + "." + fullClazzName);

            if (!packageName.equals(processName)) {
                newElement.addAttribute("android:process", processName);
            }

            boolean isProvider = "provider".equals(elementName);
            if (isProvider) {
                newElement.addAttribute("android:authorities", ATLAS_PROXY_PACKAGE + "." + fullClazzName);
            }

        }

    }

}