com.vladsch.flexmark.util.data.MutableDataSet Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of driver-cql-shaded Show documentation
Show all versions of driver-cql-shaded Show documentation
A Shaded CQL ActivityType driver for http://nosqlbench.io/
package com.vladsch.flexmark.util.data;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class MutableDataSet extends DataSet implements MutableDataHolder {
public MutableDataSet() {
super();
}
public MutableDataSet(DataHolder other) {
super(other);
}
@NotNull
@Override
public MutableDataSet set(@NotNull DataKey key, @NotNull T value) {
return set((DataKeyBase) key, value);
}
@NotNull
@Override
public MutableDataSet set(@NotNull NullableDataKey key, @Nullable T value) {
return set((DataKeyBase) key, value);
}
private MutableDataSet set(@NotNull DataKeyBase key, T value) {
dataSet.put(key, value);
return this;
}
@NotNull
@Override
public MutableDataSet setFrom(@NotNull MutableDataSetter dataSetter) {
dataSetter.setIn(this);
return this;
}
@NotNull
@Override
public MutableDataSet setAll(@NotNull DataHolder other) {
dataSet.putAll(other.getAll());
return this;
}
public static MutableDataSet merge(DataHolder... dataHolders) {
MutableDataSet dataSet = new MutableDataSet();
for (DataHolder dataHolder : dataHolders) {
if (dataHolder != null) {
dataSet.dataSet.putAll(dataHolder.getAll());
}
}
return dataSet;
}
@NotNull
@Override
public MutableDataHolder setIn(@NotNull MutableDataHolder dataHolder) {
dataHolder.setAll(this);
return dataHolder;
}
@NotNull
@Override
public MutableDataSet remove(@NotNull DataKeyBase> key) {
dataSet.remove(key);
return this;
}
@Override
public @Nullable Object getOrCompute(@NotNull DataKeyBase> key, @NotNull DataValueFactory> factory) {
if (dataSet.containsKey(key)) {
return dataSet.get(key);
} else {
Object value = factory.apply(this);
dataSet.put(key, value);
return value;
}
}
@NotNull
@Override
public MutableDataSet toMutable() {
return this;
}
@NotNull
@Override
public DataSet toImmutable() {
return new DataSet(this);
}
@Override
public @NotNull MutableDataSet toDataSet() {
return this;
}
@NotNull
@Override
public MutableDataSet clear() {
dataSet.clear();
return this;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy