merges a Reflections instance metadata into this instance
434452
public Reflections merge(final Reflections reflections) {
        if (reflections.store != null) {
            for (String indexName : reflections.store.keySet()) {
                Multimap<String, String> index = reflections.store.get(indexName);
                for (String key : index.keySet()) {
                    for (String string : index.get(key)) {
                        store.getOrCreate(indexName).put(key, string);
                    }
                }
            }
        }
        return this;
    }
607881
def merge(obj_a, obj_b, strategy='smart', renderer='yaml', merge_lists=False):
    '''
    
    '''
    return salt.utils.dictupdate.merge(obj_a, obj_b, strategy, renderer,
            merge_lists)
354846
def merge_metas(*metas):
    
    metadict = {}
    for meta in metas:
        metadict.update(meta.__dict__)

    metadict = {k: v for k, v in metadict.items() if not k.startswith('__')}
    return type('Meta', (object, ), metadict)
1068255
public void mergeWithDefaults(GlobalMetadata defaults) {
    List<String> defaultTransferEncoding = defaults.getTransferEncoding();
    List<String> myEncoding = getTransferEncoding();

    if (defaultTransferEncoding != null) {
      if (myEncoding == null) {
        setDatasetMetadata(TRANSFER_ENCODING_KEY, defaultTransferEncoding);
      } else {
        List<String> combinedEncoding = new ArrayList<>();
        combinedEncoding.addAll(myEncoding);
        combinedEncoding.addAll(defaultTransferEncoding);

        setDatasetMetadata(TRANSFER_ENCODING_KEY, combinedEncoding);
      }
    }

    for (Map.Entry<String, Object> entry : defaults.datasetLevel.entrySet()) {
      if (!datasetLevel.containsKey(entry.getKey())) {
        setDatasetMetadata(entry.getKey(), entry.getValue());
      }
    }
  }
1195458
public void merge(Metadata other) {
    if (other.isEmpty()) {
      return;
    }
    int remaining = cap() - len();
    if (isEmpty() || remaining < other.len()) {
      expand(len() + other.len());
    }
    System.arraycopy(other.namesAndValues, 0, namesAndValues, len(), other.len());
    size += other.size;
  }
719529
@Nullable
  public static Metadata merge(
      @Nullable List<Metadata> toBeMerged,
      @Nullable AggregatorFactory[] overrideMergedAggregators
  )
  {
    if (toBeMerged == null || toBeMerged.size() == 0) {
      return null;
    }

    boolean foundSomeMetadata = false;
    Map<String, Object> mergedContainer = new HashMap<>();
    List<AggregatorFactory[]> aggregatorsToMerge = overrideMergedAggregators == null
                                                   ? new ArrayList<>()
                                                   : null;

    List<TimestampSpec> timestampSpecsToMerge = new ArrayList<>();
    List<Granularity> gransToMerge = new ArrayList<>();
    List<Boolean> rollupToMerge = new ArrayList<>();

    for (Metadata metadata : toBeMerged) {
      if (metadata != null) {
        foundSomeMetadata = true;
        if (aggregatorsToMerge != null) {
          aggregatorsToMerge.add(metadata.getAggregators());
        }

        if (timestampSpecsToMerge != null && metadata.getTimestampSpec() != null) {
          timestampSpecsToMerge.add(metadata.getTimestampSpec());
        }

        if (gransToMerge != null) {
          gransToMerge.add(metadata.getQueryGranularity());
        }

        if (rollupToMerge != null) {
          rollupToMerge.add(metadata.isRollup());
        }
        mergedContainer.putAll(metadata.container);
      } else {
        //if metadata and hence aggregators and queryGranularity for some segment being merged are unknown then
        //final merged segment should not have same in metadata
        aggregatorsToMerge = null;
        timestampSpecsToMerge = null;
        gransToMerge = null;
        rollupToMerge = null;
      }
    }

    if (!foundSomeMetadata) {
      return null;
    }

    final AggregatorFactory[] mergedAggregators = aggregatorsToMerge == null ?
                                                  overrideMergedAggregators :
                                                  AggregatorFactory.mergeAggregators(aggregatorsToMerge);

    final TimestampSpec mergedTimestampSpec = timestampSpecsToMerge == null ?
                                              null :
                                              TimestampSpec.mergeTimestampSpec(timestampSpecsToMerge);

    final Granularity mergedGranularity = gransToMerge == null ?
                                          null :
                                          Granularity.mergeGranularities(gransToMerge);

    Boolean rollup = null;
    if (rollupToMerge != null && !rollupToMerge.isEmpty()) {
      rollup = rollupToMerge.get(0);
      for (Boolean r : rollupToMerge) {
        if (r == null) {
          rollup = null;
          break;
        } else if (!r.equals(rollup)) {
          rollup = null;
          break;
        } else {
          rollup = r;
        }
      }
    }

    return new Metadata(
        mergedContainer,
        mergedAggregators,
        mergedTimestampSpec,
        mergedGranularity,
        rollup
    );
  }
