use of org.apache.ignite.table.mapper.OneColumnMapper in project ignite-3 by apache.
the class Marshaller method simpleMarshaller.
/**
* Creates a marshaller for class.
*
* @param cols Columns.
* @param mapper Mapper.
* @return Marshaller.
*/
static <T> SimpleMarshaller simpleMarshaller(Column[] cols, @NotNull OneColumnMapper<T> mapper) {
final Class<T> targetType = mapper.targetType();
Column col = (mapper.mappedColumn() == null && cols.length == 1) ? cols[0] : Arrays.stream(cols).filter(c -> c.name().equals(mapper.mappedColumn())).findFirst().orElseThrow(() -> new SchemaMismatchException("Failed to map object to a single column:" + mapper.mappedColumn()));
assert !targetType.isPrimitive() : "Non-nullable types are not allowed.";
return new SimpleMarshaller(ColumnBinding.createIdentityBinding(col, targetType, mapper.converter()));
}
Aggregations