org.sfm.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.sfm.datastax.impl.setter;
import com.datastax.driver.core.SettableByIndexData;
import org.sfm.reflect.Setter;
import org.sfm.utils.conv.Converter;
import java.util.HashSet;
import java.util.Set;
public class SetWithConverterSettableDataSetter implements Setter> {
private final int index;
private final Converter converter;
public SetWithConverterSettableDataSetter(int index, Converter 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));
}
target.setSet(index, list);
}
}
}