222463
function merge(defaultObject, objectToMerge) {
		var key;
		if (!objectToMerge) {
			return defaultObject;
		}

		for (key in objectToMerge) {
			defaultObject[key] = objectToMerge[key];
		}

		return defaultObject;
	}
982381
def merge(self, other):
        
        if not isinstance(other, NameVariants):
            raise TypeError("NameVariants isinstance can be merge with"
                            "other isinstance of the same class")
        for key in self.variants:
            self.variants[key] = self.variants[key] or other.variants[key]

        return self
16184
@Override
    public void merge(WebServiceRef webServiceRef, Class<?> instanceClass, Member member) throws InjectionException {

        mergeWSRInfo(webServiceRef, instanceClass, member);

        // The former value should override the later one, i.e. the settings in DD should override the ones in annotation,
        // but we prefer the subclass.
        Class<?> annoType = webServiceRef.type();
        if (!annoType.getName().equals(Object.class.getName())) {
            Class<?> existingType = loadClass(wsrInfo.getServiceRefTypeClassName());

            if (!existingType.getName().equals(Object.class.getName())) {
                //prefer the subclass
                if (existingType.isAssignableFrom(annoType)) {
                    wsrInfo.setServiceRefTypeClassName(annoType.getName());
                } else if (annoType.isAssignableFrom(existingType)) {
                    wsrInfo.setServiceRefTypeClassName(existingType.getName());
                } else { // conflict
                    String msgKey;
                    Object[] inserts;
                    if (member != null) {
                        msgKey = "error.service.ref.type.mismatch.for.member";
                        inserts = new Object[] { wsrInfo.getJndiName(), member.getName(), member.getDeclaringClass().getName(),
                                                annoType.getName(), existingType.getName() };
                    } else {
                        msgKey = "error.service.ref.type.mismatch.for.class";
                        inserts = new Object[] { wsrInfo.getJndiName(), annoType.getName(), existingType.getName() };
                    }
                    Tr.error(tc, msgKey, inserts);
                    throw new InjectionException(Tr.formatMessage(tc, msgKey, inserts));
                }
            } else {
                wsrInfo.setServiceRefTypeClassName(annoType.getName());
            }
        }

        Class<?> annoValue = webServiceRef.value();
        if (!annoValue.getName().equals(Service.class.getName())) {
            Class<?> existingValue = loadClass(wsrInfo.getServiceInterfaceClassName());

            if (!existingValue.getName().equals(Service.class.getName())) {
                //prefer the subclass
                if (existingValue.isAssignableFrom(annoValue)) {
                    wsrInfo.setServiceInterfaceClassName(annoValue.getName());
                } else if (annoValue.isAssignableFrom(existingValue)) {
                    wsrInfo.setServiceInterfaceClassName(existingValue.getName());
                } else { // conflict
                    String msgKey;
                    Object[] inserts;
                    if (member != null) {
                        msgKey = "error.service.interface.mismatch.for.member";
                        inserts = new Object[] { wsrInfo.getJndiName(), member.getName(), member.getDeclaringClass().getName(), annoValue.getName(),
                                                existingValue.getName() };
                    } else {
                        msgKey = "error.service.interface.mismatch.for.class";
                        inserts = new Object[] { wsrInfo.getJndiName(), annoValue.getName(), existingValue.getName() };
                    }
                    Tr.error(tc, msgKey, inserts);
                    throw new InjectionException(Tr.formatMessage(tc, msgKey, inserts));
                }
            } else {
                wsrInfo.setServiceInterfaceClassName(annoValue.getName());
            }
        }

        // Validate and set value and type
        if (member == null) {
            validateAndSetClassLevelWebServiceRef(instanceClass);
        } else {
            // If the wsrInfo service ref type hasn't been set, the infer it from the member.
            validateAndSetMemberLevelWebServiceRef(member);
        }

        // now check the WSDL locations
        if (webServiceRef.wsdlLocation() != null && !webServiceRef.wsdlLocation().isEmpty()) {
            processExistingWSDL(webServiceRef.wsdlLocation(), member);
        }

        // now check to see if there was an @HandlerChain annotation on this member
        HandlerChain handlerChainInstance = null;
        if (member == null) {
            handlerChainInstance = instanceClass.getAnnotation(HandlerChain.class);
        } else if (member instanceof Field) {
            Field field = (Field) member;
            handlerChainInstance = field.getAnnotation(HandlerChain.class);
        } else if (member instanceof Method) {
            Method method = (Method) member;
            handlerChainInstance = method.getAnnotation(HandlerChain.class);
        }
        if (handlerChainInstance != null) {
            if (tc.isDebugEnabled()) {
                Tr.debug(tc, "@HandlerChain annotation found with @WebServiceRef annotation, jndiName: " + webServiceRef.name());
            }
            wsrInfo.setHandlerChainDeclaringClassName(instanceClass.getName());
            wsrInfo.setHandlerChainAnnotation(handlerChainInstance);
        }

    }
