package jodd.db.type;

import jodd.util.collection.IntArrayList;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.sql.Types;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import static org.junit.jupiter.api.Assertions.assertEquals;

class TypesUtilTest {

	private static final IntArrayList list = new IntArrayList(39);
	
	@BeforeAll
	static void beforeAll() throws Exception {
		Field[] fields = Types.class.getDeclaredFields();
		for (Field field : fields) {
			final int modifiers = field.getModifiers();
			// catch all public static final int - fields
			if (Modifier.isPublic(modifiers)
					&& Modifier.isStatic(modifiers)
					&& Modifier.isFinal(modifiers)
					&& field.getType() == int.class) {
				list.add(field.getInt(field));
			}
		}
	}

	@ParameterizedTest
	@MethodSource(value = "testData_isIntegerType")
	void isIntegerType(final boolean expected, final int input) {
		assertEquals(expected, TypesUtil.isIntegerType(input));
	}
	private static Arguments[] testData_isIntegerType() {
		final List<Integer> integerTypes = Arrays.asList(Types.INTEGER , Types.SMALLINT,Types.TINYINT, Types.BIT) ;
		final List<Arguments> args = new ArrayList<>();
		Arrays.stream(list.toArray())
				.forEach(intStream -> args.add(Arguments.of(integerTypes.contains(intStream), intStream)) );

		return args.toArray(new Arguments[0]);
	}

	@ParameterizedTest
	@MethodSource(value = "testData_isStringType")
	void isStringType(final boolean expected, final int input) {
		assertEquals(expected, TypesUtil.isStringType(input));
	}
	private static Arguments[] testData_isStringType() {
		final List<Integer> stringTypes = Arrays.asList(Types.VARCHAR , Types.CHAR) ;
		final List<Arguments> args = new ArrayList<>();
		Arrays.stream(list.toArray())
				.forEach(intStream -> args.add(Arguments.of(stringTypes.contains(intStream), intStream)) );

		return args.toArray(new Arguments[0]);
	}

}
@@ -1,67 +1,1447 @@
-package jodd.db.type;%0A%0Aimport jodd.util.collection.IntArrayList
+// Copyright (c) 2003-present, Jodd Team (http://jodd.org)%0A// All rights reserved.%0A//%0A// Redistribution and use in source and binary forms, with or without%0A// modification, are permitted provided that the following conditions are met:%0A//%0A// 1. Redistributions of source code must retain the above copyright notice,%0A// this list of conditions and the following disclaimer.%0A//%0A// 2. Redistributions in binary form must reproduce the above copyright%0A// notice, this list of conditions and the following disclaimer in the%0A// documentation and/or other materials provided with the distribution.%0A//%0A// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS %22AS IS%22%0A// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE%0A// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE%0A// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE%0A// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR%0A// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF%0A// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS%0A// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN%0A// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)%0A// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE%0A// POSSIBILITY OF SUCH DAMAGE.%0A%0Apackage jodd.db.type;%0A%0Aimport jodd.util.buffer.FastIntBuffer
 ;%0Aim
@@ -1915,51 +1915,57 @@
 nal 
-IntArrayList list = new IntArrayList
+FastIntBuffer ALL_TYPES = new FastIntBuffer
 (39);%0A
-%09
 %0A%09@B
@@ -2353,15 +2353,23 @@
 %09%09%09%09
-list.ad
+ALL_TYPES.appen
 d(fi
@@ -2586,32 +2586,33 @@
 ype(input));%0A%09%7D%0A
+%0A
 %09private static 
@@ -2714,17 +2714,16 @@
 .INTEGER
- 
 , Types.
@@ -2731,16 +2731,17 @@
 MALLINT,
+ 
 Types.TI
@@ -2757,17 +2757,16 @@
 pes.BIT)
- 
 ;%0A%09%09fina
@@ -2817,36 +2817,41 @@
 %09%09Arrays.stream(
-list
+ALL_TYPES
 .toArray())%0A%09%09%09%09
@@ -2931,33 +2931,32 @@
 am), intStream))
- 
 );%0A%0A%09%09return arg
@@ -3178,16 +3178,17 @@
 t));%0A%09%7D%0A
+%0A
 %09private
@@ -3296,17 +3296,16 @@
 .VARCHAR
- 
 , Types.
@@ -3309,17 +3309,16 @@
 es.CHAR)
- 
 ;%0A%09%09fina
@@ -3377,20 +3377,25 @@
 .stream(
-list
+ALL_TYPES
 .toArray
@@ -3490,17 +3490,16 @@
 Stream))
- 
 );%0A%0A%09%09re
@@ -3540,8 +3540,9 @@
 );%0A%09%7D%0A%0A%7D
+%0A

Update TypesUtilTest.java