001package org.itsallcode.jdbc; 002 003/** 004 * This converts a domain object to an array of types supported by the database 005 * when inserting rows. 006 * 007 * @param <T> row type 008 */ 009@FunctionalInterface 010public interface ParamConverter<T> { 011 /** 012 * Converts a domain object to a row that can be inserted into the database. 013 * 014 * @param row domain object to convert 015 * @return converted row 016 */ 017 Object[] map(T row); 018 019 /** 020 * Identity parameter convert that returns object arrays unchanged. 021 * 022 * @return a new identity parameter converter 023 */ 024 static ParamConverter<Object[]> identity() { 025 return row -> row; 026 } 027}