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


Java ListUtils类代码示例

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


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

示例1: extractTaskResultsAndMergeIntoMap

import org.apache.commons.collections4.ListUtils; //导入依赖的package包/类
private Map<String, byte[]> extractTaskResultsAndMergeIntoMap(SchedulerDBManager dbManager,
        EligibleTaskDescriptor eligibleTaskDescriptor, InternalJob job) {
    Map<String, byte[]> mergedVariables = new HashMap<>();

    int numberOfParentTasks = eligibleTaskDescriptor.getParents().size();
    List<TaskId> parentIds = new ArrayList<>(numberOfParentTasks);
    for (int i = 0; i < numberOfParentTasks; i++) {
        parentIds.add(eligibleTaskDescriptor.getParents().get(i).getTaskId());
    }

    // Batch fetching of parent tasks results
    Map<TaskId, TaskResult> taskResults = new HashMap<>();
    for (List<TaskId> parentsSubList : ListUtils.partition(new ArrayList<>(parentIds),
                                                           PASchedulerProperties.SCHEDULER_DB_FETCH_TASK_RESULTS_BATCH_SIZE.getValueAsInt())) {
        taskResults.putAll(dbManager.loadTasksResults(job.getId(), parentsSubList));
    }

    for (TaskResult taskResult : taskResults.values()) {
        if (taskResult.getPropagatedVariables() != null) {
            mergedVariables.putAll(taskResult.getPropagatedVariables());
        }
    }
    return mergedVariables;
}
 
开发者ID:ow2-proactive,项目名称:scheduling,代码行数:25,代码来源:TaskResultCreator.java

示例2: waitForLoggingEvent

import org.apache.commons.collections4.ListUtils; //导入依赖的package包/类
public synchronized void waitForLoggingEvent(long timeout, String... expectedMessages)
        throws InterruptedException {
    List<String> expectedMessagesList = new ArrayList<>(expectedMessages.length);

    Collections.addAll(expectedMessagesList, expectedMessages);

    System.out.println("Waiting for logging events with messages: " + expectedMessagesList + " (" + name + ")");

    long endTime = System.currentTimeMillis() + timeout;
    while (!ListUtils.removeAll(expectedMessagesList, actualMessages).isEmpty()) {
        long waitTime = endTime - System.currentTimeMillis();
        if (waitTime > 0) {
            wait(100);
        } else {
            break;
        }
    }

    Assert.assertTrue("Didn't receive expected events, expected: " + expectedMessagesList + ", actual: " +
                      actualMessages, ListUtils.removeAll(expectedMessagesList, actualMessages).isEmpty());
    actualMessages.clear();
}
 
开发者ID:ow2-proactive,项目名称:scheduling,代码行数:23,代码来源:TestListenJobLogs.java

示例3: execute

import org.apache.commons.collections4.ListUtils; //导入依赖的package包/类
/**
 * Executes the expressions contained within the profile definition.
 * @param expressions A list of expressions to execute.
 * @param transientState Additional transient state provided to the expressions.
 * @param expressionType The type of expression; init, update, result.  Provides additional context if expression execution fails.
 * @return The result of executing each expression.
 */
private List<Object> execute(List<String> expressions, Map<String, Object> transientState, String expressionType) {
  List<Object> results = new ArrayList<>();

  for(String expr: ListUtils.emptyIfNull(expressions)) {
    try {
      // execute an expression
      Object result = executor.execute(expr, transientState, Object.class);
      results.add(result);

    } catch (Throwable e) {

      // in-scope variables = persistent state maintained by the profiler + the transient state
      Set<String> variablesInScope = new HashSet<>();
      variablesInScope.addAll(transientState.keySet());
      variablesInScope.addAll(executor.getState().keySet());

      String msg = format("Bad '%s' expression: error='%s', expr='%s', profile='%s', entity='%s', variables-available='%s'",
              expressionType, e.getMessage(), expr, profileName, entity, variablesInScope);
      LOG.error(msg, e);
      throw new ParseException(msg, e);
    }
  }

  return results;
}
 
开发者ID:apache,项目名称:metron,代码行数:33,代码来源:DefaultProfileBuilder.java

示例4: getResults

import org.apache.commons.collections4.ListUtils; //导入依赖的package包/类
@SuppressWarnings("MethodWithTooManyParameters")
@RequestMapping(value = RESULTS_PATH, method = RequestMethod.GET)
public Documents<R> getResults(
        @RequestParam(STATE_MATCH_PARAM) final List<String> stateMatchIds,
        @RequestParam(value = STATE_DONT_MATCH_PARAM, required = false) final List<String> stateDontMatchIds,
        @RequestParam(value = TEXT_PARAM, required = false, defaultValue = "*") final String text,
        @RequestParam(value = FIELD_TEXT_PARAM, defaultValue = "") final String fieldText,
        @RequestParam(value = RESULTS_START_PARAM, required = false, defaultValue = "1") final int resultsStart,
        @RequestParam(MAX_RESULTS_PARAM) final int maxResults,
        @RequestParam(SUMMARY_PARAM) final String summary,
        @RequestParam(value = SORT_PARAM, required = false) final String sort,
        @RequestParam(value = HIGHLIGHT_PARAM, required = false, defaultValue = "true") final boolean highlight,
        @RequestParam(value = PROMOTIONS, defaultValue = "false") final boolean promotions
) throws E {
    return comparisonService.getResults(
            stateMatchIds,
            ListUtils.emptyIfNull(stateDontMatchIds),
            text,
            fieldText,
            resultsStart,
            maxResults,
            summary,
            sort,
            highlight
    );
}
 
