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


Java CollectionUtils类代码示例

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


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

示例1: findApplicationFromVm

import org.apache.commons.collections4.CollectionUtils; //导入依赖的package包/类
/**
 * Gets the applicationVm's persisted application record.  (Currently require exactly 1.)
 */
private Application findApplicationFromVm(ApplicationVm applicationVm)
{
  List<Application> applications = applicationVm.getApplications();
  if (CollectionUtils.isEmpty(applications))
  {
    throw new IllegalStateException(context(applicationVm.getEnvironment()) + "No application");
  }
  else
  {
    if (applications.size() > 1)
    {
      throw new UnsupportedOperationException(context(applicationVm.getEnvironment())
          + "Currently only support case of 1 application, but applicationVm '"
          + applicationVm.getHostname() + "' has " + applications.size());
    }
    return applications.get(0);
  }
}
 
开发者ID:Nike-Inc,项目名称:bluegreen-manager,代码行数:22,代码来源:TwoEnvLoader.java

示例2: update

import org.apache.commons.collections4.CollectionUtils; //导入依赖的package包/类
@RequestMapping(value = "/update", method = { RequestMethod.POST })
public String update(@ModelAttribute User user) {
   User persistentUser = userService.findByPK(user.getId());
   boolean expireUserSession = !user.isActive() || !CollectionUtils.isEqualCollection(user.getRoles(), persistentUser.getRoles());
   persistentUser.setFirstname(user.getFirstname());
   persistentUser.setLastname(user.getLastname());
   persistentUser.setEmail(user.getEmail());
   persistentUser.setRoles(user.getRoles());
   persistentUser.setActive(user.isActive());
   persistentUser.setPasswordExpired(user.isPasswordExpired());
   userService.update(persistentUser);
   
   if (expireUserSession){
      // expire user session
      sessionService.expireUserSession(persistentUser);
   }else{
      // update user information without expiring her session
      sessionService.updateUserSession(persistentUser);
   }
   
   return "redirect:/administration/user/list?success=true";
}
 
开发者ID:alexander-perucci,项目名称:spring-grow,代码行数:23,代码来源:AdministrationUserController.java

示例3: checkInstanceRemoval

import org.apache.commons.collections4.CollectionUtils; //导入依赖的package包/类
/**
 * Sanity checks the LB description, and checks for done-ness.
 */
private void checkInstanceRemoval(LoadBalancerDescription loadBalancerDescription)
{
  if (!StringUtils.equals(elbName, loadBalancerDescription.getLoadBalancerName()))
  {
    throw new IllegalStateException(logContext + "We requested description of ELB '" + elbName
        + "' but response is for '" + loadBalancerDescription.getLoadBalancerName() + "'");
  }
  if (CollectionUtils.isEmpty(loadBalancerDescription.getInstances()))
  {
    throw new IllegalStateException("ELB '" + elbName + "' has zero instances");
  }
  if (instanceIsGoneFromList(loadBalancerDescription.getInstances()))
  {
    LOGGER.info("ELB '" + elbName + "' list of instances shows '" + ec2InstanceId + "' is gone");
    done = true;
    result = true;
  }
}
 
开发者ID:Nike-Inc,项目名称:bluegreen-manager,代码行数:22,代码来源:ElbInstanceGoneProgressChecker.java

示例4: recursivelyCollectDependenciesPlainSet

