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


Java CollectionUtils类代码示例

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


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

示例1: explore

import org.springframework.util.CollectionUtils; //导入依赖的package包/类
@Override
public void explore(List<AlarmRule> rules) {
    if (CollectionUtils.isEmpty(rules)) {
        return;
    }
    Long pipelineId = rules.get(0).getPipelineId();

    List<ProcessStat> processStats = processStatService.listRealtimeProcessStat(pipelineId);
    if (CollectionUtils.isEmpty(processStats)) {
        return;
    }

    long now = System.currentTimeMillis();
    Map<Long, Long> processTime = new HashMap<Long, Long>();
    for (ProcessStat processStat : processStats) {
        Long timeout = 0L;
        if (!CollectionUtils.isEmpty(processStat.getStageStats())) {
            timeout = now - processStat.getStageStats().get(0).getStartTime();
        }
        processTime.put(processStat.getProcessId(), timeout);
    }

    String message = StringUtils.EMPTY;
    for (AlarmRule rule : rules) {
        if (message.isEmpty()) {
            message = checkTimeout(rule, processTime);
        } else {
            checkTimeout(rule, processTime);
        }
    }

    if (!message.isEmpty()) {
        logRecordAlarm(pipelineId, MonitorName.PROCESSTIMEOUT, message);
    }

}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:37,代码来源:ProcessTimeoutRuleMonitor.java

示例2: getTestFrameworkBundlesNames

