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


Java CollectionUtils.isNotEmpty方法代码示例

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


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

示例1: doInternal

import org.apache.commons.collections4.CollectionUtils; //导入方法依赖的package包/类
@Override
public boolean doInternal(MessageReceivedEvent message, BotContext context, String query) throws DiscordException {
    if (!message.getMessage().getAttachments().isEmpty()) {
        query = message.getMessage().getAttachments().get(0).getUrl();
    }

    List<String> results = (List<String>) context.getAttribute(ATTR_SEARCH_RESULTS);
    if (StringUtils.isNumeric(query) && CollectionUtils.isNotEmpty(results)) {
        int index = Integer.parseInt(query) - 1;
        query = getChoiceUrl(context, index);
        if (query == null) {
            messageManager.onQueueError(message.getChannel(), "discord.command.audio.play.select", results.size());
            return fail(message);
        }
    }
    message.getTextChannel().sendTyping().queue();
    if (!ResourceUtils.isUrl(query)) {
        String result = youTubeService.searchForUrl(query);
        query = result != null ? result : query;
    }
    loadAndPlay(message.getTextChannel(), context, message.getMember(), query);
    return true;
}
 
开发者ID:GoldRenard,项目名称:JuniperBotJ,代码行数:24,代码来源:PlayCommand.java

示例2: peerExplorer

