protected Sku findMatchingSku(Product product, Map<String, String> attributeValuesForSku) { Sku matchingSku = null; List<Long> possibleSkuIds = new ArrayList<>(); for (Map.Entry<String, String> entry : MapUtils.emptyIfNull(attributeValuesForSku).entrySet()) { possibleSkuIds = productOptionValidationService.findSkuIdsForProductOptionValues(product.getId(), entry.getKey(), entry.getValue(), possibleSkuIds); if (CollectionUtils.isEmpty(possibleSkuIds)) { break; } } if (CollectionUtils.isNotEmpty(possibleSkuIds)) { matchingSku = catalogService.findSkuById(possibleSkuIds.iterator().next()); } return matchingSku; }
protected Sku findMatchingSku(Product product, Map<String, String> attributeValuesForSku) { Sku matchingSku = null; List<Long> possibleSkuIds = new ArrayList<>(); for (Entry<String, String> entry : MapUtils.emptyIfNull(attributeValuesForSku).entrySet()) { possibleSkuIds = productOptionValidationService.findSkuIdsForProductOptionValues(product.getId(), entry.getKey(), entry.getValue(), possibleSkuIds); if (CollectionUtils.isEmpty(possibleSkuIds)) { break; } } if (CollectionUtils.isNotEmpty(possibleSkuIds)) { matchingSku = catalogService.findSkuById(possibleSkuIds.iterator().next()); } return matchingSku; }
Map<String, StructuredContentFieldXref> scFieldXrefs = MapUtils.emptyIfNull(sc.getStructuredContentFieldXrefs());
/** * Executes a set of expressions whose results need to be assigned to a variable. * * @param expressions Maps the name of a variable to the expression whose result should be assigned to it. * @param transientState Additional transient state provided to the expression. * @param expressionType The type of expression; init, update, result. Provides additional context if expression execution fails. */ private void assign(Map<String, String> expressions, Map<String, Object> transientState, String expressionType) { // for each expression... for(Map.Entry<String, String> entry : MapUtils.emptyIfNull(expressions).entrySet()) { String var = entry.getKey(); String expr = entry.getValue(); try { // assign the result of the expression to the variable executor.assign(var, expr, transientState); } 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); } } }
/** * Appends triage values obtained from a {@code ProfileMeasurement} to the * outgoing message. * * @param measurement The measurement that may contain triage values. * @param message The message that the triage values are appended to. */ private void appendTriageValues(ProfileMeasurement measurement, JSONObject message) { // for each triage value... Map<String, Object> triageValues = MapUtils.emptyIfNull(measurement.getTriageValues()); triageValues.forEach((key, value) -> { // append the triage value to the message if(isValidType(value)) { message.put(key, value); } else { LOG.error(String.format( "triage expression must result in primitive type, skipping; type=%s, profile=%s, entity=%s, expr=%s", ClassUtils.getShortClassName(value, "null"), measurement.getDefinition().getProfile(), measurement.getEntity(), key)); } }); }
/** * Utility method to iterate over a map that can be null<br> * for(T element : safe(list)) {} * <br> * <br> * ATTENTION: Use this method for readonly operation only * * @param map The list that may be null. * @param <K> The type of map keys * @param <K> The type of map values * @return The map or an empty map. */ public static <K, V> Map<K, V> safe(Map<K, V> map) { return org.apache.commons.collections4.MapUtils.emptyIfNull(map); }
/** * Set the filter configurations. * * @param filter * the filters. * @param mapping * the mapping used to match JSON properties/path with the ORM path. * @param specifications * the custom specifications. */ DynamicSpecification(final UiFilter filter, final Map<String, String> mapping, final Map<String, CustomSpecification> specifications) { this.filter = filter; this.mapping = MapUtils.emptyIfNull(mapping); this.specifications = MapUtils.emptyIfNull(specifications); }
applyOrder(uiPageRequest, MapUtils.emptyIfNull(mapping), builder, query, root); return pagedResult(entityType, uiPageRequest, query, spec);