开发者ID:hpe-idol,项目名称:find,代码行数:27,代码来源:ComparisonController.java

示例5: Relationships

import org.apache.commons.collections4.ListUtils; //导入依赖的package包/类
public Relationships(final AnyWrapper<?> modelObject, final PageReference pageRef) {
    super();
    add(new Label("title", new ResourceModel("any.relationships")));

    if (modelObject instanceof UserWrapper
            && UserWrapper.class.cast(modelObject).getPreviousUserTO() != null
            && !ListUtils.isEqualList(
                    UserWrapper.class.cast(modelObject).getInnerObject().getRelationships(),
                    UserWrapper.class.cast(modelObject).getPreviousUserTO().getRelationships())) {
        add(new LabelInfo("changed", StringUtils.EMPTY));
    } else {
        add(new Label("changed", StringUtils.EMPTY));
    }

    this.anyTO = modelObject.getInnerObject();
    this.pageRef = pageRef;

    // ------------------------
    // Existing relationships
    // ------------------------
    add(getViewFragment().setRenderBodyOnly(true));
    // ------------------------ 
}
 
开发者ID:apache,项目名称:syncope,代码行数:24,代码来源:Relationships.java

示例6: CoveragePerContigCollection

import org.apache.commons.collections4.ListUtils; //导入依赖的package包/类
public CoveragePerContigCollection(final LocatableMetadata metadata,
                                   final List<CoveragePerContig> coveragePerContigs,
                                   final List<String> contigs) {
    super(
            metadata,
            coveragePerContigs,
            new TableColumnCollection(ListUtils.union(Collections.singletonList(SAMPLE_NAME_TABLE_COLUMN), contigs)),
            dataLine -> new CoveragePerContig(
                    dataLine.get(SAMPLE_NAME_TABLE_COLUMN),
                    contigs.stream().collect(Collectors.toMap(
                            Function.identity(),
                            dataLine::getInt,
                            (u, v) -> {
                                throw new GATKException.ShouldNeverReachHereException("Cannot have duplicate contigs.");
                            },   //contigs should already be distinct
                            LinkedHashMap::new))),
            (coveragePerContig, dataLine) -> {
                dataLine.append(coveragePerContig.getSampleName());
                contigs.stream().map(coveragePerContig::getCoverage).forEach(dataLine::append);
            });
}
 
开发者ID:broadinstitute,项目名称:gatk,代码行数:22,代码来源:CoveragePerContigCollection.java

示例7: isWriteable

import org.apache.commons.collections4.ListUtils; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public boolean isWriteable(final Class<?> type, final Type genericType, final Annotation[] annotations,
                           final MediaType mediaType) {
    String[] p;
    return !dataViewDisabled
            && -1 != ListUtils.indexOf(requestProvider.get().getAcceptableMediaTypes(),
            this::isSupportMediaType)
            && ((p = TemplateHelper.getProduces(annotations)) == null
            || -1 != ArrayUtils.indexOf(p,
            (Predicate<String>) stringType -> {
                if (stringType.equals(MediaType.WILDCARD)) return true;

                MediaType mediaType1 = MediaType.valueOf(stringType);
                return isSupportMediaType(mediaType1);
            }));
}
 
开发者ID:icode,项目名称:ameba,代码行数:20,代码来源:DataViewMessageBodyWriter.java

示例8: onPostExecute

import org.apache.commons.collections4.ListUtils; //导入依赖的package包/类
@Override
protected void onPostExecute(List<SmbFile> files) {
    try {
        final int cpuCount = Runtime.getRuntime().availableProcessors();
        final int maxPoolSize = cpuCount * 2 + 1;
        final int partitionSize = files.size() < maxPoolSize ? files.size() : (files.size() / maxPoolSize);

        List<List<SmbFile>> subSets = ListUtils.partition(files, partitionSize);

        mNumOfSets = subSets.size();

        for (List<SmbFile> subSet : subSets) {
            if (mIsMovie) {
                new DownloadMovieTask(mContext, mConfig, subSet, this)
                        .executeOnExecutor(THREAD_POOL_EXECUTOR);
            } else {
                new DownloadTvShowTask(mContext, mConfig, subSet, this)
                        .executeOnExecutor(THREAD_POOL_EXECUTOR);
            }
        }
    } catch (Exception e) {
        if (mCallback != null) {
            mCallback.failure();
        }
    }
}
 