import org.springframework.util.CollectionUtils; //导入依赖的package包/类
protected String[] getTestFrameworkBundlesNames() {
	String[] bundles = super.getTestFrameworkBundlesNames();

	// remove slf4j
	Collection bnds = new ArrayList(bundles.length);
	CollectionUtils.mergeArrayIntoCollection(bundles, bnds);

	for (Iterator iterator = bnds.iterator(); iterator.hasNext();) {
		String object = (String) iterator.next();
		// remove slf4j
		if (object.startsWith("org.slf4j"))
			iterator.remove();
	}
	// add commons logging
	bnds.add("org.eclipse.bundles,commons-logging,20070611");

	return (String[]) bnds.toArray(new String[bnds.size()]);
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:19,代码来源:CommonsLogging104Test.java

示例3: getUserInfoRestTemplate

import org.springframework.util.CollectionUtils; //导入依赖的package包/类
@Override
public OAuth2RestTemplate getUserInfoRestTemplate() {
	if (this.oauth2RestTemplate == null) {
		this.oauth2RestTemplate = createOAuth2RestTemplate(
				this.details == null ? DEFAULT_RESOURCE_DETAILS : this.details);
		this.oauth2RestTemplate.getInterceptors()
				.add(new AcceptJsonRequestInterceptor());
		AuthorizationCodeAccessTokenProvider accessTokenProvider = new AuthorizationCodeAccessTokenProvider();
		accessTokenProvider.setTokenRequestEnhancer(new AcceptJsonRequestEnhancer());
		this.oauth2RestTemplate.setAccessTokenProvider(accessTokenProvider);
		if (!CollectionUtils.isEmpty(this.customizers)) {
			AnnotationAwareOrderComparator.sort(this.customizers);
			for (UserInfoRestTemplateCustomizer customizer : this.customizers) {
				customizer.customize(this.oauth2RestTemplate);
			}
		}
	}
	return this.oauth2RestTemplate;
}
 
开发者ID:spring-projects,项目名称:spring-security-oauth2-boot,代码行数:20,代码来源:DefaultUserInfoRestTemplateFactory.java

示例4: findByTopicFilter

import org.springframework.util.CollectionUtils; //导入依赖的package包/类
/**
 * Finds the {@link TopicSubscription} object from the {@code topicSubscriptions} list that
 * matches the {@code topicFilter}.
 * <p>
 * The search on the {@code topicFilter} is case-sensitive. If a matching
 * {@link TopicSubscription} value could not be found, a null value will be returned.
 * 
 * @param topicFilter the Topic Filter to search for
 * @param topicSubscriptions a {@link List} of {@link TopicSubscription} objects for search
 * 
 * @return a {@link TopicSubscription} object, or null if not found
 */
public static TopicSubscription findByTopicFilter(final String topicFilter,
    List<TopicSubscription> topicSubscriptions)
{
    TopicSubscription record = null;
    if (StringUtils.hasText(topicFilter)
        && !CollectionUtils.isEmpty(topicSubscriptions))
    {
        for (TopicSubscription topicSubscription : topicSubscriptions)
        {
            if (topicSubscription.getTopicFilter().equals(topicFilter))
            {
                record = topicSubscription;
                break;
            }
        }
    }
    return record;
}
 
开发者ID:christophersmith,项目名称:summer-mqtt,代码行数:31,代码来源:TopicSubscriptionHelper.java

示例5: selectByPrimaryKey

import org.springframework.util.CollectionUtils; //导入依赖的package包/类
public <T> T selectByPrimaryKey(Object primaryKey, Class<T> entityClass) {
    Entity entity=getEntity(entityClass);
    Entity.Column primaryKeyColumn=entity.getPrimaryKey();
    if (primaryKey == null) {
        throw new RuntimeException("没有指定主键");
    }
    final StringBuilder sql = new StringBuilder();
    sql.append(SqlHelper.selectFromTable(entity.getTableName()));
    sql.append(SqlHelper.whereClause(Collections.singleton(primaryKeyColumn)));
    System.out.println(sql.toString());
    List<T> resultList=jdbcTemplate.query(sql.toString(), new MapSqlParameterSource(primaryKeyColumn.getName(), primaryKey), new BeanPropertyRowMapper<>(entityClass));
    if (!CollectionUtils.isEmpty(resultList)) {
        return resultList.get(0);
    }
    return null;
}
 
开发者ID:ChenAt,项目名称:common-dao,代码行数:17,代码来源:SelectSupport.java

示例6: initTermin

import org.springframework.util.CollectionUtils; //导入依赖的package包/类
private synchronized void initTermin(List<String> termins) {
    if (CollectionUtils.isEmpty(termins)) {
        return;
    }

    List<Long> processIds = new ArrayList<Long>(termins.size());
    for (String termin : termins) {
        processIds.add(StagePathUtils.getProcessId(termin));
    }
    // 排序一下
    Collections.sort(processIds);
    for (Long processId : processIds) {
        boolean successed = waitProcessIds.offer(processId);
        if (successed && logger.isDebugEnabled()) {
            logger.debug("## {} add termin id [{}]", getPipelineId(), processId);
        }
    }
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:19,代码来源:TerminMonitor.java

示例7: equals

import org.springframework.util.CollectionUtils; //导入依赖的package包/类
/********************************* Override(s) ********************************/
@Override
public boolean equals(Object object) {
    if (object == this)
        return true;
    if (!(object instanceof FileRecord)) {
        return false;
    }

    /* Cast FileRecord */
    FileRecord fileRecord = (FileRecord) object;

    /* Empty List */
    if (CollectionUtils.isEmpty(this.getData())
            || CollectionUtils.isEmpty(fileRecord.getData())) {
        return false;
    }

    /* Check Whether Equal */
    return fileRecord.getData().toString()
            .equals(this.getData().toString());
}
 
开发者ID:ukubuka,项目名称:ukubuka-core,代码行数:23,代码来源:FileRecord.java

示例8: resolve

import org.springframework.util.CollectionUtils; //导入依赖的package包/类
@Override
public ItemChangeSets resolve(long namespaceId, String configText, List<ItemDTO> baseItems) {
  ItemChangeSets changeSets = new ItemChangeSets();
  if (StringUtils.isEmpty(configText)) {
    return changeSets;
  }
  if (CollectionUtils.isEmpty(baseItems)) {
    changeSets.addCreateItem(createItem(namespaceId, 0, configText));
  } else {
    ItemDTO beforeItem = baseItems.get(0);
    if (!configText.equals(beforeItem.getValue())) {//update
      changeSets.addUpdateItem(createItem(namespaceId, beforeItem.getId(), configText));
    }
  }

  return changeSets;
}
 
开发者ID:dewey-its,项目名称:apollo-custom,代码行数:18,代码来源:FileTextResolver.java

示例9: loadReleaseMessages

import org.springframework.util.CollectionUtils; //导入依赖的package包/类
private void loadReleaseMessages(long startId) {
  boolean hasMore = true;
  while (hasMore && !Thread.currentThread().isInterrupted()) {
    //current batch is 500
    List<ReleaseMessage> releaseMessages = releaseMessageRepository
        .findFirst500ByIdGreaterThanOrderByIdAsc(startId);
    if (CollectionUtils.isEmpty(releaseMessages)) {
      break;
    }
    releaseMessages.forEach(this::mergeReleaseMessage);
    int scanned = releaseMessages.size();
    startId = releaseMessages.get(scanned - 1).getId();
    hasMore = scanned == 500;
    logger.info("Loaded {} release messages with startId {}", scanned, startId);
  }
}
 
开发者ID:dewey-its,项目名称:apollo-custom,代码行数:17,代码来源:ReleaseMessageServiceWithCache.java

示例10: findOne

import org.springframework.util.CollectionUtils; //导入依赖的package包/类
@Override
public OrderDTO findOne(String orderId) {

    OrderMaster orderMaster = orderMasterRepository.findOne(orderId);
    if (orderMaster == null) {
        throw new SellException(ResultEnum.ORDER_NOT_EX);
    }

    List<OrderDetail> orderDetailList = orderDetailRepository.findByOrderId(orderId);
    if (CollectionUtils.isEmpty(orderDetailList)) {
        throw new SellException(ResultEnum.ORDERDETAIL_NOT_EXIST);
    }

    OrderDTO orderDTO = new OrderDTO();
    BeanUtils.copyProperties(orderMaster, orderDTO);
    orderDTO.setOrderDetailList(orderDetailList);

    return orderDTO;
}
 
开发者ID:ldlood,项目名称:SpringBoot_Wechat_Sell,代码行数:20,代码来源:OrderServiceImpl.java

示例11: assignAppRoleToUser

import org.springframework.util.CollectionUtils; //导入依赖的package包/类
@PreAuthorize(value = "@permissionValidator.hasAssignRolePermission(#appId)")
@RequestMapping(value = "/apps/{appId}/roles/{roleType}", method = RequestMethod.POST)
public ResponseEntity<Void> assignAppRoleToUser(@PathVariable String appId, @PathVariable String roleType,
                                                @RequestBody String user) {
  checkUserExists(user);
  RequestPrecondition.checkArgumentsNotEmpty(user);

  if (!RoleType.isValidRoleType(roleType)) {
    throw new BadRequestException("role type is illegal");
  }
  Set<String> assignedUsers = rolePermissionService.assignRoleToUsers(RoleUtils.buildAppRoleName(appId, roleType),
      Sets.newHashSet(user), userInfoHolder.getUser().getUserId());
  if (CollectionUtils.isEmpty(assignedUsers)) {
    throw new BadRequestException(user + "已授权");
  }

  return ResponseEntity.ok().build();
}
 
开发者ID:dewey-its,项目名称:apollo-custom,代码行数:19,代码来源:PermissionController.java

示例12: list

import org.springframework.util.CollectionUtils; //导入依赖的package包/类
@RequestMapping("/list")
@ResponseBody
public String list(@ModelAttribute RefundOrder refundOrder, Integer pageIndex, Integer pageSize) {
    PageModel pageModel = new PageModel();
    int count = refundOrderService.count(refundOrder);
    if(count <= 0) return JSON.toJSONString(pageModel);
    List<RefundOrder> refundOrderList = refundOrderService.getRefundOrderList((pageIndex-1)*pageSize, pageSize, refundOrder);
    if(!CollectionUtils.isEmpty(refundOrderList)) {
        JSONArray array = new JSONArray();
        for(RefundOrder po : refundOrderList) {
            JSONObject object = (JSONObject) JSONObject.toJSON(po);
            if(po.getCreateTime() != null) object.put("createTime", DateUtil.date2Str(po.getCreateTime()));
            if(po.getRefundAmount() != null) object.put("amount", AmountUtil.convertCent2Dollar(po.getRefundAmount()+""));
            array.add(object);
        }
        pageModel.setList(array);
    }
    pageModel.setCount(count);
    pageModel.setMsg("ok");
    pageModel.setRel(true);
    return JSON.toJSONString(pageModel);
}
 
开发者ID:jmdhappy,项目名称:xxpay-master,代码行数:23,代码来源:RefundOrderController.java

示例13: getFileContents

import org.springframework.util.CollectionUtils; //导入依赖的package包/类
/**
 * Get File Contents
 * 
 * @param fileContent
 * @return File Contents
 */
public FileContents getFileContents(final List<String> fileContent) {
    FileContents fileContents = new FileContents();

    /* Set Header */
    fileContents.setHeader(new ArrayList<>(Arrays.asList(fileContent
            .remove(0).split(Constants.DEFAULT_FILE_DELIMITER))));

    /* Set Data */
    List<FileRecord> fileData = new ArrayList<>();
    while (!CollectionUtils.isEmpty(fileContent)) {
        fileData.add(new FileRecord(
                new ArrayList<>(Arrays.asList(fileContent.remove(0)
                        .split(Constants.DEFAULT_FILE_DELIMITER)))));
    }
    fileContents.setData(fileData);

    /* Return File Contents */
    return fileContents;
}
 
开发者ID:ukubuka,项目名称:ukubuka-core,代码行数:26,代码来源:UkubukaBaseParser.java

示例14: scanGrayReleaseRules

import org.springframework.util.CollectionUtils; //导入依赖的package包/类
private void scanGrayReleaseRules() {
  long maxIdScanned = 0;
  boolean hasMore = true;

  while (hasMore && !Thread.currentThread().isInterrupted()) {
    List<GrayReleaseRule> grayReleaseRules = grayReleaseRuleRepository
        .findFirst500ByIdGreaterThanOrderByIdAsc(maxIdScanned);
    if (CollectionUtils.isEmpty(grayReleaseRules)) {
      break;
    }
    mergeGrayReleaseRules(grayReleaseRules);
    int rulesScanned = grayReleaseRules.size();
    maxIdScanned = grayReleaseRules.get(rulesScanned - 1).getId();
    //batch is 500
    hasMore = rulesScanned == 500;
  }
}
 
开发者ID:dewey-its,项目名称:apollo-custom,代码行数:18,代码来源:GrayReleaseRulesHolder.java

示例15: list

import org.springframework.util.CollectionUtils; //导入依赖的package包/类
@RequestMapping("/list")
@ResponseBody
public String list(@ModelAttribute TransOrder transOrder, Integer pageIndex, Integer pageSize) {
    PageModel pageModel = new PageModel();
    int count = transOrderService.count(transOrder);
    if(count <= 0) return JSON.toJSONString(pageModel);
    List<TransOrder> transOrderList = transOrderService.getTransOrderList((pageIndex-1)*pageSize, pageSize, transOrder);
    if(!CollectionUtils.isEmpty(transOrderList)) {
        JSONArray array = new JSONArray();
        for(TransOrder po : transOrderList) {
            JSONObject object = (JSONObject) JSONObject.toJSON(po);
            if(po.getCreateTime() != null) object.put("createTime", DateUtil.date2Str(po.getCreateTime()));
            if(po.getAmount() != null) object.put("amount", AmountUtil.convertCent2Dollar(po.getAmount()+""));
            array.add(object);
        }
        pageModel.setList(array);
    }
    pageModel.setCount(count);
    pageModel.setMsg("ok");
    pageModel.setRel(true);
    return JSON.toJSONString(pageModel);
}
 
开发者ID:jmdhappy,项目名称:xxpay-master,代码行数:23,代码来源:TransOrderController.java


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