Example usage for java.util Set containsAll

List of usage examples for java.util Set containsAll

Introduction

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

Prototype

boolean containsAll(Collection<?> c);

Source Link

Document

Returns true if this set contains all of the elements of the specified collection.

Usage

From source file:domainregistry.AdvancedSearch.java

public static Map<String, DataObjectInstance> getDataObjects(Map<String, String> params,
        Map<String, DataObjectInstance> objects) {
    Map<String, DataObjectInstance> foundDataObjects = new HashMap();

    for (Map.Entry<String, DataObjectInstance> entry : objects.entrySet()) {
        DataObjectInstance dataObject = entry.getValue();

        List<String> resourcesTypes = map(dataObject.getResources(), RESOURCES_PREFIX);
        List<String> dataSchemesTypes = map(dataObject.getDataSchemes(), SCHEMES_PREFIX);

        List<String> dataObjectParams = new ArrayList<String>(dataSchemesTypes);
        dataObjectParams.addAll(resourcesTypes);
        Set dataObjectsParamsSet = new HashSet(dataObjectParams);

        if (dataObjectsParamsSet.containsAll(new HashSet<String>(getQueryParams(params)))) {
            foundDataObjects.put(entry.getKey(), dataObject);
        }//from w  ww.j a  v  a2 s.co m
    }

    return foundDataObjects;
}

From source file:Main.java

/**
 * @param ae/* ww  w  .j  a  v a  2  s. com*/
 * @return a set containing the given elements
 * @precondition ae != null
 * @postcondition result != null
 * @postcondition result.containsAll(Arrays.asList(ae))
 */
public static <E> Set<E> asSet(E... ae) {
    final Set<E> result = new HashSet<E>(Arrays.asList(ae));

    assert result != null;
    assert result.containsAll(Arrays.asList(ae));
    return result;
}

From source file:com.linkedin.pinot.core.data.readers.PinotSegmentUtil.java

static boolean compareMultiValueColumn(Object value1, Object value2) {
    Object[] value1Array = (Object[]) value1;
    Object[] value2Array = (Object[]) value2;
    Set<Object> value1Set = new HashSet<>(Arrays.asList(value1Array));
    Set<Object> value2Set = new HashSet<>(Arrays.asList(value2Array));
    return value1Set.containsAll(value2Set);
}

From source file:transaction.script.ProjectTrScript.java

/**
 * @param session// w w w .ja v a  2  s . c  o m
 * @param query
 * @param conditionsMapList
 * @return
 * @throws DfException
 */
public static boolean query(IDfSession session, String query, List<Map<String, Object>> conditionsMapList)
        throws DfException {
    logger.info("Running script. Query to execute is: " + query);

    List<Map<String, Object>> rowsList = Utils.getAllRows(session, query);
    boolean result = true;

    if (conditionsMapList.size() == rowsList.size()) {
        for (int i = 0; i < rowsList.size(); i++) {
            Map<String, Object> executedMap = rowsList.get(i);
            Set<Map.Entry<String, Object>> actualEntrySet = executedMap.entrySet();

            result &= actualEntrySet.containsAll(conditionsMapList.get(i).entrySet());
        }
    } else {
        result = false;
    }

    logger.info("Script execution result is " + result);

    return result;
}

From source file:com.github.stagirs.lingvo.syntax.disambiguity.MyStemTest.java

public static Set<Attr> getAttrs(String form) {
    Set<Attr> result = new HashSet<Attr>();
    Set<String> formSet = new HashSet<String>(Arrays.asList(form.split(",|=")));
    for (Map.Entry<Attr, List<String>> entry : opencorpora2mystem.entrySet()) {
        if (formSet.containsAll(entry.getValue())) {
            if (entry.getKey() == Attr.acc2) {
                continue;
            }//from www.j  av a  2  s  .  com
            result.add(entry.getKey());
        }
        if (formSet.contains("ADVPRO")) {
            result.add(Attr.ADVB);
        }
    }
    return result;
}

From source file:utils.LabelSearchUtil.java

