All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.simpleflatmapper.datastax.impl.setter.ConverterToUDTValueMapper Maven / Gradle / Ivy

There is a newer version: 8.2.3
Show newest version
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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy