com.bazaarvoice.emodb.sor.delta.impl.SetDeltaBuilderImpl Maven / Gradle / Ivy
The newest version!
package com.bazaarvoice.emodb.sor.delta.impl;
import com.bazaarvoice.emodb.sor.delta.Delta;
import com.bazaarvoice.emodb.sor.delta.Deltas;
import com.bazaarvoice.emodb.sor.delta.Literal;
import com.bazaarvoice.emodb.sor.delta.SetDeltaBuilder;
import com.google.common.collect.Sets;
import javax.annotation.Nullable;
import java.util.Arrays;
import java.util.Set;
import static com.google.common.base.Preconditions.checkArgument;
public class SetDeltaBuilderImpl implements SetDeltaBuilder {
private boolean _removeRest;
private final Set _addedValues = Sets.newHashSet();
private final Set _removedValues = Sets.newHashSet();
private boolean _deleteIfEmpty;
@Override
public SetDeltaBuilder remove(@Nullable Object value) {
Literal literal = value instanceof Literal ? (Literal) value : Deltas.literal(value);
checkArgument(!_addedValues.contains(literal) && _removedValues.add(literal),
"Multiple operations against the same value are not allowed: %s", value);
return this;
}
@Override
public SetDeltaBuilder removeAll(Object... values) {
return removeAll(Arrays.asList(values));
}
@Override
public SetDeltaBuilder removeAll(Iterable
© 2015 - 2025 Weber Informatics LLC | Privacy Policy