当前位置: 首页>>代码示例>>Java>>正文


Java SetUtils类代码示例

本文整理汇总了Java中org.apache.commons.collections4.SetUtils的典型用法代码示例。如果您正苦于以下问题:Java SetUtils类的具体用法?Java SetUtils怎么用?Java SetUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SetUtils类属于org.apache.commons.collections4包,在下文中一共展示了SetUtils类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createRefreshToken

import org.apache.commons.collections4.SetUtils; //导入依赖的package包/类
@Override
public RefreshToken createRefreshToken(RefreshTokenRequest refreshTokenRequest) {
	Instant now = Instant.now();
	ClientID clientId = refreshTokenRequest.getClientId();
	Subject subject = refreshTokenRequest.getSubject();
	Scope scope = refreshTokenRequest.getScope();

	RefreshTokenContext context = this.refreshTokenStore.findByClientIdAndSubject(clientId, subject);

	if (context == null || !SetUtils.isEqualSet(context.getScope(), scope)) {
		if (context != null) {
			this.refreshTokenStore.revoke(context.getRefreshToken());
		}
		Instant expiry = (!this.refreshTokenLifetime.isZero() && !this.refreshTokenLifetime.isNegative())
				? now.plus(this.refreshTokenLifetime)
				: null;
		context = new RefreshTokenContext(new RefreshToken(), clientId, subject, scope, expiry);
		this.refreshTokenStore.save(context);
	}

	return context.getRefreshToken();
}
 
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:23,代码来源:DefaultTokenService.java

示例2: equals

