Turns a changeset into a composite write attribute operation.
The keys to the changeset are the java property names of the attributes that have been modified.

@param changeSet values of the java properties that changed
@return composite operation
334775
public ModelNode fromChangeset(Map<String, Object> changeSet, String... wildcards) {

        ClassInfo clazz = null;
        Class<?> currentType = getType();

        while (clazz == null) {
            clazz = index.getClassByName(DotName.createSimple(currentType.getCanonicalName()));

            if (clazz == null) {
                currentType = currentType.getSuperclass();
                if (currentType == null) {
                    throw new RuntimeException("Unable to determine ClassInfo");
                }
            }
        }

        Address addressMeta = currentType.getDeclaredAnnotation(Address.class);
        AddressTemplate address = AddressTemplate.of(addressMeta.value());
        ModelNode protoType = new ModelNode();
        protoType.get(ADDRESS).set(address.resolve(NOOP_CTX, wildcards));
        protoType.get(OP).set(WRITE_ATTRIBUTE_OPERATION);

        ModelNode operation = new ModelNode();
        operation.get(OP).set(COMPOSITE);
        operation.get(ADDRESS).setEmptyList();

        List<ModelNode> steps = new ArrayList<ModelNode>();


        for (MethodInfo method : clazz.methods()) {

            if (method.hasAnnotation(IndexFactory.BINDING_META)) {

                try {

                    Method target = currentType.getMethod(method.name());
                    Class<?> propertyType = target.getReturnType();
                    ModelNodeBinding binding = target.getDeclaredAnnotation(ModelNodeBinding.class);
                    String detypedName = binding.detypedName();

                    String javaPropName = method.name(); // in our case it's same as the method name
                    Object value = changeSet.get(javaPropName);
                    if (value == null) continue;

                    ModelNode step = protoType.clone();

                    step.get(NAME).set(javaPropName);
                    ModelNode modelNode = step.get(VALUE);

                    try {
                        ModelType dmrType = Types.resolveModelType(propertyType);

                        if (dmrType == ModelType.LIST) {
                            new ListTypeAdapter().toDmr(modelNode.get(detypedName), (List) value);

                        } else if (dmrType == ModelType.OBJECT) {
                            new MapTypeAdapter().toDmr(modelNode.get(detypedName), (Map) value);

                        } else {
                            new SimpleTypeAdapter().toDmr(modelNode.get(detypedName), dmrType, value);
                        }
                    } catch (RuntimeException e) {
                        throw new RuntimeException("Failed to adopt value " + propertyType.getName(), e);
                    }

                    steps.add(step);

                } catch (NoSuchMethodException e) {
                    e.printStackTrace();
                }
            }

        }

        operation.get(STEPS).set(steps);

        return operation;
    }
83446
public static String serializeSet(Set<?> set) {
        if (set == null) {
            set = new HashSet<String>();
        }
        XStream xstream = new XStream(new DomDriver());
        return xstream.toXML(set);
    }
1047772
private void appendPropertyChanges(DiffBuilder diff, NodePair pair, final Optional<CommitMetadata> commitMetadata) {
        List<JaversProperty> nodeProperties = pair.getProperties();
        for (JaversProperty property : nodeProperties) {

            //optimization, skip all appenders if null on both sides
            if (pair.isNullOnBothSides(property)) {
                continue;
            }

            JaversType javersType = property.getType();

            appendChanges(diff, pair, property, javersType, commitMetadata);
        }
    }
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));
        }
    }
207744
public static void writeStringSet(DataOutputStream os, Collection<String> set) throws IOException {
		if(set==null) {
			os.writeInt(-1);
		} else {
			os.writeInt(set.size());
			for(String s : set) {
				writeString(os, s);
			}
		}

	}
186556
public static ChangeRequestAttribute createChangeRequestAttribute(
			boolean changeIP, boolean changePort) {
		ChangeRequestAttribute attribute = new ChangeRequestAttribute();

		attribute.setAddressChanging(changeIP);
		attribute.setPortChanging(changePort);

		return attribute;
	}
1099761
public static <T> Set<T> toImmutableSet(final Set<? extends T> set) {
    switch (set.size()) {
      case 0:
        return Collections.emptySet();
      case 1:
        return Collections.singleton(set.iterator().next());
      default:
        return Collections.unmodifiableSet(set);
    }
  }
774441
@SuppressWarnings("unchecked")
    protected Set _transform(final Set set) {
        if (set == null) return null;
        if (set instanceof BeanSet) return set;
        return new BeanSet<>(set, this);
    }
437726
def pop_changeset(self, changeset_id: uuid.UUID) -> Dict[bytes, Union[bytes, DeletedEntry]]:
        
        if changeset_id not in self.journal_data:
            raise KeyError(changeset_id, "Unknown changeset in JournalDB")

        all_ids = tuple(self.journal_data.keys())
        changeset_idx = all_ids.index(changeset_id)
        changesets_to_pop = all_ids[changeset_idx:]
        popped_clears = tuple(idx for idx in changesets_to_pop if idx in self._clears_at)
        if popped_clears:
            last_clear_idx = changesets_to_pop.index(popped_clears[-1])
            changesets_to_drop = changesets_to_pop[:last_clear_idx]
            changesets_to_merge = changesets_to_pop[last_clear_idx:]
        else:
            changesets_to_drop = ()
            changesets_to_merge = changesets_to_pop

        # we pull all of the changesets *after* the changeset we are
        # reverting to and collapse them to a single set of keys (giving
        # precedence to later changesets)
        changeset_data = merge(*(
            self.journal_data.pop(c_id)
            for c_id
            in changesets_to_merge
        ))

        # drop the changes on the floor if they came before a clear that is being committed
        for changeset_id in changesets_to_drop:
            self.journal_data.pop(changeset_id)

        self._clears_at.difference_update(popped_clears)
        return changeset_data
