Java Code Examples for org.apache.commons.collections4.CollectionUtils#isSubCollection()

The following examples show how to use org.apache.commons.collections4.CollectionUtils#isSubCollection() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UnitDistrictIndex.java    From ad with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("all")
public boolean match(Long adUnitId, List<DistrictFeature.ProvinceAndCity> districts) {
    if (redisTemplate.hasKey(UNIT_DISTRICT_INDEX_PREFIX + adUnitId) &&
            CollectionUtils.isNotEmpty(
                    redisTemplate.opsForSet()
                            .members(UNIT_DISTRICT_INDEX_PREFIX + adUnitId))) {
        Set unitDistricts = redisTemplate.opsForSet().members(UNIT_DISTRICT_INDEX_PREFIX + adUnitId);
        if (CollectionUtils.isNotEmpty(unitDistricts)) {
            List<String> targetDistrict = districts.stream()
                    .map(district -> CommonUtils.stringContact(district.getProvince(), district.getCity()))
                    .collect(Collectors.toList());
            return CollectionUtils.isSubCollection(targetDistrict, unitDistricts);
        }
    }
    return false;
}
 
Example 2
Source File: UnitItIndex.java    From ad with Apache License 2.0 5 votes vote down vote up
/**
 * 查询 unitId 对应的兴趣标签是否包含 itTagSet集合
 * @param unitId
 * @param itTagSet
 * @return
 */
@SuppressWarnings("all")
public boolean match(Long unitId, List<String> itTagSet) {
    if (redisTemplate.hasKey(UNIT_IT_INDEX_PREFIX + unitId)) {
        Set<Object> unitItTagSet = redisTemplate.opsForSet().members(UNIT_IT_INDEX_PREFIX + unitId);
        if (CollectionUtils.isNotEmpty(unitItTagSet)) {
            // itTagSet 是否为 unitTagSet的子集
            return CollectionUtils.isSubCollection(itTagSet, unitItTagSet);
        }
    }
    return false;
}
 
Example 3
Source File: UnitKeywordIndex.java    From ad with Apache License 2.0 5 votes vote down vote up
/**
 * 开放方法用来匹配 某个推广单元unitId 是否包含了一些关键词 List<String> keyWords
 */
@SuppressWarnings({"all"})
public boolean match(Long unitId, List<String> keywords) {
    if (redisTemplate.hasKey(UNIT_KEYWORD_INDEX_PREFIX + unitId)) {
        Set<Object> unitKeywords = redisTemplate.opsForSet().members(UNIT_KEYWORD_INDEX_PREFIX + unitId);
        if (CollectionUtils.isNotEmpty(unitKeywords)) {
            // 判断 keywords 是不是 unitKeywords的子集
            return CollectionUtils.isSubCollection(keywords, unitKeywords);
        }
    }
    return false;
}
 
Example 4
Source File: SyncDashboard.java    From hygieia-core with Apache License 2.0 5 votes vote down vote up
private boolean associateBuild(Component component, CollectorItem collectorItem) {
    List<CollectorItem> scmCollectorItems = Lists.newArrayList(component.getCollectorItems(CollectorType.SCM));
    if(CollectionUtils.isEmpty(scmCollectorItems)) return false;

    // get the last build and compare the codeRepos to be subset of validRepoBranchSet if not then do not associate dashboard.
    Build build = buildRepository.findTop1ByCollectorItemIdOrderByTimestampDesc(collectorItem.getId());
    if(build == null || CollectionUtils.isEmpty(build.getCodeRepos())) return false;

    Set<RepoBranch> validRepoBranchSet = buildValidRepoBranches(component, getRepoType(build));
    Set<RepoBranch> repoBranchesBuild = Sets.newConcurrentHashSet(build.getCodeRepos());

    return CollectionUtils.isSubCollection(repoBranchesBuild, validRepoBranchSet);
}
 
Example 5
Source File: SyncDashboard.java    From hygieia-core with Apache License 2.0 5 votes vote down vote up
private boolean associateCodeQuality (@NotNull Component component,@NotNull CollectorItem collectorItem) {
    List<CollectorItem> scmCollectorItems = Lists.newArrayList(component.getCollectorItems(CollectorType.SCM));
    if(CollectionUtils.isEmpty(scmCollectorItems)) return false;

    CodeQuality entity = codeQualityRepository.findTop1ByCollectorItemIdOrderByTimestampDesc(collectorItem.getId());
    if(entity == null || entity.getBuildId() == null) return false;

    Build build = buildRepository.findOne(entity.getBuildId());
    if(build == null || CollectionUtils.isEmpty(build.getCodeRepos())) return false;

    Set<RepoBranch> validRepoBranchSet = buildValidRepoBranches(component, getRepoType(build));
    Set<RepoBranch> repoBranchesBuild = Sets.newConcurrentHashSet(build.getCodeRepos());

    return CollectionUtils.isSubCollection(repoBranchesBuild, validRepoBranchSet);
}