org.simpleflatmapper.datastax.impl.setter.SetWithConverterSettableDataSetter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sfm-datastax Show documentation
Show all versions of sfm-datastax Show documentation
Cassandra Datastax SFM supports.
package org.simpleflatmapper.datastax.impl.setter;
import com.datastax.driver.core.SettableByIndexData;
import org.simpleflatmapper.reflect.Setter;
import org.simpleflatmapper.converter.ContextualConverter;
import java.util.HashSet;
import java.util.Set;
public class SetWithConverterSettableDataSetter implements Setter, Set> {
private final int index;
private final ContextualConverter converter;
public SetWithConverterSettableDataSetter(int index, ContextualConverter converter) {
this.index = index;
this.converter = converter;
}
@Override
public void set(SettableByIndexData> target, Set value) throws Exception {
if (value == null) {
target.setToNull(index);
} else {
Set list = new HashSet(value.size());
for(I i : value) {
list.add(converter.convert(i, null));
}
target.setSet(index, list);
}
}
}