/*
(non-Javadoc)

@see com.ibm.wsspi.injectionengine.InjectionBinding#merge(java.lang.annotation.Annotation, java.lang.Class, java.lang.reflect.Member)
11172
@Override
    public void merge(@Sensitive MailSessionDefinition annotation, Class<?> instanceClass, Member member) throws InjectionException {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        if (isTraceOn && tc.isEntryEnabled())
            Tr.entry(tc, "merge: name=" + getJndiName() + ", " + super.toStringSecure(annotation));

        if (member != null)
        {
            // MailSessionDefinition is a class-level annotation only.
            throw new IllegalArgumentException(member.toString());
        }

        description = mergeAnnotationValue(description, XMLDescription, annotation.description(), KEY_DESCRIPTION, "");
        user = mergeAnnotationValue(user, XMLUser, annotation.user(), KEY_USER, "");
        if (password != null)
            password = (SerializableProtectedString) mergeAnnotationValue(password.getChars(), XMLPassword, annotation.password().toCharArray(), KEY_PASSWORD, "");
        host = mergeAnnotationValue(host, XMLHost, annotation.host(), KEY_HOST, "");
        from = mergeAnnotationValue(from, XMLFrom, annotation.from(), KEY_FROM, "");
        properties = mergeAnnotationProperties(properties, XMLProperties, annotation.properties());
        storeProtocol = mergeAnnotationValue(storeProtocol, XMLStoreProtocol, annotation.storeProtocol(), KEY_STORE_PROTOCOL, "");
        storeProtocolClassName = mergeAnnotationValue(storeProtocolClassName, XMLStoreProtocolClassName, annotation.storeProtocol(), KEY_STORE_PROTOCOL_CLASS_NAME, "");
        transportProtocol = mergeAnnotationValue(transportProtocol, XMLTransportProtocol, annotation.transportProtocol(), KEY_TRANSPORT_PROTOCOL, "");
        transportProtocolClassName = mergeAnnotationValue(transportProtocolClassName, XMLTransportProtocolClassName, annotation.storeProtocol(), KEY_TRANSPORT_PROTOCOL_CLASS_NAME,
                                                          "");

        if (isTraceOn && tc.isEntryEnabled())
            Tr.exit(tc, "merge");
    }
496734
@SuppressWarnings("unchecked")
    private List<RaConfigProperty> mergeConfigProperties(List<RaConfigProperty> rxConfigProperties, List<RaConfigProperty> annotatedConfigProperties) {
        final boolean trace = TraceComponent.isAnyTracingEnabled();

        LinkedList<RaConfigProperty> configProperties = new LinkedList<RaConfigProperty>();
        List<RaConfigProperty> annoConfigProperties = null;
        if (annotatedConfigProperties != null)
            annoConfigProperties = (List<RaConfigProperty>) ((LinkedList<RaConfigProperty>) annotatedConfigProperties).clone();
        else
            annoConfigProperties = new LinkedList<RaConfigProperty>();

        if (trace && tc.isDebugEnabled())
            Tr.debug(this, tc,
                     "rxConfigProperties size: " + rxConfigProperties.size());

        for (RaConfigProperty rxConfigProp : rxConfigProperties) {
            RaConfigProperty annoConfigProp = null;

            if (annoConfigProperties.isEmpty()) {
                return (List<RaConfigProperty>) ((LinkedList<RaConfigProperty>) rxConfigProperties).clone();
            } else {
                for (RaConfigProperty configProp : annoConfigProperties)
                    if (isEqual(rxConfigProp.getName(), configProp.getName())) {
                        annoConfigProp = configProp;
                        break;
                    }

                if (annoConfigProp != null) {
                    if (trace && tc.isDebugEnabled())
                        Tr.debug(this, tc, "merging " + rxConfigProp + ", " + annoConfigProp);

                    // remove the config property from the list so we know at the end if there
                    // are any additional annotated-only config properties that we need to copy
                    // into the master
                    annoConfigProperties.remove(annoConfigProp);

                    // merge the two config properties
                    if (rxConfigProp.getConfidential() == null)
                        rxConfigProp.setConfidential(annoConfigProp.getConfidential());

                    if (rxConfigProp.getDescription() == null || rxConfigProp.getDescription().isEmpty())
                        rxConfigProp.setDescription(annoConfigProp.getDescription());

                    if (rxConfigProp.getIgnore() == null)
                        rxConfigProp.setIgnore(annoConfigProp.getIgnore());

                    if (rxConfigProp.getSupportsDynamicUpdates() == null)
                        rxConfigProp.setSupportsDynamicUpdates(annoConfigProp.getSupportsDynamicUpdates());

                    if (rxConfigProp.getType() == null || rxConfigProp.getType().equals(""))
                        rxConfigProp.setType(annoConfigProp.getType());

                    if (rxConfigProp.getDefault() == null || rxConfigProp.getDefault().equals(""))
                        rxConfigProp.setDefault(annoConfigProp.getDefault());

                    configProperties.add(rxConfigProp);
                } else {
                    configProperties.add(rxConfigProp);
                }
            }
        }

        if (!annoConfigProperties.isEmpty()) {
            // there are annotated config properties that do not exist already in the ra.xml,
            // thus add them to the master
            for (RaConfigProperty configProp : annoConfigProperties)
                configProperties.add(configProp);
        }

        return configProperties;
    }
491797
@Override
  public void merge(MergeState mergeState) throws IOException {
    final List<Fields> fields = new ArrayList<>();
    final List<ReaderSlice> slices = new ArrayList<>();

    int docBase = 0;

    for (int readerIndex = 0; readerIndex < mergeState.fieldsProducers.length; readerIndex++) {
      final FieldsProducer f = mergeState.fieldsProducers[readerIndex];

      final int maxDoc = mergeState.maxDocs[readerIndex];
      f.checkIntegrity();
      slices.add(new ReaderSlice(docBase, maxDoc, readerIndex));
      fields.add(f);
      docBase += maxDoc;
    }

    Fields mergedFields = new MappedMultiFields(mergeState,
        new MultiFields(fields.toArray(Fields.EMPTY_ARRAY),
            slices.toArray(ReaderSlice.EMPTY_ARRAY)));
    write(mergedFields);
  }
601454
@SuppressWarnings({"unchecked", "rawtypes"})
    @Override
    public C merge(final C other) {
        return (C) ConfigurationUtils.defaultMerge((ConfigurationComponent) this, (ConfigurationComponent) other);
    }
265762
@Override
    public void merge(final Object from, final Object target, final NullHandlingPolicy nullPolicy) {
        if (from == null || target == null) {
            return;
        }

        final BeanWrapper fromWrapper = beanWrapper(from);
        final BeanWrapper targetWrapper = beanWrapper(target);

        final DomainTypeAdministrationConfiguration domainTypeAdministrationConfiguration = configuration.forManagedDomainType(target.getClass());
        final PersistentEntity<?, ?> entity = domainTypeAdministrationConfiguration.getPersistentEntity();

        entity.doWithProperties(new SimplePropertyHandler() {
            @Override
            public void doWithPersistentProperty(PersistentProperty<?> persistentProperty) {
                Object sourceValue = fromWrapper.getPropertyValue(persistentProperty.getName());
                Object targetValue = targetWrapper.getPropertyValue(persistentProperty.getName());

                if (entity.isIdProperty(persistentProperty)) {
                    return;
                }

                if (nullSafeEquals(sourceValue, targetValue)) {
                    return;
                }

                if (propertyIsHiddenInFormView(persistentProperty, domainTypeAdministrationConfiguration)) {
                    return;
                }

                if (nullPolicy == APPLY_NULLS || sourceValue != null) {
                    targetWrapper.setPropertyValue(persistentProperty.getName(), sourceValue);
                }
            }
        });

        entity.doWithAssociations(new SimpleAssociationHandler() {
            @Override
            @SuppressWarnings("unchecked")
            public void doWithAssociation(Association<? extends PersistentProperty<?>> association) {
                PersistentProperty<?> persistentProperty = association.getInverse();

                Object fromValue = fromWrapper.getPropertyValue(persistentProperty.getName());
                Object targetValue = targetWrapper.getPropertyValue(persistentProperty.getName());

                if (propertyIsHiddenInFormView(persistentProperty, domainTypeAdministrationConfiguration)) {
                    return;
                }

                if ((fromValue == null && nullPolicy == APPLY_NULLS)) {
                    targetWrapper.setPropertyValue(persistentProperty.getName(), fromValue);
                }

                if (persistentProperty.isCollectionLike()) {
                    Collection<Object> sourceCollection = (Collection) fromValue;
                    Collection<Object> targetCollection = (Collection) targetValue;

                    Collection<Object> candidatesForAddition = candidatesForAddition(sourceCollection, targetCollection, persistentProperty);
                    Collection<Object> candidatesForRemoval = candidatesForRemoval(sourceCollection, targetCollection, persistentProperty);

                    removeReferencedItems(targetCollection, candidatesForRemoval);

                    addReferencedItems(targetCollection, candidatesForAddition);

                    return;
                }

                if (!nullSafeEquals(fromValue, targetWrapper.getPropertyValue(persistentProperty.getName()))) {
                    targetWrapper.setPropertyValue(persistentProperty.getName(), fromValue);
                }
            }
        });
    }
1104379
private void initMerger() throws IOException
   {
      if (merger == null)
      {
         merger = new IndexMerger(this);
         merger.setMaxMergeDocs(handler.getMaxMergeDocs());
         merger.setMergeFactor(handler.getMergeFactor());
         merger.setMinMergeDocs(handler.getMinMergeDocs());

         for (Object index : indexes)
         {
            merger.indexAdded(((PersistentIndex)index).getName(), ((PersistentIndex)index).getNumDocuments());
         }
         merger.start();
      }
   }
1029849
public void merge(Object obj, PropertyList properties) {
        if (obj == null) {
            throw new IllegalArgumentException(
                    "Object to merge cannot be null");
        }

        for (PropertySpec property : properties) {
            String name = property.getName();
            Object value = property.getValue(obj);

            if (value != null && property.getPropertyList() != null) {
                if (value instanceof Collection) {
                    List colValues = new ArrayList(((Collection) value).size());
                    for (Object o : (Collection) value) {
                        colValues.add(new DynamicObject(o,
                                                        property.getPropertyList()));
                    }
                    value = colValues;
                }
                else {
                    value = new DynamicObject(value,
                                              property.getPropertyList());
                }
            }

            m_properties.put(name, value);
        }
    }
1084319
@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();

            List<Object> destList = toModify.get(sourceKey);
            if (destList == null) {
                destList = new LinkedList<>();
                toModify.put(sourceKey, destList);
            }

            final List<Object> sourceValue = sourceEntry.getValue();
            destList.addAll(sourceValue);
        }

        return toModify;
    }
852906
public void merge(BloomKFilter that)
  {
    if (this != that && this.m == that.m && this.k == that.k) {
      this.bitSet.putAll(that.bitSet);
    } else {
      throw new IllegalArgumentException("BloomKFilters are not compatible for merging." +
                                         " this - " + this + " that - " + that);
    }
  }
751766
public void merge(Object obj) {
        if (obj == null) {
            throw new IllegalArgumentException(
                    "Object to merge cannot be null");
        }

        m_properties.putAll(getPropertyMap(obj));
    }
1149712
public static Map<String, List<Object>> mergeAttributes(final Map<String, List<Object>> currentAttributes, final Map<String, List<Object>> attributesToMerge) {
        val merger = new MultivaluedAttributeMerger();

        val toModify = currentAttributes.entrySet()
            .stream()
            .map(entry -> Pair.of(entry.getKey(), CollectionUtils.toCollection(entry.getValue(), ArrayList.class)))
            .collect(Collectors.toMap(Pair::getKey, Pair::getValue));

        val toMerge = attributesToMerge.entrySet()
            .stream()
            .map(entry -> Pair.of(entry.getKey(), CollectionUtils.toCollection(entry.getValue(), ArrayList.class)))
            .collect(Collectors.toMap(Pair::getKey, Pair::getValue));

        LOGGER.trace("Merging current attributes [{}] with [{}]", toModify, toMerge);
        val results = merger.mergeAttributes((Map) toModify, (Map) toMerge);
        LOGGER.debug("Merged attributes with the final result as [{}]", results);
        return results;
    }
574857
@Override
    public InjectionBinding<ConnectionFactoryDefinition> createInjectionBinding(ConnectionFactoryDefinition annotation, Class<?> instanceClass, Member member, String jndiName) throws InjectionException {
        InjectionBinding<ConnectionFactoryDefinition> injectionBinding =
                        new ConnectionFactoryDefinitionInjectionBinding(jndiName, ivNameSpaceConfig);
        injectionBinding.merge(annotation, instanceClass, null);
        return injectionBinding;
    }
145838
@Sensitive
    @Override
    public InjectionBinding<MailSessionDefinition> createInjectionBinding(@Sensitive MailSessionDefinition annotation, Class<?> instanceClass, Member member, String jndiName) throws InjectionException {
        InjectionBinding<MailSessionDefinition> injectionBinding =
                        new MailSessionDefinitionInjectionBinding(jndiName, ivNameSpaceConfig);
        injectionBinding.merge(annotation, instanceClass, null);
        return injectionBinding;
    }
190663
@Override
	public void merge(MinMaxHolder another){
		Long anotherMin = another.getMaxAsLong();
		if (anotherMin != null){
			evaluate(anotherMin);
		}
		Long anotherMax = another.getMaxAsLong();
		if (anotherMax != null){
			evaluate(anotherMax);
		}
	}
438968
private void mergeProperties(Map<ExecutionConfigSource, Map<ExecutionProperty, List<String>>> sourceToPropertiesMap) {
        for ( ExecutionConfigSource s : propertySources) {
            Map<ExecutionProperty, List<String>> properties = sourceToPropertiesMap.get(s);
            for ( ExecutionProperty p : properties.keySet()) {
                List<String> valuesFromSource = properties.get(p);
                if ( valuesFromSource != null && !valuesFromSource.isEmpty()) {
                    List<String> vals = getOrCreatePropertyValues(p);
                    mergeValues(valuesFromSource, p, vals);
                }
            }
        }
    }
1052312
public void merge(DynamicObject obj) {
        if (obj == null) {
            throw new IllegalArgumentException(
                    "Object to merge cannot be null");
        }

        m_properties.putAll(obj.m_properties);
    }
1331134
private void merge(Integer cid1, Integer cid2) {
    Collection<String> klass1 = classix.get(cid1);
    Collection<String> klass2 = classix.get(cid2);

    // if klass1 is the smaller, swap the two
    if (klass1.size() < klass2.size()) {
      Collection<String> tmp = klass2;
      klass2 = klass1;
      klass1 = tmp;

      Integer itmp = cid2;
      cid2 = cid1;
      cid1 = itmp;
    }

    // now perform the actual merge
    for (String id : klass2) {
      klass1.add(id);
      recordix.put(id, cid1);
    }

    // delete the smaller class, and we're done
    classix.remove(cid2);
  }