private static boolean hasLabels(final LabelOwner labelOwner, final Set<Long> labelIds) {
    Set<Long> objectLabelIds = new HashSet<>();
    Set<? extends ResourceConvertible> labels = labelOwner.getLabels();
    for (ResourceConvertible label : labels) {
        objectLabelIds.add(Long.valueOf(label.asResource().getId()));
    }/*from www .j  av  a  2s.  c  om*/
    return objectLabelIds.containsAll(labelIds);
}

From source file:cz.hobrasoft.pdfmu.error.ErrorType.java

/**
 * @return true iff each of the constants of this enum is a key in both
 * {@link #CODES} and {@link #messages}.
 *//*from   w  w  w .ja  v a  2 s  .c o m*/
private static boolean codesAndMessagesAvailable() {
    ErrorType[] enumKeyArray = ErrorType.values();
    List<ErrorType> enumKeyList = Arrays.asList(enumKeyArray);
    Collection<String> enumKeyStrings = CollectionUtils.collect(enumKeyList,
            StringValueTransformer.stringValueTransformer());

    Set<String> codeKeySet = CODES.stringPropertyNames();
    assert messages != null;
    Set<String> messageKeySet = messages.keySet();

    return codeKeySet.containsAll(enumKeyStrings) && messageKeySet.containsAll(enumKeyStrings);
}

From source file:apim.restful.exportimport.utils.APIImportUtil.java

/**
 * This method imports an API to the API store
 *
 * @param pathToArchive location of the extracted folder of the API
 *//*from  w  w w  .  ja va  2 s.c  o m*/
public static void importAPI(String pathToArchive) throws APIManagementException {

    Gson gson = new Gson();
    InputStream inputStream = null;
    BufferedReader bufferedReader = null;

    try {
        inputStream = new FileInputStream(pathToArchive + APIImportConstants.JSON_FILE_LOCATION);
        bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
        API importedApi = gson.fromJson(bufferedReader, API.class);
        Set<Tier> allowedTiers = provider.getTiers();
        boolean isAllTiersAvailable = allowedTiers.containsAll(importedApi.getAvailableTiers());

        //The API is only imported if all the tiers are available
        if (isAllTiersAvailable) {

            //Creating API and adding resources
            provider.addAPI(importedApi);
            addAPIImage(pathToArchive, importedApi);
            addAPIDocuments(pathToArchive, importedApi, gson);
            addAPISequences(pathToArchive, importedApi);

        } else {
            log.error("Tiers of the new API is not supported.");
            throw new APIManagementException("Tiers of the new API is not supported.");
        }

    } catch (FileNotFoundException e) {
        log.error("Error in importing API.");
        throw new APIManagementException("Error in importing API.", e);
    } finally {
        try {
            if (inputStream != null) {
                inputStream.close();
            }
            if (bufferedReader != null) {
                bufferedReader.close();
            }
        } catch (IOException e) {
            log.error("Error in closing streams.");
        }
    }
}

From source file:alfio.controller.api.admin.ExtensionApiController.java

private static void ensureIdsArePresent(List<ExtensionMetadataValue> toUpdate,
        List<ExtensionParameterMetadataAndValue> system) {
    Set<Integer> validIds = system.stream().map(ExtensionParameterMetadataAndValue::getId)
            .collect(Collectors.toSet());
    Set<Integer> toUpdateIds = toUpdate.stream().map(ExtensionMetadataValue::getId).collect(Collectors.toSet());
    if (!validIds.containsAll(toUpdateIds)) {
        throw new IllegalStateException();
    }/*  ww w.  j  a v  a 2  s  . co  m*/
}

From source file:com.datatorrent.lib.appdata.schemas.SchemaUtils.java

/**
 * This is a utility method to check that the given JSONObject has the given keys.
 * @param jo The {@link JSONObject} to check.
 * @param fields The keys in the {@link JSONObject} to check.
 * @return True if the given {@link JSONObject} contains all the given keys. False otherwise.
 *///  w  w w  .j a  v  a  2s .  c  o m
public static boolean checkValidKeys(JSONObject jo, Fields fields) {
    @SuppressWarnings("unchecked")
    Set<String> fieldSet = fields.getFields();
    Set<String> jsonKeys = getSetOfJSONKeys(jo);

    return jsonKeys.containsAll(fieldSet);
}