本文整理了Java中org.apache.commons.collections4.CollectionUtils.addIgnoreNull()
方法的一些代码示例,展示了CollectionUtils.addIgnoreNull()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CollectionUtils.addIgnoreNull()
方法的具体详情如下:
包路径:org.apache.commons.collections4.CollectionUtils
类名称:CollectionUtils
方法名:addIgnoreNull
[英]Adds an element to the collection unless the element is null.
[中]将元素添加到集合中,除非该元素为null。
代码示例来源:origin: com.sap.cloud.lm.sl/com.sap.cloud.lm.sl.mta
protected static List<Map<String, Object>> getParametersList(List<RequiredDependency> dependencies, Module module,
ModuleType moduleType, DeploymentDescriptor descriptor) {
List<ParametersContainer> containers = new ArrayList<>();
containers.addAll(dependencies);
CollectionUtils.addIgnoreNull(containers, module);
CollectionUtils.addIgnoreNull(containers, moduleType);
CollectionUtils.addIgnoreNull(containers, descriptor);
return PropertiesUtil.getParametersList(containers);
}
代码示例来源:origin: com.sap.cloud.lm.sl/com.sap.cloud.lm.sl.mta
protected static List<Map<String, Object>> getPropertiesList(List<RequiredDependency> dependencies, Module module,
ModuleType moduleType) {
List<PropertiesContainer> containers = new ArrayList<>();
containers.addAll(dependencies);
CollectionUtils.addIgnoreNull(containers, module);
CollectionUtils.addIgnoreNull(containers, moduleType);
return PropertiesUtil.getPropertiesList(containers);
}
代码示例来源:origin: Evolveum/midpoint
@NotNull
@Override
@SuppressWarnings("unchecked")
public <ID extends ItemDefinition> List<ID> findItemDefinitionsByElementName(@NotNull QName elementName,
@NotNull Class<ID> definitionClass) {
List<Definition> matching = new ArrayList<>();
CollectionUtils.addIgnoreNull(matching, itemDefinitionMap.get(elementName));
if (QNameUtil.hasNamespace(elementName)) {
CollectionUtils.addIgnoreNull(matching, itemDefinitionMap.get(QNameUtil.unqualify(elementName)));
} else if (namespace != null) {
CollectionUtils.addIgnoreNull(matching, itemDefinitionMap.get(new QName(namespace, elementName.getLocalPart())));
}
return matching.stream()
.filter(d -> definitionClass.isAssignableFrom(d.getClass()))
.map(d -> (ID) d)
.collect(Collectors.toList());
}
代码示例来源:origin: cloudfoundry-incubator/multiapps-controller
public List<String> getApplicationRoutes(List<Map<String, Object>> parametersList) {
String route = routeParameterName != null ? (String) PropertiesUtil.getPropertyValue(parametersList, routeParameterName, null)
: null;
List<Map<String, Object>> routes = routesParameterName != null
? (List<Map<String, Object>>) PropertiesUtil.getPropertyValue(parametersList, routesParameterName, Collections.emptyList())
: null;
List<String> allRoutesFound = new ArrayList<>();
CollectionUtils.addIgnoreNull(allRoutesFound, route);
CollectionUtils.emptyIfNull(routes)
.forEach(routesMap -> CollectionUtils.addIgnoreNull(allRoutesFound, (String) routesMap.get(routeParameterName)));
return allRoutesFound;
}
代码示例来源:origin: Evolveum/midpoint
public static List<PolicyActionType> getAllActions(PolicyActionsType actions) {
List<PolicyActionType> rv = new ArrayList<>();
if (actions == null) {
return rv;
}
addIgnoreNull(rv, actions.getEnforcement());
rv.addAll(actions.getApproval());
addIgnoreNull(rv, actions.getRecord());
rv.addAll(actions.getNotification());
rv.addAll(actions.getScriptExecution());
addIgnoreNull(rv, actions.getCertification());
addIgnoreNull(rv, actions.getPrune());
addIgnoreNull(rv, actions.getRemediation());
addIgnoreNull(rv, actions.getSuspendTask());
return rv;
}
代码示例来源:origin: cloudfoundry-incubator/multiapps-controller
protected List<ServiceKeyToInject> getServicesKeysToInject(Module module) {
List<ServiceKeyToInject> serviceKeysToInject = new ArrayList<>();
for (RequiredDependency dependency : module.getRequiredDependencies2()) {
ServiceKeyToInject serviceKey = getServiceKeyToInject(dependency);
CollectionUtils.addIgnoreNull(serviceKeysToInject, serviceKey);
}
return serviceKeysToInject;
}
代码示例来源:origin: com.sap.cloud.lm.sl/com.sap.cloud.lm.sl.mta
private List<ExtensionDescriptor> build(DeploymentDescriptor deploymentDescriptor,
Map<String, ExtensionDescriptor> extensionDescriptorsPerParent) {
List<ExtensionDescriptor> chain = new ArrayList<>();
Descriptor currentDescriptor = deploymentDescriptor;
while (currentDescriptor != null) {
ExtensionDescriptor nextDescriptor = extensionDescriptorsPerParent.remove(currentDescriptor.getId());
CollectionUtils.addIgnoreNull(chain, nextDescriptor);
currentDescriptor = nextDescriptor;
}
if (!extensionDescriptorsPerParent.isEmpty() && isStrict) {
throw new ContentException(Messages.CANNOT_BUILD_EXTENSION_DESCRIPTOR_CHAIN_BECAUSE_DESCRIPTORS_0_HAVE_AN_UNKNOWN_PARENT,
String.join(",", Descriptor.getIds(extensionDescriptorsPerParent.values())));
}
return chain;
}
代码示例来源:origin: Evolveum/midpoint
private void gatherCandidateShadowsFromAbstractRole(AbstractRoleType thisRole, List<String> candidateShadowsOidList) {
for (ObjectReferenceType linkRef: thisRole.getLinkRef()) {
CollectionUtils.addIgnoreNull(candidateShadowsOidList, linkRef.getOid());
}
}
代码示例来源:origin: cloudfoundry-incubator/multiapps-controller
protected List<ServiceKeyToInject> getServicesKeysToInject(Module module) {
List<ServiceKeyToInject> serviceKeysToInject = new ArrayList<>();
for (RequiredDependency dependency : module.getRequiredDependencies3()) {
ServiceKeyToInject serviceKey = getServiceKeyToInject(dependency);
if (isActiveServiceKey(serviceKey)) {
CollectionUtils.addIgnoreNull(serviceKeysToInject, serviceKey);
}
}
return serviceKeysToInject;
}
代码示例来源:origin: Evolveum/midpoint
public static List<OtherPrivilegesLimitationType> extractLimitations(AssignmentPath assignmentPath) {
List<OtherPrivilegesLimitationType> rv = new ArrayList<>();
for (AssignmentPathSegment segment : assignmentPath.getSegments()) {
CollectionUtils.addIgnoreNull(rv, segment.getAssignment().getLimitOtherPrivileges());
}
return rv;
}
代码示例来源:origin: phenotips/phenotips
/**
* Extracts rejected genes from provided {@code genes} data.
*
* @param genes a {@link PatientData} object containing gene data for the {@link #patient}
* @return a set of rejected {@link VocabularyTerm genes}
*/
private Set<VocabularyTerm> extractRejectedGenes(@Nullable final PatientData<Gene> genes)
{
if (genes == null) {
return Collections.emptySet();
}
final Set<VocabularyTerm> rejected = new HashSet<>();
final Vocabulary hgnc = this.vocabularyManager.getVocabulary(HGNC);
for (final Gene gene : genes) {
if (REJECTED.equals(gene.getStatus()) || REJECTED_CANDIDATE.equals(gene.getStatus())) {
final String geneID = gene.getId();
final VocabularyTerm geneObj = hgnc.getTerm(geneID);
CollectionUtils.addIgnoreNull(rejected, geneObj);
}
}
return rejected;
}
代码示例来源:origin: org.ligoj.plugin/plugin-id
/**
* Convert the import format to the internal format.
*
* @param importEntry
* The raw imported user.
* @return The internal format of the user.
*/
private UserOrg toUserOrg(final UserOrgEditionVo importEntry) {
final UserOrg user = new UserOrg();
importEntry.copy(user);
user.setGroups(new ArrayList<>());
final List<String> mails = new ArrayList<>();
CollectionUtils.addIgnoreNull(mails, importEntry.getMail());
user.setMails(mails);
return user;
}
代码示例来源:origin: cloudfoundry-incubator/multiapps-controller
public List<ConfigurationSubscription> create(DeploymentDescriptor descriptor,
Map<String, ResolvedConfigurationReference> resolvedResources, String spaceId) {
List<String> dependenciesToIgnore = new ArrayList<>(resolvedResources.keySet());
descriptor = getPartialDescriptorReferenceResolver(descriptor, dependenciesToIgnore).resolve();
List<ConfigurationSubscription> result = new ArrayList<>();
for (com.sap.cloud.lm.sl.mta.model.v2.Module module : descriptor.getModules2()) {
for (RequiredDependency dependency : module.getRequiredDependencies2()) {
if (shouldCreateSubscription(dependency)) {
CollectionUtils.addIgnoreNull(result,
createSubscription(spaceId, descriptor.getId(), module, dependency, resolvedResources));
}
}
}
return result;
}
代码示例来源:origin: cloudfoundry-incubator/multiapps-controller
protected List<String> getApplicationServices(Module module, Predicate<ResourceAndResourceType> filterRule) {
List<String> services = new ArrayList<>();
for (RequiredDependency dependency : module.getRequiredDependencies2()) {
ResourceAndResourceType pair = getApplicationService(dependency.getName());
if (pair != null && filterRule.test(pair)) {
CollectionUtils.addIgnoreNull(services, cloudServiceNameMapper.mapServiceName(pair.getResource(), pair.getResourceType()));
}
}
return ListUtil.removeDuplicates(services);
}
代码示例来源:origin: theonedev/onedev
if (fieldName.equals(CodeCommentConstants.FIELD_CREATE_DATE) || fieldName.equals(CodeCommentConstants.FIELD_UPDATE_DATE)) {
suggestions.addAll(SuggestionUtils.suggest(DateUtils.RELAX_DATE_EXAMPLES, unfencedLowerCaseMatchWith, null));
CollectionUtils.addIgnoreNull(suggestions, suggestToFence(terminalExpect, unfencedMatchWith));
} else if (fieldName.equals(CodeCommentConstants.FIELD_PATH)) {
suggestions.addAll(SuggestionUtils.suggestPath(projectModel.getObject(), unfencedLowerCaseMatchWith, ESCAPE_CHARS));
代码示例来源:origin: Evolveum/midpoint
@Override
public void close(OperationResult taskResult, boolean saveState, OperationResult parentResult)
throws ObjectNotFoundException, SchemaException {
List<ItemDelta<?, ?>> deltas = new ArrayList<>();
if (taskResult != null) {
addIgnoreNull(deltas, setResultAndPrepareDelta(taskResult));
addIgnoreNull(deltas, setResultStatusTypeAndPrepareDelta(taskResult.getStatus() != null ? taskResult.getStatus().createStatusType() : null));
}
addIgnoreNull(deltas, setExecutionStatusAndPrepareDelta(TaskExecutionStatus.CLOSED));
addIgnoreNull(deltas, setCompletionTimestampAndPrepareDelta(System.currentTimeMillis()));
Duration cleanupAfterCompletion = taskPrism.asObjectable().getCleanupAfterCompletion();
if (cleanupAfterCompletion != null) {
TriggerType trigger = new TriggerType(getPrismContext())
.timestamp(XmlTypeConverter.fromNow(cleanupAfterCompletion))
.handlerUri(SchemaConstants.COMPLETED_TASK_CLEANUP_TRIGGER_HANDLER_URI);
addIgnoreNull(deltas, addTriggerAndPrepareDelta(
trigger)); // we just ignore any other triggers (they will do nothing if launched too early)
}
if (saveState) {
try {
processModificationsNow(deltas, parentResult);
} catch (ObjectAlreadyExistsException e) {
throw new SystemException(e);
}
} else {
pendingModifications.addAll(deltas);
}
}
代码示例来源:origin: Evolveum/midpoint
public static void triggerRule(@NotNull EvaluatedPolicyRule rule, Collection<EvaluatedPolicyRuleTrigger<?>> triggers,
Collection<String> policySituations) {
LOGGER.debug("Policy rule {} triggered: {}", rule.getName(), triggers);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Policy rule {} triggered:\n{}", rule.getName(), DebugUtil.debugDump(triggers, 1));
}
((EvaluatedPolicyRuleImpl) rule).addTriggers(triggers);
CollectionUtils.addIgnoreNull(policySituations, rule.getPolicySituation());
}
代码示例来源:origin: Evolveum/midpoint
private List<ObjectReferenceType> getAssignees(AbstractRoleType role, RelationKindType relationKind, OperationResult result)
throws SchemaException {
List<ObjectReferenceType> rv = new ArrayList<>();
if (relationKind == RelationKindType.OWNER) {
CollectionUtils.addIgnoreNull(rv, role.getOwnerRef());
} else if (relationKind == RelationKindType.APPROVER) {
rv.addAll(role.getApproverRef());
} else {
throw new AssertionError(relationKind);
}
// TODO in theory, we could look for approvers/owners of UserType, right?
Collection<PrismReferenceValue> values = new ArrayList<>();
for (QName relation : relationRegistry.getAllRelationsFor(relationKind)) {
PrismReferenceValue ref = prismContext.itemFactory().createReferenceValue(role.getOid());
ref.setRelation(relation);
values.add(ref);
}
ObjectQuery query = prismContext.queryFor(FocusType.class)
.item(FocusType.F_ROLE_MEMBERSHIP_REF).ref(values)
.build();
List<PrismObject<FocusType>> assignees = repositoryService.searchObjects(FocusType.class, query, null, result);
LOGGER.trace("Looking for '{}' of {} using {}: found: {}", relationKind, role, query, assignees);
assignees.forEach(o -> rv.add(ObjectTypeUtil.createObjectRef(o, prismContext)));
return rv;
}
代码示例来源:origin: Evolveum/midpoint
private <T extends ObjectType> List<ObjectDelta<T>> extractDeltasToApprove(ObjectDelta<T> focusDelta, WfProcessSpecificationType processSpecification)
throws SchemaException {
List<ObjectDelta<T>> rv = new ArrayList<>();
if (focusDelta.isDelete() || processSpecification == null || processSpecification.getDeltaFrom().isEmpty()) {
return takeWholeDelta(focusDelta, rv);
}
for (DeltaSourceSpecificationType sourceSpec : processSpecification.getDeltaFrom()) {
if (sourceSpec == null || sourceSpec.getItem().isEmpty() && sourceSpec.getItemValue() == null) {
return takeWholeDelta(focusDelta, rv);
} else if (!sourceSpec.getItem().isEmpty()) {
ObjectDelta.FactorOutResultSingle<T> out = focusDelta.factorOut(ItemPathType.toItemPathList(sourceSpec.getItem()), false);
addIgnoreNull(rv, out.offspring);
} else {
assert sourceSpec.getItemValue() != null;
ObjectDelta.FactorOutResultMulti<T> out = focusDelta.factorOutValues(prismContext.toUniformPath(sourceSpec.getItemValue()), false);
rv.addAll(out.offsprings);
}
}
return rv;
}
代码示例来源:origin: Evolveum/midpoint
private List<AccessCertificationResponseType> getOutcomesFromCompletedStages(AccessCertificationCaseType aCase,
Integer additionalStageNumber, AccessCertificationResponseType additionalStageResponse) {
LOGGER.trace("getOutcomesFromCompletedStages: additionalStageNumber={}, additionalStageResponse={}", additionalStageNumber, additionalStageResponse);
SetValuedMap<Integer, AccessCertificationResponseType> allOutcomes = new HashSetValuedHashMap<>();
for (CaseEventType event : aCase.getEvent()) {
if (event instanceof StageCompletionEventType) {
StageCompletionEventType stageCompletionEvent = (StageCompletionEventType) event;
if (event.getStageNumber() == null) {
throw new IllegalStateException("Missing stage number in StageCompletionEventType: " + event);
}
allOutcomes.put(event.getStageNumber(), normalizeToNonNull(fromUri(stageCompletionEvent.getOutcome())));
}
}
if (additionalStageNumber != null) {
allOutcomes.put(additionalStageNumber, normalizeToNonNull(additionalStageResponse));
}
List<AccessCertificationResponseType> rv = new ArrayList<>();
for (Integer stage : allOutcomes.keySet()) {
Set<AccessCertificationResponseType> stageOutcomes = allOutcomes.get(stage);
addIgnoreNull(rv, extractStageOutcome(stageOutcomes, aCase.getId(), stage));
}
return rv;
}
内容来源于网络,如有侵权,请联系作者删除!