package org.simpleflatmapper.datastax.impl.getter;
import com.datastax.driver.core.GettableByIndexData;
import org.simpleflatmapper.datastax.DataHelper;
import org.simpleflatmapper.reflect.Getter;
import org.simpleflatmapper.reflect.primitive.LongGetter;
public class DatastaxTimeGetter implements LongGetter<GettableByIndexData>, Getter<GettableByIndexData, Long> {
private final int index;
public DatastaxTimeGetter(int index) {
this.index = index;
}
@Override
public Long get(GettableByIndexData target) throws Exception {
if (target.isNull(index)) {
return null;
}
return getLong(target);
}
@Override
public long getLong(GettableByIndexData target) throws Exception {
return DataHelper.getTime(index, target);
}
}