import org.apache.commons.collections4.CollectionUtils; //导入依赖的package包/类
@NotNull
protected Set<HybrisModuleDescriptor> recursivelyCollectDependenciesPlainSet(
    @NotNull final HybrisModuleDescriptor descriptor,
    @NotNull final Set<HybrisModuleDescriptor> dependenciesSet
) {
    Validate.notNull(descriptor);
    Validate.notNull(dependenciesSet);

    if (CollectionUtils.isEmpty(descriptor.getDependenciesTree())) {
        return dependenciesSet;
    }

    for (HybrisModuleDescriptor moduleDescriptor : descriptor.getDependenciesTree()) {
        if (dependenciesSet.contains(moduleDescriptor)) {
            continue;
        }

        dependenciesSet.add(moduleDescriptor);
        dependenciesSet.addAll(recursivelyCollectDependenciesPlainSet(moduleDescriptor, dependenciesSet));
    }

    return dependenciesSet;
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:24,代码来源:AbstractHybrisModuleDescriptor.java

示例5: 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

示例6: 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.getVegaCrossBucketConcentration(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,代码来源:VegaMarginAcrossBucketUtils.java

示例7: netSensitivitiesByRiskFactor

import org.apache.commons.collections4.CollectionUtils; //导入依赖的package包/类
/**
 * As defined in Appendix 1 section B.8.a, B.9.a of doc/ISDA_SIMM_vR1.0_(PUBLIC).pdf
 */
public static List<Sensitivity> netSensitivitiesByRiskFactor(RiskClass riskClass, List<Sensitivity> sensitivities) {
  List<Sensitivity> riskFactorList = new ArrayList<>();
  Map<String, BigDecimal> valuesMap = new LinkedHashMap<>();

  if (CollectionUtils.isNotEmpty(sensitivities)) {
    for (Sensitivity sensitivity : sensitivities) {
      String key = sensitivity.getProductClass() + "/" + sensitivity.getRiskType() + "/" + sensitivity.getQualifier() + "/" + sensitivity.getBucket()
        + "/" + sensitivity.getLabel1() + "/" + sensitivity.getLabel2();

      if (valuesMap.containsKey(key)) {
        BigDecimal value = valuesMap.get(key);
        valuesMap.put(key, value.add(sensitivity.getAmountUsd()));
      } else {
        valuesMap.put(key, sensitivity.getAmountUsd());
      }
    }
  }

  for (Entry<String, BigDecimal> valueEntry : valuesMap.entrySet()) {
    riskFactorList.add(new Sensitivity(valueEntry.getKey(), valueEntry.getValue()));
  }

  return riskFactorList;
}
 
开发者ID:AcadiaSoft,项目名称:simm-lib,代码行数:28,代码来源:SensitivityUtils.java

示例8: onPendingStateChanged

import org.apache.commons.collections4.CollectionUtils; //导入依赖的package包/类
private void onPendingStateChanged() {
    if (!isLocalMining && externalMiner == null) return;

    logger.debug("onPendingStateChanged()");
    if (miningBlock == null) {
        restartMining();
    } else if (miningBlock.getNumber() <= ((PendingStateImpl) pendingState).getBestBlock().getNumber()) {
        logger.debug("Restart mining: new best block: " + blockchain.getBestBlock().getShortDescr());
        restartMining();
    } else if (!CollectionUtils.isEqualCollection(miningBlock.getTransactionsList(), getAllPendingTransactions())) {
        logger.debug("Restart mining: pending transactions changed");
        restartMining();
    } else {
        if (logger.isDebugEnabled()) {
            String s = "onPendingStateChanged() event, but pending Txs the same as in currently mining block: ";
            for (Transaction tx : getAllPendingTransactions()) {
                s += "\n    " + tx;
            }
            logger.debug(s);
        }
    }
}
 
开发者ID:talentchain,项目名称:talchain,代码行数:23,代码来源:BlockMiner.java

示例9: syncMee6

import org.apache.commons.collections4.CollectionUtils; //导入依赖的package包/类
@Transactional
@Override
public void syncMee6(Guild guild) throws IOException {
    List<RankingInfo> mee6Infos = mee6Provider.export(guild.getIdLong());
    if (CollectionUtils.isNotEmpty(mee6Infos)) {
        List<LocalMember> members = memberService.syncMembers(guild);
        Map<String, LocalMember> membersMap = members.stream()
                .collect(Collectors.toMap(u -> u.getUser().getUserId(), e -> e));
        for (RankingInfo info : mee6Infos) {
            LocalMember member = membersMap.get(info.getId());
            if (member == null) {
                member = new LocalMember();
                member.setGuildId(guild.getId());
                member.setEffectiveName(info.getNick());

                LocalUser user = userRepository.findByUserId(info.getId());
                if (user == null) {
                    user = new LocalUser();
                    user.setUserId(info.getId());
                }
                if (StringUtils.isNotEmpty(info.getAvatarUrl())) {
                    user.setAvatarUrl(info.getAvatarUrl());
                }
                user.setName(info.getName());
                user.setDiscriminator(info.getDiscriminator());
                member.setUser(user);
                userRepository.save(user);
                memberRepository.save(member);
            }
            Ranking ranking = getRanking(member);
            ranking.setExp(info.getTotalExp());
            rankingRepository.save(ranking);
        }
        sync(guild);
    }
}
 
开发者ID:GoldRenard,项目名称:JuniperBotJ,代码行数:37,代码来源:RankingServiceImpl.java

示例10: findLogicalDatabaseFromEnvironment

import org.apache.commons.collections4.CollectionUtils; //导入依赖的package包/类
/**
 * Gets the env's persisted logicaldb record.  Requires exactly 1.
 */
private LogicalDatabase findLogicalDatabaseFromEnvironment()
{
  List<LogicalDatabase> logicalDatabases = environment.getLogicalDatabases();
  if (CollectionUtils.isEmpty(logicalDatabases))
  {
    throw new IllegalStateException(context() + "No logical databases");
  }
  else if (logicalDatabases.size() > 1)
  {
    throw new UnsupportedOperationException(context() + "Currently only support case of 1 logicalDatabase, but env has "
        + logicalDatabases.size() + ": " + environmentHelper.listOfNames(logicalDatabases));
  }
  else if (StringUtils.isBlank(logicalDatabases.get(0).getLogicalName()))
  {
    throw new IllegalStateException(context() + "Live logical database has blank name");
  }
  return logicalDatabases.get(0);
}
 
开发者ID:Nike-Inc,项目名称:bluegreen-manager,代码行数:22,代码来源:OneEnvLoader.java

示例11: sendInitialMessageToNodes

import org.apache.commons.collections4.CollectionUtils; //导入依赖的package包/类
@Test
public void sendInitialMessageToNodes() {
    List<String> nodes = new ArrayList<>();
    nodes.add("localhost:3306");
    nodes.add("localhost:3307");
    nodes.add("localhost:3306:abd");
    nodes.add("");
    nodes.add(null);

    Node node = new Node(new ECKey().getNodeId(), HOST_1, PORT_1);
    NodeDistanceTable distanceTable = new NodeDistanceTable(KademliaOptions.BINS, KademliaOptions.BUCKET_SIZE, node);
    PeerExplorer peerExplorer = new PeerExplorer(nodes, node, distanceTable, new ECKey(), TIMEOUT, REFRESH);

    UDPChannel channel = new UDPChannel(Mockito.mock(Channel.class), peerExplorer);
    peerExplorer.setUDPChannel(channel);

    Set<String> nodesWithMessage = peerExplorer.startConversationWithNewNodes();

    Assert.assertTrue(CollectionUtils.size(nodesWithMessage) == 2);
    Assert.assertTrue(nodesWithMessage.contains("localhost/127.0.0.1:3307"));
    Assert.assertTrue(nodesWithMessage.contains("localhost/127.0.0.1:3306"));
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:23,代码来源:PeerExplorerTest.java

示例12: addComposited

import org.apache.commons.collections4.CollectionUtils; //导入依赖的package包/类
/**
 * Add an additional Map to the composite.
 *
 * @param map  the Map to be added to the composite
 * @throws IllegalArgumentException if there is a key collision and there is no
 *         MapMutator set to handle it.
 */
@SuppressWarnings("unchecked")
public synchronized void addComposited(final Map<K, V> map) throws IllegalArgumentException {
    for (int i = composite.length - 1; i >= 0; --i) {
        final Collection<K> intersect = CollectionUtils.intersection(this.composite[i].keySet(), map.keySet());
        if (intersect.size() != 0) {
            if (this.mutator == null) {
                throw new IllegalArgumentException("Key collision adding Map to CompositeMap");
            }
            this.mutator.resolveCollision(this, this.composite[i], map, intersect);
        }
    }
    final Map<K, V>[] temp = new Map[this.composite.length + 1];
    System.arraycopy(this.composite, 0, temp, 0, this.composite.length);
    temp[temp.length - 1] = map;
    this.composite = temp;
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:24,代码来源:CompositeMap.java

示例13: getBusinessObjectInstanceDTO

import org.apache.commons.collections4.CollectionUtils; //导入依赖的package包/类
private BusinessObjectInstanceDTO getBusinessObjectInstanceDTO(
    final BusinessObject businessObject) {
  final Long bomId = businessObject.getBomId();

  final List<BusinessObjectFieldInstanceDTO> fields = businessObject.getFields().values().stream()
      .map(field -> new BusinessObjectFieldInstanceDTO(field.getBofmId(), field.getValue()))
      .collect(Collectors.toList());

  final List<BusinessObjectInstanceDTO> children = Lists.newArrayList();
  if (CollectionUtils.isEmpty(businessObject.getChildren().values())) {
    for (final BusinessObject child : businessObject.getChildren().values()) {
      children.add(getBusinessObjectInstanceDTO(child));
    }
  }
  return new BusinessObjectInstanceDTO(bomId, fields, children);
}
 
开发者ID:stefanstaniAIM,项目名称:IPPR2016,代码行数:17,代码来源:ExecuteRefinementTask.java

示例14: createTempStringList

import org.apache.commons.collections4.CollectionUtils; //导入依赖的package包/类
@Transactional(propagation = Propagation.MANDATORY)
public Long createTempStringList(final Long listId, final Collection<String> list) {
    Assert.notNull(listId);
    Assert.isTrue(CollectionUtils.isNotEmpty(list));
    // creates a new local temporary table if it doesn't exists to handle temporary lists
    getJdbcTemplate().update(createTemporaryStringListQuery);
    // fills in a temporary list by given values
    int i = 0;
    final Iterator<String> iterator = list.iterator();
    final MapSqlParameterSource[] batchArgs = new MapSqlParameterSource[list.size()];
    while (iterator.hasNext()) {
        MapSqlParameterSource params = new MapSqlParameterSource();
        params.addValue(HelperParameters.LIST_ID.name(), listId);
        params.addValue(HelperParameters.LIST_VALUE.name(), iterator.next());
        batchArgs[i] = params;
        i++;
    }
    getNamedParameterJdbcTemplate().batchUpdate(insertTemporaryStringListItemQuery, batchArgs);
    return listId;
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:21,代码来源:DaoHelper.java

示例15: findApplicationVmFromEnvironment

import org.apache.commons.collections4.CollectionUtils; //导入依赖的package包/类
/**
 * Gets the env's persisted application vm record.  (Currently support only 1.)
 */
private void findApplicationVmFromEnvironment(boolean createVm)
{
  List<ApplicationVm> applicationVms = environment.getApplicationVms();
  if (CollectionUtils.isEmpty(applicationVms))
  {
    if (!createVm)
    {
      throw new IllegalStateException(context() + "No application vms");
    }
  }
  else if (createVm)
  {
    throw new IllegalStateException("Cannot create applicationVm, since " + applicationVms.size() + " already exist");
  }
  else
  {
    if (applicationVms.size() > 1)
    {
      throw new UnsupportedOperationException(context() + "Currently only support case of 1 applicationVm, but found "
          + applicationVms.size());
    }
    this.applicationVm = applicationVms.get(0);
  }
}
 
开发者ID:Nike-Inc,项目名称:bluegreen-manager,代码行数:28,代码来源:OneEnvLoader.java


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