/* (non-Javadoc)
@see org.jasig.services.persondir.support.merger.BaseAdditiveAttributeMerger#mergePersonAttributes(java.util.Map, java.util.Map)
176003
@Override
    protected Map<String, List<Object>> mergePersonAttributes(final Map<String, List<Object>> toModify, final Map<String, List<Object>> toConsider) {
        Validate.notNull(toModify, "toModify cannot be null");
        Validate.notNull(toConsider, "toConsider cannot be null");

        toModify.putAll(toConsider);

        return toModify;
    }
735580
public static IAttributeMerger getAttributeMerger(final String mergingPolicy) {
        switch (mergingPolicy.toLowerCase()) {
            case "multivalued":
            case "multi_valued":
            case "combine":
                return new MultivaluedAttributeMerger();
            case "add":
                return new NoncollidingAttributeAdder();
            case "replace":
            case "overwrite":
            case "override":
                return new ReplacingAttributeAdder();
            default:
                return new BaseAdditiveAttributeMerger() {
                    @Override
                    protected Map<String, List<Object>> mergePersonAttributes(final Map<String, List<Object>> toModify,
                                                                              final Map<String, List<Object>> toConsider) {
                        return new LinkedHashMap<>(toModify);
                    }
                };
        }
    }
1299463
@Required
    public final void setPersonAttributeDaos(final List<IPersonAttributeDao> daos) {
        Validate.notNull(daos, "The IPersonAttributeDao List cannot be null");
        this.personAttributeDaos = Collections.unmodifiableList(daos);
    }
1261616
public static <K, V> Map<K, V> updateMap(final Map<K, V> original, MapDifference<K, V> diff) throws MergeException {
        Map<K, V> result = new HashMap<K, V>(original);
        if (diff.areEqual()) {
            return result;
        }
        for (Entry<K, V> entry : diff.entriesOnlyOnLeft().entrySet()) {
            V originalValue = original.get(entry.getKey());
            if (ObjectUtils.equals(originalValue, entry.getValue())) {
                result.remove(entry.getKey());
            }
        }
        for (Entry<K, V> entry : diff.entriesOnlyOnRight().entrySet()) {
            K key = entry.getKey();
            if (original.containsKey(key)) {
                if (ObjectUtils.notEqual(original.get(key), entry.getValue())) {
                    throw new MergeException(String.format(
                        "tried to introduce a new value, but it was already there: %s (%s,%s)",
                        key, original.get(key), entry.getValue()));
                }
            }
            result.put(entry.getKey(), entry.getValue());
        }
        for (Entry<K, ValueDifference<V>> entry : diff.entriesDiffering().entrySet()) {
            K key = entry.getKey();
            V originalValue = original.get(entry.getKey());
            if (ObjectUtils.equals(originalValue, entry.getValue().leftValue())) {
                // Map changed in diff only
                result.put(key, entry.getValue().rightValue());
            } else if (ObjectUtils.equals(originalValue, entry.getValue().rightValue())) {
                // Diff would change value to value already in original Map
                result.put(key, originalValue);
            } else {
                // Merge conflict, got 3 different Values
                String errorMessage =
                    String
                        .format(
                            "Changes could not be applied, because original value differes from left-side of the"
                                    + "MapDifference: %s (%s,%s)", entry.getKey(), original.get(entry.getKey()),
                            entry.getValue());
                throw new MergeException(errorMessage);
            }
        }
        return result;
    }
85598
public void setAttributeDefinitions(java.util.Collection<AttributeDefinition> attributeDefinitions) {
        if (attributeDefinitions == null) {
            this.attributeDefinitions = null;
            return;
        }

        this.attributeDefinitions = new java.util.ArrayList<AttributeDefinition>(attributeDefinitions);
    }
306464
@Override
    public void setAttributes(Map<String, List<String>> attributes) {
        // Tries to modify as many of the existing attributes in place to reduce DB churn in
        // hibernate

        // Make a local copy so we don't edit the original reference
        attributes = new LinkedHashMap<String, List<String>>(attributes);

        for (final Iterator<LocalAccountPersonAttributeImpl> attributesItr =
                        this.attributes.iterator();
                attributesItr.hasNext(); ) {
            final LocalAccountPersonAttributeImpl attribute = attributesItr.next();

            // Remove the new values for the attribute from the input map
            final String name = attribute.getName();
            final List<String> newValues = attributes.remove(name);

            // If no new values remove the attribute
            if (newValues == null) {
                attributesItr.remove();
            }
            // Otherwise update the existing values
            else {
                attribute.setValues(new ArrayList<String>(newValues));
            }
        }

        // Add any remaining new attributes to the list
        for (final Map.Entry<String, List<String>> attribute : attributes.entrySet()) {
            final String name = attribute.getKey();
            final List<String> values = attribute.getValue();
            this.attributes.add(new LocalAccountPersonAttributeImpl(name, values));
        }
    }
944008
@Override
	protected ACC mergeState(ACC a, ACC b) {
		return aggregateTransformation.aggFunction.merge(a, b);
	}
1088447
public static Taint merge(Taint a, Taint b) {
        if (a == null) {
            if (b == null) {
                return null;
            } else {
                return new Taint(b);
            }
        } else if (b == null) {
            return new Taint(a);
        }
        assert a != null && b != null;
        Taint result = new Taint(State.merge(a.getState(), b.getState()));
        if (a.variableIndex == b.variableIndex) {
            result.variableIndex = a.variableIndex;
        }
        result.taintLocations.addAll(a.taintLocations);
        result.taintLocations.addAll(b.taintLocations);
        result.unknownLocations.addAll(a.unknownLocations);
        result.unknownLocations.addAll(b.unknownLocations);
        if (!result.isTainted()) {
           mergeParameters(a, b, result); 
        }
        mergeRealInstanceClass(a, b, result);
        mergeTags(a, b, result);
        if (a.constantValue != null && a.constantValue.equals(b.constantValue)) {
            result.constantValue = a.constantValue;
        }
        if (FindSecBugsGlobalConfig.getInstance().isDebugTaintState()) {
            result.setDebugInfo("[" + a.getDebugInfo() + "]+[" + b.getDebugInfo() + "]");
        }
        assert !result.hasParameters() || result.isUnknown();
        if(a.potentialValue != null) {
            result.potentialValue = a.potentialValue;
        }
        else if(b.potentialValue != null) {
            result.potentialValue = b.potentialValue;
        }
        result.addAllSources(a.sources);
        result.addAllSources(b.sources);
        return result;
    }
343944
protected void merge(Set<Annotation> stereotypeAnnotations) {
        final MetaAnnotationStore store = manager.getServices().get(MetaAnnotationStore.class);
        for (Annotation stereotypeAnnotation : stereotypeAnnotations) {
            // Retrieve and merge all metadata from stereotypes
            StereotypeModel<?> stereotype = store.getStereotype(stereotypeAnnotation.annotationType());
            if (stereotype == null) {
                throw MetadataLogger.LOG.stereotypeNotRegistered(stereotypeAnnotation);
            }
            if (stereotype.isAlternative()) {
                alternative = true;
            }
            if (stereotype.getDefaultScopeType() != null) {
                possibleScopeTypes.add(stereotype.getDefaultScopeType());
            }
            if (stereotype.isBeanNameDefaulted()) {
                beanNameDefaulted = true;
            }
            this.stereotypes.add(stereotypeAnnotation.annotationType());
            // Merge in inherited stereotypes
            merge(stereotype.getInheritedStereotypes());
        }
    }
1343548
public static void addAttributes(final Map<String, Object> attributes, AttributesBuilder attributesBuilder) {
        // TODO Figure out how to reliably set other values (like boolean values, dates, times, etc)
        for (Map.Entry<String, Object> attributeEntry : attributes.entrySet()) {
            addAttribute(attributeEntry.getKey(), attributeEntry.getValue(), attributesBuilder);
        }
    }
421291
public MergeOptions<E> doNotUpdate(Attribute... attributes)
    {
        if (this.doNotUpdate == null)
        {
            this.doNotUpdate = attributes;
        }
        else
        {
            List<Attribute> all = FastList.newListWith(this.doNotUpdate);
            for(Attribute a: attributes) all.add(a);
            this.doNotUpdate = new Attribute[all.size()];
            all.toArray(this.doNotUpdate);
        }
        return this;
    }
632154
@Override
  public PathImpl schemeWalk(String userPath,
                         Map<String,Object> attributes,
                         String filePath,
                         int offset)
  {
    int length = filePath.length();

    if (length <= offset || filePath.charAt(offset) != '(')
      return super.schemeWalk(userPath, attributes, filePath, offset);

    MergePath mergePath = createMergePath();
    mergePath.setUserPath(userPath);

    int head = ++offset;
    int tail = head;
    while (tail < length) {
      int ch = filePath.charAt(tail);

      if (ch == ')') {
        if (head + 1 != tail) {
          String subPath = filePath.substring(head, tail);

          if (subPath.startsWith("(") && subPath.endsWith(")"))
            subPath = subPath.substring(1, subPath.length() - 1);

          mergePath.addMergePath(VfsOld.lookup(subPath));
        }

        if (tail + 1 == length)
          return mergePath;
        else
          return mergePath.fsWalk(userPath, attributes, filePath.substring(tail + 1));
      }
      else if (ch == ';') {
        String subPath = filePath.substring(head, tail);

        if (subPath.startsWith("(") && subPath.endsWith(")"))
          subPath = subPath.substring(1, subPath.length() - 1);

        mergePath.addMergePath(VfsOld.lookup(subPath));

        head = ++tail;
      }
      else if (ch == '(') {
        int depth = 1;

        for (tail++; tail < length; tail++) {
          if (filePath.charAt(tail) == '(')
            depth++;
          else if (filePath.charAt(tail) == ')') {
            tail++;
            depth--;
            if (depth == 0)
              break;
          }
        }

        if (depth != 0)
          return new NotFoundPath(getSchemeMap(), filePath);
      }
      else
        tail++;
    }

    return new NotFoundPath(getSchemeMap(), filePath);
  }
941837
@Override
    protected Map<String, List<Object>> mergePersonAttributes(final Map<String, List<Object>> toModify, final Map<String, List<Object>> toConsider) {
        Validate.notNull(toModify, "toModify cannot be null");
        Validate.notNull(toConsider, "toConsider cannot be null");

        for (final Map.Entry<String, List<Object>> sourceEntry : toConsider.entrySet()) {
            final String sourceKey = sourceEntry.getKey();

            if (!toModify.containsKey(sourceKey)) {
                final List<Object> sourceValue = sourceEntry.getValue();
                toModify.put(sourceKey, sourceValue);
            }
        }

        return toModify;
    }
818256
private void merge(Map<String, NodeT> source, Map<String, NodeT> target) {
        for (Map.Entry<String, NodeT> entry : source.entrySet()) {
            String key = entry.getKey();
            if (!target.containsKey(key)) {
                target.put(key, entry.getValue());
            }
        }
    }
206352
public void merge(Map<String, Object> map) {
        if (map == null) {
            throw new IllegalArgumentException("Map to merge cannot be null");
        }

        m_properties.putAll(map);
    }
993663
@Bean(name = "innerMergedPersonAttributeDaoList")
    public List<IPersonAttributeDao> getInnerMergedPersonAttributeDaoList() {
        final List<IPersonAttributeDao> rslt = new ArrayList<>();
        rslt.add(getImpersonationStatusPersonAttributeDao());
        rslt.add(getUPortalAccountUserSource());
        rslt.add(getUPortalJdbcUserSource());
        return rslt;
    }
29697
public void merge(VersionRows other) {
		conceptRows.addAll(other.conceptRows);
		relationshipRows.addAll(other.relationshipRows);
		concreteDomainRows.addAll(other.getConcreteDomainRows());
                attributeDomainRows.addAll(other.getAttributeDomainRows());
		owlRows.addAll(other.getConcreteDomainRows());
	}