DefaultBinderConfiguration implements BinderConfiguration { @Override public Binder getBinder(ParameterMetaData metadata, int param) throws SQLException { if (metadata == null) { return Binders.defaultBinder(); } try { int sqlType = metadata.getParameterType(param); if (sqlType == Types.DATE) { return Binders.dateBinder(); } if (sqlType == Types.TIME || sqlType == Types.TIME_WITH_TIMEZONE) { return Binders.timeBinder(); } if (sqlType == Types.TIMESTAMP || sqlType == Types.TIMESTAMP_WITH_TIMEZONE) { return Binders.timestampBinder(); } if (sqlType == Types.BIGINT || sqlType == Types.INTEGER || sqlType == Types.SMALLINT || sqlType == Types.TINYINT) { return Binders.integerBinder(); } if (sqlType == Types.DECIMAL || sqlType == Types.DOUBLE || sqlType == Types.FLOAT || sqlType == Types.NUMERIC || sqlType == Types.REAL) { return Binders.decimalBinder(); } if (sqlType == Types.VARCHAR || sqlType == Types.CHAR || sqlType == Types.LONGNVARCHAR || sqlType == Types.LONGVARCHAR || sqlType == Types.NCHAR || sqlType == Types.NVARCHAR) { return Binders.stringBinder(); } return Binders.defaultBinder(); } catch (SQLException e) { return Binders.defaultBinder(); } } protected  DefaultBinderConfiguration(); @Override Binder getBinder(ParameterMetaData metadata, int param); @Override String toString(); static final DefaultBinderConfiguration INSTANCE; }
@Test public void shouldReturnDefaultBinderIfNoParameterMetadata() throws SQLException { assertEquals(Binders.defaultBinder(), DefaultBinderConfiguration.INSTANCE.getBinder(null, 1)); }
@Test public void shouldReturnDefaultBinderIfParameterTypeCantBeObtained() throws SQLException { ParameterMetaData mockMetaData = mock(ParameterMetaData.class); when(mockMetaData.getParameterType(1)).thenThrow(new SQLException()); assertEquals(Binders.defaultBinder(), DefaultBinderConfiguration.INSTANCE.getBinder(mockMetaData, 1)); }