57555
@NonNull
  public static <E> ImmutableSet<E> appendSet(@NonNull ImmutableSet<E> set, @NonNull E newValue) {
    return ImmutableSet.<E>builder().addAll(set).add(newValue).build();
  }
329437
def record_changeset(self, custom_changeset_id: uuid.UUID = None) -> uuid.UUID:
        
        if custom_changeset_id is not None:
            if custom_changeset_id in self.journal_data:
                raise ValidationError(
                    "Tried to record with an existing changeset id: %r" % custom_changeset_id
                )
            else:
                changeset_id = custom_changeset_id
        else:
            changeset_id = uuid.uuid4()

        self.journal_data[changeset_id] = {}
        return changeset_id
115545
protected function proceedSubmitRecords(array $changeSet)
    {
        if (is_array($changeSet['submitRecords'] === false)) {
            return;
        }

        foreach ($changeSet['submitRecords'] as $submitRecord) {
            $submitRecordData = array(
                'changeset' => $changeSet['id'],
                'status' => $submitRecord['status'],
            );

            $wherePart = array('changeset' => $changeSet['id']);
            $submitRecordRow = $this->getLookupTableValues(Database::TABLE_SUBMIT_RECORDS, array('id'), $wherePart);
            if ($submitRecordRow === false) {
                $id = $this->getDatabase()->insertRecord(Database::TABLE_SUBMIT_RECORDS, $submitRecordData);

            } else {
                $id = $submitRecordRow['id'];
                $this->getDatabase()->updateRecord(Database::TABLE_SUBMIT_RECORDS, $submitRecordData, $submitRecordRow['id']);
            }

            $submitRecord = $this->unsetKeys($submitRecord, array('status'));

            if (is_array($submitRecord['labels']) === true) {
                $this->proceedSubmitRecordLabels($id, $submitRecord['labels']);
                $submitRecord = $this->unsetKeys($submitRecord, array('labels'));
            }

            $this->checkIfAllValuesWereProceeded($submitRecord, 'Submit record');
        }
    }
724558
def setattr(self, attr, new_value, close_the_changeset=True):
        """"""
        existing_value = getattr(self, attr, None)
        if existing_value != new_value:
            setattr(self, attr, new_value)
            self._changeset[attr] = new_value

        if close_the_changeset and self._changeset:
            self._call_callbacks()
256108
public int replace(Object dependency, ValueSet valueSet) {
        int returnCode = HTODDynacache.NO_EXCEPTION;
        dependencyNotUpdatedTable.remove(dependency);
        if (valueSet != null && valueSet.size() > this.delayOffloadEntriesLimit) {
            dependencyToEntryTable.remove(dependency);
            if (this.type == DEP_ID_TABLE) {
                returnCode = this.htod.writeValueSet(HTODDynacache.DEP_ID_DATA, dependency, valueSet, HTODDynacache.ALL);  // valueSet may be empty after writeValueSet
                this.htod.cache.getCacheStatisticsListener().depIdsOffloadedToDisk(dependency);
                //System.out.println("***** replace dependency id=" + dependency + " size=" + valueSet.size());
            } else {
                returnCode = this.htod.writeValueSet(HTODDynacache.TEMPLATE_ID_DATA, dependency, valueSet, HTODDynacache.ALL);  // valueSet may be empty after writeValueSet
                this.htod.cache.getCacheStatisticsListener().templatesOffloadedToDisk(dependency);
                //System.out.println("***** replace template id=" + dependency + " size=" + valueSet.size());
            }
        } else {
            if (valueSet.size() > 0) {
                dependencyToEntryTable.put(dependency, valueSet);
            } else {
                dependencyToEntryTable.remove(dependency);
            }
        }
        if (returnCode == HTODDynacache.DISK_SIZE_OVER_LIMIT_EXCEPTION && valueSet.size() > 0) {
            this.htod.delCacheEntry(valueSet, CachePerf.DISK_OVERFLOW, CachePerf.LOCAL, 
                                    !Cache.FROM_DEPID_TEMPLATE_INVALIDATION, 
                                    HTODInvalidationBuffer.FIRE_EVENT);
            returnCode = HTODDynacache.NO_EXCEPTION;
        }
        return returnCode;
    }
659509
protected Set<String> extractModifNames(Set mfSet)
	{
		Set<String> set = new HashSet<String>();

		for (Object o : mfSet)
		{
			ModificationFeature mf = (ModificationFeature) o;
			if (mf.getModificationType() != null && !mf.getModificationType().getTerm().isEmpty())
			{
				set.add(mf.getModificationType().getTerm().iterator().next());
			}
		}
		return set;
	}
94620
@Override
    public <O extends Comparable> Set<O> transform(Set<O> set) {
        return checkNotNull(set);
    }
775979
public static <PS, SEG, S> Consumer<List<RichTextChange<PS, SEG, S>>> applyMultiRichTextChange(
            GenericStyledArea<PS, SEG, S> area) {
        return changeList -> {
            MultiChangeBuilder<PS, SEG, S> builder = area.createMultiChange(changeList.size());
            for (RichTextChange<PS, SEG, S> c : changeList) {
                builder.replaceAbsolutely(c.getPosition(), c.getRemovalEnd(), c.getInserted());
            }
            builder.commit();
        };
    }