/** * Removes all values associated with the specified key. * <p> * A subsequent <code>get(Object)</code> would return an empty set. * * @param key the key to remove values from * @return the <code>Set</code> of values removed, will return an empty, * unmodifiable set for no mapping found. */ @Override public Set<V> remove(final Object key) { return SetUtils.emptyIfNull(getMap().remove(key)); }
protected List<ItemCriteriaDTO> buildItemCriteriaDTOList(StructuredContent sc) { List<ItemCriteriaDTO> itemCriteriaDTOList = new ArrayList<>(); Set<StructuredContentItemCriteria> qualifyingItemCriteria = SetUtils.emptyIfNull(sc.getQualifyingItemCriteria()); for (StructuredContentItemCriteria criteria : qualifyingItemCriteria) { ItemCriteriaDTO criteriaDTO = entityConfiguration.createEntityInstance(ItemCriteriaDTO.class.getName(), ItemCriteriaDTO.class); criteriaDTO.setMatchRule(criteria.getMatchRule()); criteriaDTO.setQty(criteria.getQuantity()); itemCriteriaDTOList.add(criteriaDTO); } return itemCriteriaDTOList; }
protected void addProductOptionPricingToModel(Map<String, Object> newModelVars, Product product, BroadleafTemplateContext context, Map<String, String> tagAttributes) { List<Sku> skus = product.getSkus(); List<ProductOptionPricingDTO> skuPricing = new ArrayList<>(); for (Sku sku : skus) { List<Long> productOptionValueIds = new ArrayList<Long>(); Set<SkuProductOptionValueXref> productOptionValueXrefs = SetUtils.emptyIfNull(sku.getProductOptionValueXrefs()); for (SkuProductOptionValueXref skuProductOptionValueXref : productOptionValueXrefs) { ProductOptionValue productOptionValue = skuProductOptionValueXref.getProductOptionValue(); productOptionValueIds.add(productOptionValue.getId()); } ProductOptionPricingDTO pricingDto = createPricingDto(sku, productOptionValueIds, tagAttributes, context); skuPricing.add(pricingDto); } writeJSONToModel(newModelVars, "skuPricing", skuPricing); }
/** * Converts a StructuredContent into a StructuredContentDTO. If the item contains fields with * broadleaf cms urls, the urls are converted to utilize the domain. * <p/> * The StructuredContentDTO is built via the {@link EntityConfiguration}. To override the actual type that is returned, * include an override in an applicationContext like any other entity override. * * @param sc * @param secure * @return */ @Override public StructuredContentDTO buildStructuredContentDTO(StructuredContent sc, boolean secure) { StructuredContentDTO scDTO = entityConfiguration.createEntityInstance(StructuredContentDTO.class.getName(), StructuredContentDTO.class); Set<StructuredContentItemCriteria> qualifyingItemCriteria = SetUtils.emptyIfNull(sc.getQualifyingItemCriteria()); scDTO.setContentName(sc.getContentName()); scDTO.setContentType(sc.getStructuredContentType().getName()); scDTO.setId(sc.getId()); scDTO.setPriority(sc.getPriority()); if (sc.getLocale() != null) { scDTO.setLocaleCode(sc.getLocale().getLocaleCode()); } scDTO.setRuleExpression(buildRuleExpression(sc)); buildFieldValues(sc, scDTO, secure); if (qualifyingItemCriteria.size() > 0) { scDTO.setItemCriteriaDTOList(buildItemCriteriaDTOList(sc)); } return scDTO; }
private List<ResolveResult> tryResolveForRelationType(final TSMetaModel meta, final String featureName) { final Optional<List<TSMetaReference>> metaReferences = findHeaderItemTypeName(getElement()) .map(PsiElement::getText) .map(meta::findRelationByName); if (!metaReferences.isPresent()) { return null; } final Set<TSMetaReference> references = new HashSet<>(metaReferences.get()); if (SOURCE_ATTRIBUTE_NAME.equals(featureName)) { return emptyIfNull(references).stream() .map(TSMetaReference::getSource) .map(TSMetaReference.ReferenceEnd::retrieveDom) .filter(Objects::nonNull) .map(RelationElementResolveResult::new) .collect(Collectors.toList()); } if (TARGET_ATTRIBUTE_NAME.equals(featureName)) { return emptyIfNull(references).stream() .map(TSMetaReference::getTarget) .map(TSMetaReference.ReferenceEnd::retrieveDom) .filter(Objects::nonNull) .map(RelationElementResolveResult::new) .collect(Collectors.toList()); } return null; }