本文整理汇总了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;
}
示例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();
}
示例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;
}
示例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
);
}
示例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));
// ------------------------
}
示例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);
});
}
示例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);
}));
}
示例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();
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}