protected String toString(int tabs) { StringBuilder sb = new StringBuilder(); if (MapUtils.isNotEmpty(map)) { sb.append("{\n"); for (Map.Entry<String, Object> entry : map.entrySet()) { sb.append(getString(entry.getKey(), entry.getValue(), tabs+1)); } sb.append(StringUtils.repeat(" ", (tabs-1)*2)).append("}"); } return sb.toString(); }
/** * Null-safe check if the specified map is not empty. * <p> * Null returns false. * * @param map the map to check, may be null * @return true if non-null and non-empty * @since 3.2 */ public static boolean isNotEmpty(final Map<?,?> map) { return !MapUtils.isEmpty(map); }
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; }
/** * Retrieve the cache bound to the current thread. * * @return The cache for the current thread, or null if not set */ public static CatalogStructure getCache() { BroadleafRequestContext ctx = BroadleafRequestContext.getBroadleafRequestContext(); Catalog currentCatalog = ctx == null ? null : ctx.getCurrentCatalog(); if (currentCatalog != null) { return MapUtils.getObject(CACHE.get(), currentCatalog.getId()); } else { return MapUtils.getObject(CACHE.get(), DEFAULT_CATALOG_CACHE_KEY); } }
private Capability getOrFailCapability(NodeTemplate nodeTemplate, String capabilityName) { Capability capability = MapUtils.getObject(nodeTemplate.getCapabilities(), capabilityName); if (capability != null) { return capability; } throw new NotFoundException("Capability [" + capabilityName + "] not found in template."); }
@Override public void setApplicationContext(ApplicationContext ctx) throws BeansException { Map<String, Object> serviceBeanMap = ctx.getBeansWithAnnotation(RpcService.class); if (MapUtils.isNotEmpty(serviceBeanMap)) { for (Object serviceBean : serviceBeanMap.values()) { String interfaceName = serviceBean.getClass().getAnnotation(RpcService.class).value().getName(); logger.info("Loading service: {}", interfaceName); handlerMap.put(interfaceName, serviceBean); } } }
void addReading(Map<DataWord, DataWord> entries) { if (MapUtils.isEmpty(entries)) return; for (Map.Entry<DataWord, DataWord> entry : entries.entrySet()) { if (!this.entries.containsKey(entry.getKey())) add(entry, false); } }
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; }
private PropertyDefinition getOrFailCapabilityPropertyDefinition(CapabilityType capabilityType, String propertyName) { PropertyDefinition propertyDefinition = MapUtils.getObject(capabilityType.getProperties(), propertyName); if (propertyDefinition != null) { return propertyDefinition; } throw new NotFoundException("Property [" + propertyName + "] not found in capability type [" + capabilityType.getElementId() + "]"); }
List<FilterAndSortCriteria> result = new ArrayList<>(); if (MapUtils.isNotEmpty(requestParams)) {
void addWriting(Map<DataWord, DataWord> entries) { if (MapUtils.isEmpty(entries)) return; for (Map.Entry<DataWord, DataWord> entry : entries.entrySet()) { add(entry, true); } }
Map<String, StructuredContentFieldXref> scFieldXrefs = MapUtils.emptyIfNull(sc.getStructuredContentFieldXrefs());
private void assertMapContains(Map<String, String> map, Map<String, String> expectedMap) { for (Entry<String, String> entry : expectedMap.entrySet()) { assertEquals(entry.getValue(), MapUtils.getObject(map, entry.getKey())); } }
if (org.apache.commons.collections4.MapUtils.isNotEmpty(clientBeanPostProcessors)) { for (Map.Entry<String, BeanDefinition> entry : clientBeanPostProcessors.entrySet()) { registry.registerBeanDefinition(entry.getKey(), entry.getValue()); if (org.apache.commons.collections4.MapUtils.isNotEmpty(clientAnnotatedBeanPostProcessors)) { for (Map.Entry<String, BeanDefinition> entry : clientAnnotatedBeanPostProcessors.entrySet()) { registry.registerBeanDefinition(entry.getKey(), entry.getValue());
if (shouldRecompress && MapUtils.isEmpty(convertedParameters)) { convertedParameters.put("recompress","true");
/** * 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); } } }
@SuppressWarnings({ "unchecked", "rawtypes" }) private <V extends AbstractInstantiableToscaType> void registerOperationOutput(final List<? extends IPaaSTemplate> paaSTemplates, final String interfaceName, final String operationName, final String output, final String formatedAttributeName) { for (IPaaSTemplate<V> paaSTemplate : paaSTemplates) { if (paaSTemplate.getInterfaces() != null) { Interface interfass = MapUtils.getObject(paaSTemplate.getInterfaces(), (interfaceName)); if (interfass != null && interfass.getOperations().containsKey(operationName)) { OperationOutput toAdd = new OperationOutput(output); if (StringUtils.isNotBlank(formatedAttributeName)) { toAdd.getRelatedAttributes().add(formatedAttributeName); } interfass.getOperations().get(operationName).addOutput(toAdd); } } } }
private static Type createInlineObjectType(Type type, String name, String uniqueName, List<ObjectType> inlineDefinitions) { if (type instanceof ObjectType) { ObjectType objectType = (ObjectType) type; if (isNotEmpty(objectType.getProperties())) { if (objectType.getName() == null) { objectType.setName(name); objectType.setUniqueName(uniqueName); } inlineDefinitions.add(objectType); return new RefType(objectType); } else return type; } else return type; } }
Map<String, String> additionalFields = customerPayment.getAdditionalFields(); if (gatewayType == null || paymentType == null) { if (MapUtils.isEmpty(additionalFields)) { additionalFields = new HashMap<>();
/** * 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)); } }); }