org.sfm.datastax.impl.getter.DatastaxSetWithConverterGetter 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.getter;
import com.datastax.driver.core.GettableByIndexData;
import org.sfm.reflect.Getter;
import org.sfm.utils.conv.Converter;
import java.util.HashSet;
import java.util.Set;
public class DatastaxSetWithConverterGetter implements Getter> {
private final int index;
private final Class type;
private final Converter converter;
public DatastaxSetWithConverterGetter(int index, Class type, Converter converter) {
this.index = index;
this.type = type;
this.converter = converter;
}
@Override
public Set get(GettableByIndexData target) throws Exception {
Set set = target.getSet(index, type);
if (set == null) return null;
Set convertedSet = new HashSet();
for(I i : set) {
convertedSet.add(converter.convert(i));
}
return convertedSet;
}
}