public void applyMultiValue()

in scim-core/src/main/java/org/apache/directory/scim/core/repository/PatchHandlerImpl.java [340:366]


    public <T extends ScimResource> void applyMultiValue(T source, Map<String, Object> sourceAsMap, Schema schema, Attribute attribute, ValuePathExpression valuePathExpression, Object value) {

      String attributeName = attribute.getName();
      checkMutability(attribute, sourceAsMap.get(attributeName));

      // apply expression filter
      Collection<Map<String, Object>> items = (Collection<Map<String, Object>>) sourceAsMap.get(attributeName);
      Predicate<Object> pred = FilterExpressions.inMemoryMap(valuePathExpression.getAttributeExpression(), schema);

      Collection<Object> updatedCollection = items.stream()
        .map(item -> {
          // find items that need to be updated
          if (pred.test(item)) {
            String subAttributeName = valuePathExpression.getAttributePath().getSubAttributeName();
            // if there is a sub-attribute set it, otherwise replace the whole item
            if (item.containsKey(subAttributeName)) {
              checkMutability(attribute.getAttribute(subAttributeName), item.get(subAttributeName));
              checkPrimary(subAttributeName, items, value);
              item.put(subAttributeName, value);
            } else {
              item = (Map<String, Object>) value;
            }
          }
          return item;
        }).collect(toList());
      sourceAsMap.put(attribute.getName(), updatedCollection);
    }