import org.apache.commons.collections4.CollectionUtils; //导入方法依赖的package包/类
@Bean
public PeerExplorer peerExplorer(RskSystemProperties rskConfig) {
    ECKey key = rskConfig.getMyKey();
    Node localNode = new Node(key.getNodeId(), rskConfig.getExternalIp(), rskConfig.listenPort());
    NodeDistanceTable distanceTable = new NodeDistanceTable(KademliaOptions.BINS, KademliaOptions.BUCKET_SIZE, localNode);
    long msgTimeOut = rskConfig.peerDiscoveryMessageTimeOut();
    long refreshPeriod = rskConfig.peerDiscoveryRefreshPeriod();
    List<String> initialBootNodes = rskConfig.peerDiscoveryIPList();
    List<Node> activePeers = rskConfig.peerActive();
    if(CollectionUtils.isNotEmpty(activePeers)) {
        for(Node n : activePeers) {
            InetSocketAddress address = n.getAddress();
            initialBootNodes.add(address.getHostName() + ":" + address.getPort());
        }
    }
    return new PeerExplorer(initialBootNodes, localNode, distanceTable, key, msgTimeOut, refreshPeriod);
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:18,代码来源:DefaultConfig.java

示例3: elementTreeToList

import org.apache.commons.collections4.CollectionUtils; //导入方法依赖的package包/类
/**
 * 层级关系的list转换为平行的list
 * <p>
 * 现在是一个层级关系的 树形 结构
 * <pre>
 *                          root
 *   children | children children | children children children
 *   ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
 *   转换为平行的,也就是普通的链表
 *   element | element | element | element | element | element
 * </pre>
 *
 * @param trees     implements {@link ParentChildrenRecursion}
 * @param container 存储
 * @return
 */
public static List elementTreeToList ( List< ? extends ParentChildrenRecursion > trees ,
									   List< ParentChildrenRecursion > container ) {
	if ( CollectionUtils.isEmpty( trees ) ) {
		return container;
	}
	for ( ParentChildrenRecursion tree : trees ) {
		container.add( tree );
		if ( CollectionUtils.isNotEmpty( tree.getChildren() ) ) {
			elementTreeToList( tree.getChildren() , container );
		}
	}
	// 清空 children 内容
	return container.parallelStream()
					.map( element -> element.setChildren( null ) )
					.collect( Collectors.toList() );
}
 
开发者ID:yujunhao8831,项目名称:spring-boot-start-current,代码行数:33,代码来源:RecursionUtils.java

示例4: getNodes

import org.apache.commons.collections4.CollectionUtils; //导入方法依赖的package包/类
public synchronized List<NodeHandler> getNodes(Set<String> nodesInUse) {
    List<NodeHandler> handlers = new ArrayList<>();
    handlers.addAll(initialNodes);

    List<Node> foundNodes = this.peerExplorer.getNodes();
    if (this.discoveryEnabled && CollectionUtils.isNotEmpty(foundNodes)) {
        logger.debug("{} Nodes retrieved from the PE.", CollectionUtils.size(foundNodes));
        foundNodes.stream().filter(n -> !nodeHandlerMap.containsKey(n.getHexId())).forEach(this::createNodeHandler);
    }

    for(NodeHandler handler : this.nodeHandlerMap.values()) {
        if(!nodesInUse.contains(handler.getNode().getHexId())) {
            handlers.add(handler);
        }
    }
    return handlers;
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:18,代码来源:NodeManager.java

示例5: handleRequest

import org.apache.commons.collections4.CollectionUtils; //导入方法依赖的package包/类
@Override
public ApiGatewayResponse handleRequest(SNSEvent input, Context context) {

	if (CollectionUtils.isNotEmpty(input.getRecords())) {
		SNSRecord record = input.getRecords().get(0);
		if (StringUtils.containsIgnoreCase(record.getSNS().getTopicArn(), "handle-emoji")) {
			LOG.info("Got message to handle-emoji topic.");
			handleSlackEvent(record);
		} else if (StringUtils.containsIgnoreCase(record.getSNS().getTopicArn(), "s3-file-ready")) {
			LOG.info("Got message to s3-file-ready topic.");
			postImageToSlack(record);
		} else if (StringUtils.containsIgnoreCase(record.getSNS().getTopicArn(), "gif-generator-error")) {
			LOG.info("Got message to gif-generator-error topic.");
			postErrorMessageToSlack(record);
		}
	}

	Response responseBody = new Response("pprxmtr-file-fetcher called succesfully.", new HashMap<>());
	return ApiGatewayResponse.builder().setStatusCode(200).setObjectBody(responseBody).build();
}
 
开发者ID:villeau,项目名称:pprxmtr,代码行数:21,代码来源:Handler.java

示例6: setSimilarityFields

import org.apache.commons.collections4.CollectionUtils; //导入方法依赖的package包/类
public MltConfig setSimilarityFields(String lang, Collection<String> similarityFields) {
    lang = StringUtils.lowerCase(lang, Locale.ROOT);
    if(CollectionUtils.isEmpty(similarityFields)){
        langSimilarityFields.remove(lang);
    } else {
        Collection<String> langFields = similarityFields.stream()
                .filter(StringUtils::isNoneBlank)
                .collect(Collectors.toCollection(() -> new LinkedHashSet<>()));
        if(CollectionUtils.isNotEmpty(langFields)){
            langSimilarityFields.put(lang, langFields);
        } else {
            langSimilarityFields.remove(lang);
        }
    }
    return this;
}
 
开发者ID:redlink-gmbh,项目名称:smarti,代码行数:17,代码来源:MltConfig.java

示例7: addNewSiblings

import org.apache.commons.collections4.CollectionUtils; //导入方法依赖的package包/类
/**
 * Saves uncles of the current block into the siblings map to use in the future for fee distribution
 */
private void addNewSiblings() {
    // Add uncles of the execution block to the siblings map
    List<BlockHeader> uncles = executionBlock.getUncleList();
    if (CollectionUtils.isNotEmpty(uncles)) {
        for (BlockHeader uncleHeader : uncles) {
            List<Sibling> siblings = provider.getSiblings().get(uncleHeader.getNumber());
            if (siblings == null) {
                siblings = new ArrayList<>();
            }

            siblings.add(new Sibling(uncleHeader, executionBlock.getHeader().getCoinbase(), executionBlock.getNumber()));
            provider.getSiblings().put(uncleHeader.getNumber(), siblings);
        }
    }
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:19,代码来源:Remasc.java

示例8: findSelfNamedOrDefaultParamGroupName

import org.apache.commons.collections4.CollectionUtils; //导入方法依赖的package包/类
/**
 * Finds the name of the instance's paramgroup whose name embeds the instname.  If not found, then simply returns
 * the first paramgroup name.
 */
public String findSelfNamedOrDefaultParamGroupName(DBInstance dbInstance)
{
  String selfNamedGroupName = findSelfNamedParamGroupName(dbInstance);
  if (selfNamedGroupName != null)
  {
    return selfNamedGroupName;
  }
  if (dbInstance != null && CollectionUtils.isNotEmpty(dbInstance.getDBParameterGroups()))
  {
    String defaultName = dbInstance.getDBParameterGroups().get(0).getDBParameterGroupName();
    LOGGER.warn("Could not find paramgroup containing the string '" + dbInstance.getDBInstanceIdentifier()
        + "', falling back to '" + defaultName + "'");
    return defaultName;
  }
  return null;
}
 
开发者ID:Nike-Inc,项目名称:bluegreen-manager,代码行数:21,代码来源:RdsAnalyzer.java

示例9: sumCorrelationsAcrossBuckets

import org.apache.commons.collections4.CollectionUtils; //导入方法依赖的package包/类
static BigDecimal sumCorrelationsAcrossBuckets(RiskClass riskClass, List<BucketWeightedAggregation> aggregateByBucket) {
  BigDecimal sum = BigDecimal.ZERO;

  if (CollectionUtils.isNotEmpty(aggregateByBucket)) {
    for (BucketWeightedAggregation bucketAggregateB : aggregateByBucket) {
      for (BucketWeightedAggregation bucketAggregateC : aggregateByBucket) {
        if (!StringUtils.equals(bucketAggregateB.getBucket(), bucketAggregateC.getBucket())) {
          BigDecimal concentrationRiskFactor = RiskConcentration.getDeltaCrossBucketConcentration(riskClass, bucketAggregateB, bucketAggregateC);
          BigDecimal correlation = RiskCorrelation.getBucketCorrelation(riskClass, bucketAggregateB.getBucket(), bucketAggregateC.getBucket());

          BigDecimal bucketBSum = WeightedSensitivityUtils.sumWeightSensitivities(bucketAggregateB.getWeightedSensitivities());
          BigDecimal bucketCSum = WeightedSensitivityUtils.sumWeightSensitivities(bucketAggregateC.getWeightedSensitivities());

          BigDecimal bucketBAggregate = bucketAggregateB.getAggregate();
          BigDecimal bucketCAggregate = bucketAggregateC.getAggregate();
          BigDecimal sb = bucketBSum.min(bucketBAggregate).max(bucketBAggregate.negate());
          BigDecimal sc = bucketCSum.min(bucketCAggregate).max(bucketCAggregate.negate());
          BigDecimal product = correlation.multiply(concentrationRiskFactor).multiply(sb).multiply(sc);
          sum = sum.add(product);
        }
      }
    }
  }
  return sum;
}
 
开发者ID:AcadiaSoft,项目名称:simm-lib,代码行数:26,代码来源:DeltaMarginAcrossBucketUtils.java

示例10: toCacheUserInternal

import org.apache.commons.collections4.CollectionUtils; //导入方法依赖的package包/类
/**
 * Transform user to JPA.
 */
private CacheUser toCacheUserInternal(final UserOrg user) {
	final CacheUser entity = new CacheUser();
	entity.setId(user.getId());
	entity.setFirstName(user.getFirstName());
	entity.setLastName(user.getLastName());
	if (CollectionUtils.isNotEmpty(user.getMails())) {
		entity.setMails(user.getMails().get(0));
	}
	return entity;
}
 
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:14,代码来源:LdapCacheDao.java

示例11: getClasses

import org.apache.commons.collections4.CollectionUtils; //导入方法依赖的package包/类
/**
 * 返回包名路径下所有的类
 * @return         类集合
 */
@Override
public List<Class<?>> getClasses() {
    AssertUtil.assertNotBlank(pkgName, "包路径不能为空");
    synchronized (lock) {
        if (CollectionUtils.isNotEmpty(classes)) {
            return classes;
        }
        //对包名进行替换 .==>/
        String pkgDir = pkgName.replace(".", "/");
        //定义一个枚举集合
        Enumeration<URL> dirs;
        try {
            dirs = Thread.currentThread().getContextClassLoader().getResources(pkgDir);
            while (dirs.hasMoreElements()) {
                URL url = dirs.nextElement();
                String protocol = url.getProtocol();
                if (StringUtils.equals(FILE_PROTOCOL, protocol)) { //如果是文件
                    //获取包的物理路径
                    String pkgPath = URLDecoder.decode(url.getFile(), StandardCharsets.UTF_8.displayName());
                    //扫描包下的文件并放入集合
                    addClassesToList(pkgName, pkgPath, classes);
                }
            }
        } catch (IOException e) {
            throw new RuntimeException("扫描类失败", e);
        }

        return classes;
    }
}
 
开发者ID:huhuics,项目名称:tauren,代码行数:35,代码来源:DefaultClassScanner.java

示例12: getClassesByAnnotation

import org.apache.commons.collections4.CollectionUtils; //导入方法依赖的package包/类
/**
 * 根据注解获取类
 * @return  结果不包含接口或抽象类
 */
@Override
public List<Class<?>> getClassesByAnnotation(Class<? extends Annotation> anno) {
    List<Class<?>> classesByAnno = new ArrayList<Class<?>>();
    List<Class<?>> classes = getClasses();
    if (CollectionUtils.isNotEmpty(classes)) {
        for (Class<?> _clazz : classes) {
            if (_clazz.isAnnotationPresent(anno) && !ClassUtil.isInterfaceOrAbstract(_clazz)) {
                classesByAnno.add(_clazz);
            }
        }
    }

    return classesByAnno;
}
 
开发者ID:huhuics,项目名称:tauren,代码行数:19,代码来源:DefaultClassScanner.java

示例13: assignTask

import org.apache.commons.collections4.CollectionUtils; //导入方法依赖的package包/类
public void  assignTask(List<String> monitorIds, String taskId) throws NiPingException {
    try {
        //validate has assigned TODO
        monitorTaskDao.removeMonitorTask(taskId);
        if (CollectionUtils.isNotEmpty(monitorIds)) {
            monitorTaskDao.insertMonitorTask(monitorIds, taskId);
        }
        log.debug("task {} has been assigned to monitors {}", taskId, Arrays.toString(monitorIds.toArray(new String[]{})));
    } catch (DBIException e) {
        log.error("assign task {} to monitor {} error: {}", taskId, Arrays.toString(monitorIds.toArray(new String[]{})),
                ExceptionUtils.getMessage(e));
        throw new NiPingException(DBError);
    }
}
 
开发者ID:CloudWise-OpenSource,项目名称:SAPNetworkMonitor,代码行数:15,代码来源:TaskService.java

示例14: aggregateCrossBucket

import org.apache.commons.collections4.CollectionUtils; //导入方法依赖的package包/类
/**
 * As defined in Appendix 1 ISDA_SIMM_2.0_(PUBLIC).pdf
 */
static BigDecimal aggregateCrossBucket(RiskClass riskClass, List<BucketWeightedAggregation> aggregateByBucket) {
  List<BucketWeightedAggregation> nonResiduals = BucketWeightedAggregationUtils.filterOutResiduals(aggregateByBucket);
  if (CollectionUtils.isNotEmpty(nonResiduals)) {
    BigDecimal sumSquaresByBucket = BucketWeightedAggregationUtils.sumSquared(nonResiduals);
    BigDecimal sumCorrelationsAcrossBuckets = sumCorrelationsAcrossBuckets(riskClass, nonResiduals);
    BigDecimal crossSum = sumSquaresByBucket.add(sumCorrelationsAcrossBuckets);
    BigDecimal crossSqrt = BigDecimalUtils.sqrt(crossSum);
    return crossSqrt;
  } else {
    return BigDecimal.ZERO;
  }
}
 
开发者ID:AcadiaSoft,项目名称:simm-lib,代码行数:16,代码来源:VegaMarginAcrossBucketUtils.java

示例15: tree

import org.apache.commons.collections4.CollectionUtils; //导入方法依赖的package包/类
/**
 * 规整
 *
 * @param parentId : 上级ID
 * @param content
 * @return
 */
private static List< ? extends ParentChildrenRecursion > tree ( Serializable parentId ,
																Map< Serializable, List< ParentChildrenRecursion > > content ) {
	List< ParentChildrenRecursion > container = new ArrayList<>();
	List< ParentChildrenRecursion > children  = content.get( parentId );
	if ( CollectionUtils.isNotEmpty( children ) ) {
		children.forEach( element -> {
			element.setChildren( tree( element.getId() , content ) );
			container.add( element );
		} );
	}
	return container;
}
 
开发者ID:yujunhao8831,项目名称:spring-boot-start-current,代码行数:20,代码来源:RecursionUtils.java


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