700506
def merge_model_instances(self, primary_object, alias_objects):
        
        generic_fields = get_generic_fields()

        # get related fields
        related_fields = list(filter(
            lambda x: x.is_relation is True,
            primary_object._meta.get_fields()))

        many_to_many_fields = list(filter(
            lambda x: x.many_to_many is True, related_fields))

        related_fields = list(filter(
            lambda x: x.many_to_many is False, related_fields))

        # Loop through all alias objects and migrate their references to the
        # primary object
        deleted_objects = []
        deleted_objects_count = 0
        for alias_object in alias_objects:
            # Migrate all foreign key references from alias object to primary
            # object.
            for many_to_many_field in many_to_many_fields:
                alias_varname = many_to_many_field.name
                related_objects = getattr(alias_object, alias_varname)
                for obj in related_objects.all():
                    try:
                        # Handle regular M2M relationships.
                        getattr(alias_object, alias_varname).remove(obj)
                        getattr(primary_object, alias_varname).add(obj)
                    except AttributeError:
                        # Handle M2M relationships with a 'through' model.
                        # This does not delete the 'through model.
                        # TODO: Allow the user to delete a duplicate 'through' model.
                        through_model = getattr(alias_object, alias_varname).through
                        kwargs = {
                            many_to_many_field.m2m_reverse_field_name(): obj,
                            many_to_many_field.m2m_field_name(): alias_object,
                        }
                        through_model_instances = through_model.objects.filter(**kwargs)
                        for instance in through_model_instances:
                            # Re-attach the through model to the primary_object
                            setattr(
                                instance,
                                many_to_many_field.m2m_field_name(),
                                primary_object)
                            instance.save()
                            # TODO: Here, try to delete duplicate instances that are
                            # disallowed by a unique_together constraint

            for related_field in related_fields:
                if related_field.one_to_many:
                    alias_varname = related_field.get_accessor_name()
                    related_objects = getattr(alias_object, alias_varname)
                    for obj in related_objects.all():
                        field_name = related_field.field.name
                        setattr(obj, field_name, primary_object)
                        obj.save()
                elif related_field.one_to_one or related_field.many_to_one:
                    alias_varname = related_field.name
                    related_object = getattr(alias_object, alias_varname)
                    primary_related_object = getattr(primary_object, alias_varname)
                    if primary_related_object is None:
                        setattr(primary_object, alias_varname, related_object)
                        primary_object.save()
                    elif related_field.one_to_one:
                        self.stdout.write("Deleted {} with id {}\n".format(
                            related_object, related_object.id))
                        related_object.delete()

            for field in generic_fields:
                filter_kwargs = {}
                filter_kwargs[field.fk_field] = alias_object._get_pk_val()
                filter_kwargs[field.ct_field] = field.get_content_type(alias_object)
                related_objects = field.model.objects.filter(**filter_kwargs)
                for generic_related_object in related_objects:
                    setattr(generic_related_object, field.name, primary_object)
                    generic_related_object.save()

            if alias_object.id:
                deleted_objects += [alias_object]
                self.stdout.write("Deleted {} with id {}\n".format(
                    alias_object, alias_object.id))
                alias_object.delete()
                deleted_objects_count += 1

        return primary_object, deleted_objects, deleted_objects_count
370745
function mergeMeta(ctx, newMeta) {
	if (newMeta)
		_.assign(ctx.meta, newMeta);
	return ctx.meta;
}
283357
def merge(base: Dict[Any, Any], extension: Dict[Any, Any]) -> Dict[Any, Any]:
    '''

    '''

    _ = copy.deepcopy(base)

    for key, value in extension.items():
        if isinstance(value, Dict) and key in _:
            _[key] = merge(_[key], value)
        else:
            _[key] = value

    return _
97589
function merge (target, source) {
  source = source || {};
  return Object.keys(source).reduce((targetKey, key) => {
    targetKey[key] = source[key];
    return target;
  }, target);
}
690806
def merge(a, b):
    
    for item in a:
        setattr(b, item[0], item[1])
        b.__metadata__ = b.__metadata__
    return b
162515
public function merge(MetaData $data): void
    {
        foreach ($data->toArray() as $key => $value) {
            $this->set($key, $value);
        }
    }
726269
def _merge_meta_data(cls, first: "HistogramBase", second: "HistogramBase") -> dict:
        
        keys = set(first._meta_data.keys())
        keys = keys.union(set(second._meta_data.keys()))
        return {key:
                (first._meta_data.get(key, None) if first._meta_data.get(key, None) == second._meta_data.get(key, None) else None)
                for key in keys}
779642
public void addMetadata(Metadata meta) {
    for (String k : meta.keySet()) {
      for (TiffObject to : meta.getList(k)) {
        add(k, to, meta.getMetadataObject(k).isDublinCore(), meta.getMetadataObject(k).getPath());
      }
    }
  }