import org.apache.commons.collections4.SetUtils; //导入依赖的package包/类
@Override
public boolean equals(Object other) {
    final Set<V> set = (Set<V>) getMapping();
    if (set == null) {
        return Collections.emptySet().equals(other);
    }
    if (!(other instanceof Set)) {
        return false;
    }
    Set<?> otherSet = (Set<?>) other;
    return SetUtils.isEqualSet(set, otherSet);
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:13,代码来源:AbstractSetValuedMap.java

示例3: setAclFileAttributes

import org.apache.commons.collections4.SetUtils; //导入依赖的package包/类
/**
 * Sets ACL attributes for the file. Only {@link PublicPrivateCloudPermissionsPrincipal} is accepted in the ACL
 * permissions set by this class. Extend it to allow for storage of other ACL's. The set is first
 * {@link CloudAclEntrySet#optimise() optimised} before being set.
 * @param	cloudAclEntrySet	The ACL entry set for this file
 * @return	The ACL entries which could not be set.
 * @throws IOException 
 */
@SuppressWarnings("unchecked")
public Set<CloudAclEntry<?>> setAclFileAttributes(CloudAclEntrySet cloudAclEntrySet) throws IOException {
	checkAccess(WRITE_ACL_PERMS);

	// Optimise the entry set first
	cloudAclEntrySet.optimise();

	Set<CloudAclEntry<?>> validPrincipals =
		cloudAclEntrySet.stream().filter(e -> PublicPrivateCloudPermissionsPrincipal.class.isAssignableFrom(e.getPrincipalClass()))
			.collect(Collectors.toSet());
	// TODO: Reverse PublicPrivateCloudPermissionsPrincipal if the permission is DENY
	// TODO: Maybe add validation methods on the entry and principal?
	validPrincipals.forEach(pe -> context.getBlobStore().setBlobAccess(path.getContainerName(), path.getPathName(),
				((PublicPrivateCloudPermissionsPrincipal)pe.getPrincipal()).getBlobAccess()));

	// If we got only a subset of the principals then log the invalid ones
	if (validPrincipals.size() < cloudAclEntrySet.size()) {
		Set<CloudAclEntry<?>> differences = SetUtils.difference(cloudAclEntrySet.getAclEntries(), validPrincipals);

		if (!differences.isEmpty()) {
			LOG.warn("Skipping unknown ACL's from the set: {}", differences);
			return differences;
		}
	}

	return Collections.EMPTY_SET;
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:36,代码来源:CloudFileAttributesView.java

示例4: findAclsOfTypeWithAllPermissions

import org.apache.commons.collections4.SetUtils; //导入依赖的package包/类
/**
 * Finds all ACL's with any of the specified type and with <em>all</em> of the permissions
 * type.
 * @param aclOwner
 * @param type
 * @return
 */
public Set<CloudAclEntry<?>> findAclsOfTypeWithAllPermissions(Principal aclOwner, AclEntryType type,
		Set<AclEntryPermission> permissions) {
	return findAcls(a ->
		type.equals(a.getType()) &&
		aclOwner.equals(a.getPrincipal()) &&
		SetUtils.difference(permissions, a.getPermissions()).isEmpty());
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:15,代码来源:CloudAclEntrySet.java

示例5: findAclsOfTypeWithAnyPermissions

import org.apache.commons.collections4.SetUtils; //导入依赖的package包/类
/**
 * Finds all ACL's with any of the specified type and with <em>any</em> of the permissions
 * type.
 * @param aclOwner
 * @param type
 * @return
 */
public Set<CloudAclEntry<?>> findAclsOfTypeWithAnyPermissions(Principal aclOwner, AclEntryType type,
		Set<AclEntryPermission> permissions) {
	return findAcls(a ->
		type.equals(a.getType()) &&
		aclOwner.equals(a.getPrincipal()) &&
		SetUtils.difference(permissions, a.getPermissions()).size() < permissions.size());
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:15,代码来源:CloudAclEntrySet.java

示例6: getCSVRecords

import org.apache.commons.collections4.SetUtils; //导入依赖的package包/类
/**
 * 获取所有行数据
 *
 * @param csvFile   csv 文件
 * @param duplicate 是否过滤重复行 。判断重复行的依据是各个单元格内容是否相同
 * @return
 * @throws IOException
 */
public static List<CSVRecord> getCSVRecords(File csvFile, boolean duplicate) throws IOException {

    List<CSVRecord> collection = CSVParser.parse(csvFile, MyCharsetUtils.detectEncoding(csvFile), CSVFormat.DEFAULT).getRecords();

    if (duplicate) {
        //    logger.info("in list");
        return collection;
    } else {
        //自定义了一个比较器,只比较单元格内容
        //    logger.info("in set.");
        Set set = new TreeSet(new Comparator<CSVRecord>() {
            @Override
            // record.toString() 方法输出为  CSVRecord [comment=null, mapping=null, recordNumber=55, values=[USDA, 美国农业部, 1]]
            // values 为各行的值
            public int compare(CSVRecord csv1, CSVRecord csv2) {
                String values1 = getCSVListValues(csv1).toString();
                String values2 = getCSVListValues(csv2).toString();
                return values1.compareTo(values2);
            }
        });

        //创建一个按照 参数 set 进行排序的空 set ,用法见 SetUtils
        Set set1 = SetUtils.orderedSet(set);
        //重新用 set 包装,去掉重复元素
        for (CSVRecord csvRecord : collection) {
            set1.add(csvRecord);
        }

        return new ArrayList<>(set1);
    }
}
 
开发者ID:h819,项目名称:spring-boot,代码行数:40,代码来源:MyCSVUtils.java

示例7: equals

import org.apache.commons.collections4.SetUtils; //导入依赖的package包/类
public boolean equals( Object object)
{
TestCase other =
  object != null && object.getClass().equals( getClass())
  ? (TestCase) object
  : null;

return
  other != null
  && id_ == other.id_
  && SetUtils.isEqualSet( varBindings_, other.varBindings_);
}
 
开发者ID:Cornutum,项目名称:tcases,代码行数:13,代码来源:TestCase.java

示例8: hashCode

import org.apache.commons.collections4.SetUtils; //导入依赖的package包/类
@Override
public int hashCode() {
    final Set<V> set = (Set<V>) getMapping();
    return SetUtils.hashCodeForSet(set);
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:6,代码来源:AbstractSetValuedMap.java

示例9: execute

import org.apache.commons.collections4.SetUtils; //导入依赖的package包/类
@Override
@Transactional
public void execute( JobConfiguration jobConfiguration )
{
    notifier.clear( jobConfiguration ).notify( jobConfiguration, "Monitoring data" );

    MonitoringJobParameters monitoringJobParameters = (MonitoringJobParameters) jobConfiguration.getJobParameters();

    //TODO improve collection usage
    
    try
    {
        List<Period> periods;
        Collection<ValidationRule> validationRules;
        List<String> groupUIDs = monitoringJobParameters.getValidationRuleGroups();

        if ( groupUIDs.isEmpty() )
        {
            validationRules = validationRuleService
                .getValidationRulesWithNotificationTemplates();
        }
        else
        {
            validationRules = groupUIDs.stream()
                .map( ( uid ) -> validationRuleService.getValidationRuleGroup( uid ) )
                .filter( Objects::nonNull )
                .map( ValidationRuleGroup::getMembers )
                .filter( Objects::nonNull )
                .reduce( Sets.newHashSet(), SetUtils::union );
        }

        if ( monitoringJobParameters.getRelativeStart() != 0 && monitoringJobParameters.getRelativeEnd() != 0 )
        {
            Date startDate = DateUtils.getDateAfterAddition( new Date(), monitoringJobParameters.getRelativeStart() );
            Date endDate = DateUtils.getDateAfterAddition( new Date(), monitoringJobParameters.getRelativeEnd() );

            periods = periodService.getPeriodsBetweenDates( startDate, endDate );

            periods = ListUtils.union( periods, periodService.getIntersectionPeriods( periods ) );
        }
        else
        {
            periods = validationRules.stream()
                .map( ValidationRule::getPeriodType )
                .distinct()
                .map( ( vr ) -> Arrays.asList( vr.createPeriod(), vr.getPreviousPeriod( vr.createPeriod() ) ) )
                .reduce( Lists.newArrayList(), ListUtils::union );
        }

        ValidationAnalysisParams parameters = validationService
            .newParamsBuilder( validationRules, null, periods )
            .withIncludeOrgUnitDescendants( true )
            .withMaxResults( ValidationService.MAX_SCHEDULED_ALERTS )
            .withSendNotifications( monitoringJobParameters.isSendNotifications() )
            .withPersistResults( monitoringJobParameters.isPersistResults() )
            .build();

        validationService.validationAnalysis( parameters );

        notifier.notify( jobConfiguration, INFO, "Monitoring process done", true );
    }
    catch ( RuntimeException ex )
    {
        notifier.notify( jobConfiguration, ERROR, "Process failed: " + ex.getMessage(), true );

        messageService.sendSystemErrorNotification( "Monitoring process failed", ex );

        throw ex;
    }
}
 
开发者ID:dhis2,项目名称:dhis2-core,代码行数:71,代码来源:MonitoringJob.java

示例10: CollectionActionDispatcher

import org.apache.commons.collections4.SetUtils; //导入依赖的package包/类
public CollectionActionDispatcher(Collection<E> cache){
this.cache     =cache;
this.targets   =SetUtils.newIdentityHashSet();
   }
 
开发者ID:jtrfp,项目名称:terminal-recall,代码行数:5,代码来源:CollectionActionDispatcher.java

示例11: remove

import org.apache.commons.collections4.SetUtils; //导入依赖的package包/类
/**
 * Removes all values associated with the specified key.
 * <p>
 * A subsequent <code>get(Object)</code> would return an empty set.
 *
 * @param key the key to remove values from
 * @return the <code>Set</code> of values removed, will return an empty,
 *   unmodifiable set for no mapping found.
 */
@Override
public Set<V> remove(Object key) {
    return SetUtils.emptyIfNull(getMap().remove(key));
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:14,代码来源:AbstractSetValuedMap.java

示例12: getOrderSet

import org.apache.commons.collections4.SetUtils; //导入依赖的package包/类
/**
 * Set,过滤重复元素
 * 按照添加的顺序
 * Returns a set that maintains the order of elements that are added backed by the given set.
 * If an element is added twice, the order is determined by the first add. The order is observed through the iterator or toArray.
 * <p/>
 *
 * @param set
 * @return
 */
public Set getOrderSet(Set set) {
    // 创建一个按照 参数 set 元素放入顺序进行排序的空 set ,返回后需要按照需求添加元素
    return SetUtils.orderedSet(set);
}
 
开发者ID:h819,项目名称:spring-boot,代码行数:15,代码来源:CollectionExamples.java


注:本文中的org.apache.commons.collections4.SetUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。