开发者ID:jerrellmardis,项目名称:Amphitheatre,代码行数:27,代码来源:GetFilesTask.java

示例9: listToJsonArray

import org.apache.commons.collections4.ListUtils; //导入依赖的package包/类
public static JsonArray listToJsonArray(List<Contribution> contributions) {
  String method = "listToJsonArray";
  logger.entering(clazz, method);

  JsonArrayBuilder contributionsBuilder = Json.createArrayBuilder();
  for (Contribution contribution : ListUtils.emptyIfNull(contributions)) {
    contributionsBuilder.add(contribution.toJson());
  }
  JsonArray contributionsOut = contributionsBuilder.build();

  logger.exiting(clazz, method, contributionsOut);
  return contributionsOut;
}
 
开发者ID:OpenLiberty,项目名称:sample-acmegifts,代码行数:14,代码来源:Occasion.java

示例10: listToDBList

import org.apache.commons.collections4.ListUtils; //导入依赖的package包/类
public static BasicDBList listToDBList(List<Contribution> contributions) {
  String method = "listToString";
  logger.entering(clazz, method);
  BasicDBList dbl = new BasicDBList();
  for (Contribution contribution : ListUtils.emptyIfNull(contributions)) {
    dbl.add(contribution.toDbo());
  }
  logger.exiting(clazz, method);
  return dbl;
}
 
开发者ID:OpenLiberty,项目名称:sample-acmegifts,代码行数:11,代码来源:Occasion.java

示例11: listToString

import org.apache.commons.collections4.ListUtils; //导入依赖的package包/类
public static String listToString(List<Contribution> contributions) {
  String method = "listToString";
  logger.entering(clazz, method);
  StringBuilder sb = new StringBuilder();
  for (Contribution contribution : ListUtils.emptyIfNull(contributions)) {
    sb.append(contribution.toString());
  }
  String str = sb.toString();
  logger.exiting(clazz, method, str);
  return str;
}
 
开发者ID:OpenLiberty,项目名称:sample-acmegifts,代码行数:12,代码来源:Occasion.java

示例12: dbListToList

import org.apache.commons.collections4.ListUtils; //导入依赖的package包/类
public static List<Contribution> dbListToList(BasicDBList dbl) {
  String method = "dbListToList";
  logger.entering(clazz, method, dbl);

  List<Contribution> contributions = new ArrayList<>();
  for (Object dbo : ListUtils.emptyIfNull(dbl)) {
    contributions.add(new Contribution((BasicDBObject) dbo));
  }

  logger.exiting(clazz, method, listToString(contributions));
  return contributions;
}
 
开发者ID:OpenLiberty,项目名称:sample-acmegifts,代码行数:13,代码来源:Occasion.java

示例13: listsEqual

import org.apache.commons.collections4.ListUtils; //导入依赖的package包/类
public static boolean listsEqual(List<Contribution> list1, List<Contribution> list2) {
  for (Contribution p1 : ListUtils.emptyIfNull(list1)) {
    if (!list2.contains(p1)) return false;
  }
  for (Contribution p2 : ListUtils.emptyIfNull(list2)) {
    if (!list1.contains(p2)) return false;
  }
  return true;
}
 
开发者ID:OpenLiberty,项目名称:sample-acmegifts,代码行数:10,代码来源:Occasion.java

示例14: jsonArrayToDbList

import org.apache.commons.collections4.ListUtils; //导入依赖的package包/类
public static BasicDBList jsonArrayToDbList(JsonArray jsonArray) {
  String method = "jsonArrayToDbList";
  logger.entering(clazz, method, jsonArray);

  BasicDBList dbl = new BasicDBList();
  for (JsonValue json : ListUtils.emptyIfNull(jsonArray)) {
    BasicDBObject dbo = new Occasion((JsonObject) json).toDbo();
    dbl.add(dbo);
  }

  logger.exiting(clazz, method, dbl);
  return dbl;
}
 
开发者ID:OpenLiberty,项目名称:sample-acmegifts,代码行数:14,代码来源:Occasion.java

示例15: dboListToJsonArray

import org.apache.commons.collections4.ListUtils; //导入依赖的package包/类
public static JsonArray dboListToJsonArray(List<DBObject> dboList) {
  String method = "dboListToJsonArray";
  logger.entering(clazz, method, dboList);

  JsonArrayBuilder arrayBuilder = Json.createArrayBuilder();
  for (Object dbo : ListUtils.emptyIfNull(dboList)) {
    JsonObject json = new Occasion((DBObject) dbo).toJson();
    arrayBuilder.add(json);
  }
  JsonArray returnArray = arrayBuilder.build();

  logger.exiting(clazz, method, returnArray);
  return returnArray;
}
 
开发者ID:OpenLiberty,项目名称:sample-acmegifts,代码行数:15,代码来源:Occasion.java


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