org.simpleflatmapper.datastax.impl.setter.ConverterToUDTValueMapper 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.UDTValue;
import com.datastax.driver.core.UserType;
import org.simpleflatmapper.converter.Context;
import org.simpleflatmapper.map.FieldMapper;
import org.simpleflatmapper.converter.ContextualConverter;
public class ConverterToUDTValueMapper implements ContextualConverter {
private final FieldMapper mapper;
private final UserType userType;
public ConverterToUDTValueMapper(FieldMapper mapper, UserType userType) {
this.mapper = mapper;
this.userType = userType;
}
@Override
public UDTValue convert(I in, Context context) throws Exception {
if (in == null) return null;
UDTValue udtValue = userType.newValue();
mapper.mapTo(in, udtValue, null);
return udtValue;
}
}