@SuppressWarnings("unchecked") protected List<SolrJSONFacet> resolveJSONFacetList(List<NamedList> listOfNamedList) { List<SolrJSONFacet> listOfJSONFacet = new ArrayList<>(); for (NamedList namedList : ListUtils.emptyIfNull(listOfNamedList)) { listOfJSONFacet.add(resolveJSONFacet(namedList)); } return listOfJSONFacet; } }
/** * Removes all values associated with the specified key. * <p> * A subsequent <code>get(Object)</code> would return an empty list. * * @param key the key to remove values from * @return the <code>List</code> of values removed, will return an empty, * unmodifiable list for no mapping found. */ @Override public List<V> remove(final Object key) { return ListUtils.emptyIfNull(getMap().remove(key)); }
/** * Converts a list of structured content items to a list of structured content DTOs.<br> * Internally calls buildStructuredContentDTO(...). * * @param structuredContentList * @param secure * @return * @see {@link #buildStructuredContentDTO(StructuredContent, boolean)} */ @Override public List<StructuredContentDTO> buildStructuredContentDTOList(List<StructuredContent> structuredContentList, boolean secure) { List<StructuredContentDTO> dtoList = new ArrayList<>(); structuredContentList = ListUtils.emptyIfNull(structuredContentList); for (StructuredContent sc : structuredContentList) { dtoList.add(buildStructuredContentDTO(sc, secure)); } return dtoList; }
protected void checkCategoryAncestry(Category category, Set<Category> knownAncestors) { List<CategoryXref> parentXrefs = ListUtils.emptyIfNull(category.getAllParentCategoryXrefs()); knownAncestors.add(category); for (CategoryXref parentXref : parentXrefs) { final Category parentCategory = parentXref.getCategory(); if (!knownAncestors.contains(parentCategory)) { checkCategoryAncestry(parentCategory, knownAncestors); } } }
" events: " + (inEvents != null ? inEvents.size() : -1)); for (TezEvent tezEvent : ListUtils.emptyIfNull(inEvents)) { EventType eventType = tezEvent.getEventType(); switch (eventType) {
@Override public void heartbeat(TezHeartbeatRequest request) { List<TezEvent> inEvents = request.getEvents(); for (TezEvent tezEvent : ListUtils.emptyIfNull(inEvents)) { EventType eventType = tezEvent.getEventType(); try { switch (eventType) { case TASK_ATTEMPT_COMPLETED_EVENT: sendOrQueueEvent(ReaderEvent.doneEvent()); break; case TASK_ATTEMPT_FAILED_EVENT: TaskAttemptFailedEvent taskFailedEvent = (TaskAttemptFailedEvent) tezEvent.getEvent(); sendOrQueueEvent(ReaderEvent.errorEvent(taskFailedEvent.getDiagnostics())); break; case TASK_STATUS_UPDATE_EVENT: // If we want to handle counters break; default: LOG.warn("Unhandled event type " + eventType); break; } } catch (Exception err) { LOG.error("Error during heartbeat responder:", err); } } }
protected void addAllProductOptionsToModel(Map<String, Object> newModelVars, Product product) { List<ProductOptionXref> productOptionXrefs = ListUtils.emptyIfNull(product.getProductOptionXrefs()); List<ProductOptionDTO> dtos = new ArrayList<>(); for (ProductOptionXref optionXref : productOptionXrefs) { ProductOptionDTO dto = new ProductOptionDTO(); ProductOption productOption = optionXref.getProductOption(); dto.setId(productOption.getId()); dto.setType(productOption.getType().getType()); Map<Long, String> values = new HashMap<>(); Map<Long, Double> priceAdjustments = new HashMap<>(); for (ProductOptionValue value : productOption.getAllowedValues()) { values.put(value.getId(), value.getAttributeValue()); Money priceAdjustment = value.getPriceAdjustment(); Double priceAdjustmentValue = (priceAdjustment != null) ? priceAdjustment.doubleValue() : null; priceAdjustments.put(value.getId(), priceAdjustmentValue); } dto.setValues(values); dto.setPriceAdjustments(priceAdjustments); dtos.add(dto); } writeJSONToModel(newModelVars, "allProductOptions", dtos); }
protected Sku findMatchingSku(Product product, Map<String, String> attributeValues, ActivityMessages messages) throws RequiredAttributeNotProvidedException { Map<String, String> attributesRelevantToFindMatchingSku = new HashMap<>(); // Verify that required product-option values were set. if (product != null) { for (ProductOptionXref productOptionXref : ListUtils.emptyIfNull(product.getProductOptionXrefs())) { ProductOption productOption = productOptionXref.getProductOption(); String attributeName = productOption.getAttributeName(); String attributeValue = attributeValues.get(attributeName); boolean isRequired = productOption.getRequired(); boolean hasStrategy = productOptionValidationService.hasProductOptionValidationStrategy(productOption); boolean isAddOrNoneTypes = productOptionValidationService.isAddOrNoneType(productOption); if (shouldValidateWithException(isRequired, isAddOrNoneTypes, attributeValue, hasStrategy)) { productOptionValidationService.validate(productOption, attributeValue); } if (hasStrategy && !isAddOrNoneTypes) { // we need to validate; however, we will not error out productOptionValidationService.validateWithoutException(productOption, attributeValue, messages); } if (productOption.getUseInSkuGeneration()) { attributesRelevantToFindMatchingSku.put(attributeName, attributeValue); } } return findMatchingSku(product, attributesRelevantToFindMatchingSku); } return null; }
protected Sku findMatchingSku(Product product, Map<String, String> attributeValues, ActivityMessages messages) throws RequiredAttributeNotProvidedException { Map<String, String> attributesRelevantToFindMatchingSku = new HashMap<>(); // Verify that required product-option values were set. if (product != null) { for (ProductOptionXref productOptionXref : ListUtils.emptyIfNull(product.getProductOptionXrefs())) { ProductOption productOption = productOptionXref.getProductOption(); String attributeName = productOption.getAttributeName(); String attributeValue = attributeValues.get(attributeName); boolean isRequired = productOption.getRequired(); boolean hasStrategy = productOptionValidationService.hasProductOptionValidationStrategy(productOption); boolean isAddOrNoneTypes = productOptionValidationService.isAddOrNoneType(productOption); if (shouldValidateWithException(isRequired, isAddOrNoneTypes, attributeValue, hasStrategy)) { productOptionValidationService.validate(productOption, attributeValue); } if (hasStrategy && !isAddOrNoneTypes) { // we need to validate; however, we will not error out productOptionValidationService.validateWithoutException(productOption, attributeValue, messages); } if (productOption.getUseInSkuGeneration()) { attributesRelevantToFindMatchingSku.put(attributeName, attributeValue); } } return findMatchingSku(product, attributesRelevantToFindMatchingSku); } return null; }
StructuredContentType scType = sc.getStructuredContentType(); StructuredContentFieldTemplate scFieldTemplate = scType.getStructuredContentFieldTemplate(); List<FieldGroup> scFieldGroups = ListUtils.emptyIfNull(scFieldTemplate.getFieldGroups()); Iterator<FieldGroup> groupIterator = scFieldGroups.iterator();
@Override public PaymentRequestDTO populateCustomerInfo(PaymentRequestDTO requestDTO, Customer customer, String defaultEmailAddress) { String phoneNumber = null; for (CustomerPhone phone : ListUtils.emptyIfNull(customer.getCustomerPhones())) { if (phone.getPhone().isDefault()) { phoneNumber = phone.getPhone().getPhoneNumber(); } } String emailAddress = (customer.getEmailAddress() == null)? defaultEmailAddress : customer.getEmailAddress(); return requestDTO.customer() .customerId(customer.getId().toString()) .firstName(customer.getFirstName()) .lastName(customer.getLastName()) .email(emailAddress) .phone(phoneNumber) .done(); } }
for (ProductOptionXref productOptionXref : ListUtils.emptyIfNull(product.getProductOptionXrefs())) { ProductOption productOption = productOptionXref.getProductOption(); String attributeName = productOption.getAttributeName();
/** * 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; }
@Override public Object apply(List<Object> args, Context context) throws ParseException { SensorEnrichmentConfig config = getSensorEnrichmentConfig(args, 0); ThreatIntelConfig tiConfig = (ThreatIntelConfig) getConfig(config, EnrichmentConfigFunctions.Type.THREAT_INTEL); if(tiConfig == null) { return ""; } org.apache.metron.common.configuration.enrichment.threatintel.ThreatTriageConfig triageConfig = tiConfig.getTriageConfig(); if(triageConfig == null) { return ""; } // print each rule List<RiskLevelRule> triageRules = ListUtils.emptyIfNull(triageConfig.getRiskLevelRules()); String[] headers = new String[] {"Name", "Comment", "Triage Rule", "Score", "Reason"}; String[][] data = new String[triageRules.size()][5]; int i = 0; for(RiskLevelRule rule : triageRules) { String score = rule.getScoreExpression(); String name = Optional.ofNullable(rule.getName()).orElse(""); String comment = Optional.ofNullable(rule.getComment()).orElse(""); String reason = Optional.ofNullable(rule.getReason()).orElse(""); data[i++] = new String[] {name, comment, rule.getRule(), score, reason}; } String ret = FlipTable.of(headers, data); // print the aggregation if(!triageRules.isEmpty()) { ret += "Aggregation: " + triageConfig.getAggregator().name(); } return ret; }
/** * Overwrite all existing tags with new list. * @param tags new tags or null to reset */ public void setTags(List<String> tags) { includeTags = ListUtils.emptyIfNull(tags); }
private RetrieveIndexFieldsResponse(final Builder builder) { fieldTypeCounts = builder.fieldTypeCounts; totalFields = builder.totalFields; fields.put(FieldTypeParam.AutnRank, ListUtils.emptyIfNull(builder.autnRankTypeFields)); fields.put(FieldTypeParam.NumericDate, ListUtils.emptyIfNull(builder.dateTypeFields)); fields.put(FieldTypeParam.Index, ListUtils.emptyIfNull(builder.indexTypeFields)); fields.put(FieldTypeParam.Numeric, ListUtils.emptyIfNull(builder.numericTypeFields)); fields.put(FieldTypeParam.Parametric, ListUtils.emptyIfNull(builder.parametricTypeFields)); fields.put(FieldTypeParam.Reference, ListUtils.emptyIfNull(builder.referenceTypeFields)); fields.put(FieldTypeParam.All, ListUtils.emptyIfNull(builder.storedTypeFields)); }
/** * @param sourceMap a Map containing the list of events and subscribers to iterate over. The supported map keys are * {@code events} and {@code subscribers} * @return the typed instance representing the inputs passed */ public static EventsAndSubscribersSource parse(Map<String, Object> sourceMap) { List<WatchListEvent> events = ListUtils.emptyIfNull((List<WatchListEvent>) sourceMap.get(EVENTS_PARAMETER)); List<DocumentReference> subscribers = ListUtils.emptyIfNull((List<DocumentReference>) sourceMap.get(SUBSCRIBERS_PARAMETER)); return new EventsAndSubscribersSource(events, subscribers); }
@Override protected List<String> getDependencies(Module module) { com.sap.cloud.lm.sl.mta.model.v3.Module moduleV3 = cast(module); return ListUtils.emptyIfNull(moduleV3.getDeployedAfter()); }
private List<ModuleToDeploy> getModulesToDeploy(List<Module> modules) { List<ModuleToDeploy> modulesToDeploy = new ArrayList<ModuleToDeploy>(); for (Module module : modules) { ModuleToDeploy moduleToDeploy = new ModuleToDeploy(module.getName(), module.getType()); if (module instanceof com.sap.cloud.lm.sl.mta.model.v3.Module) { List<String> deployedAfter = emptyIfNull(((com.sap.cloud.lm.sl.mta.model.v3.Module) module).getDeployedAfter()); moduleToDeploy.setDeployedAfter(new HashSet<>(deployedAfter)); } modulesToDeploy.add(moduleToDeploy); } return modulesToDeploy; }
public List<FacetResult> getFacetResult(DiscoverySearchFilterFacet field) { List<DiscoverResult.FacetResult> facetValues = getFacetResult(field.getIndexFieldName()); //Check if we are dealing with a date, sometimes the facet values arrive as dates ! if (facetValues.size() == 0 && field.getType().equals(DiscoveryConfigurationParameters.TYPE_DATE)) { facetValues = getFacetResult(field.getIndexFieldName() + ".year"); } return ListUtils.emptyIfNull(facetValues); }