提交 51e50c98 authored 作者: thomasmueller's avatar thomasmueller

#1091 Get rid if the New class

上级 e07a34d1
...@@ -54,7 +54,7 @@ public class DropDatabase extends DefineCommand { ...@@ -54,7 +54,7 @@ public class DropDatabase extends DefineCommand {
boolean runLoopAgain; boolean runLoopAgain;
do { do {
ArrayList<Table> tables = db.getAllTablesAndViews(false); ArrayList<Table> tables = db.getAllTablesAndViews(false);
ArrayList<Table> toRemove = New.arrayList(); ArrayList<Table> toRemove = new ArrayList<>();
for (Table t : tables) { for (Table t : tables) {
if (t.getName() != null && if (t.getName() != null &&
TableType.VIEW == t.getTableType()) { TableType.VIEW == t.getTableType()) {
...@@ -99,7 +99,7 @@ public class DropDatabase extends DefineCommand { ...@@ -99,7 +99,7 @@ public class DropDatabase extends DefineCommand {
db.removeDatabaseObject(session, schema); db.removeDatabaseObject(session, schema);
} }
} }
ArrayList<SchemaObject> list = New.arrayList(); ArrayList<SchemaObject> list = new ArrayList<>();
for (SchemaObject obj : db.getAllSchemaObjects(DbObject.SEQUENCE)) { for (SchemaObject obj : db.getAllSchemaObjects(DbObject.SEQUENCE)) {
// ignore these. the ones we want to drop will get dropped when we // ignore these. the ones we want to drop will get dropped when we
// drop their associated tables, and we will ignore the problematic // drop their associated tables, and we will ignore the problematic
......
...@@ -18,7 +18,7 @@ import org.h2.engine.Session; ...@@ -18,7 +18,7 @@ import org.h2.engine.Session;
import org.h2.message.DbException; import org.h2.message.DbException;
import org.h2.schema.Schema; import org.h2.schema.Schema;
import org.h2.table.Table; import org.h2.table.Table;
import org.h2.util.New; import org.h2.util.Utils;
/** /**
* This class represents the statements * This class represents the statements
...@@ -32,7 +32,7 @@ public class GrantRevoke extends DefineCommand { ...@@ -32,7 +32,7 @@ public class GrantRevoke extends DefineCommand {
private ArrayList<String> roleNames; private ArrayList<String> roleNames;
private int operationType; private int operationType;
private int rightMask; private int rightMask;
private final ArrayList<Table> tables = New.arrayList(); private final ArrayList<Table> tables = Utils.newSmallArrayList();
private Schema schema; private Schema schema;
private RightOwner grantee; private RightOwner grantee;
...@@ -60,7 +60,7 @@ public class GrantRevoke extends DefineCommand { ...@@ -60,7 +60,7 @@ public class GrantRevoke extends DefineCommand {
*/ */
public void addRoleName(String roleName) { public void addRoleName(String roleName) {
if (roleNames == null) { if (roleNames == null) {
roleNames = New.arrayList(); roleNames = Utils.newSmallArrayList();
} }
roleNames.add(roleName); roleNames.add(roleName);
} }
......
...@@ -1553,7 +1553,7 @@ public class Database implements DataHandler { ...@@ -1553,7 +1553,7 @@ public class Database implements DataHandler {
*/ */
public ArrayList<SchemaObject> getAllSchemaObjects() { public ArrayList<SchemaObject> getAllSchemaObjects() {
initMetaTables(); initMetaTables();
ArrayList<SchemaObject> list = New.arrayList(); ArrayList<SchemaObject> list = new ArrayList<>();
for (Schema schema : schemas.values()) { for (Schema schema : schemas.values()) {
list.addAll(schema.getAll()); list.addAll(schema.getAll());
} }
...@@ -1570,7 +1570,7 @@ public class Database implements DataHandler { ...@@ -1570,7 +1570,7 @@ public class Database implements DataHandler {
if (type == DbObject.TABLE_OR_VIEW) { if (type == DbObject.TABLE_OR_VIEW) {
initMetaTables(); initMetaTables();
} }
ArrayList<SchemaObject> list = New.arrayList(); ArrayList<SchemaObject> list = new ArrayList<>();
for (Schema schema : schemas.values()) { for (Schema schema : schemas.values()) {
list.addAll(schema.getAll(type)); list.addAll(schema.getAll(type));
} }
...@@ -1602,7 +1602,7 @@ public class Database implements DataHandler { ...@@ -1602,7 +1602,7 @@ public class Database implements DataHandler {
* @return all objects of that type * @return all objects of that type
*/ */
public ArrayList<TableSynonym> getAllSynonyms() { public ArrayList<TableSynonym> getAllSynonyms() {
ArrayList<TableSynonym> list = New.arrayList(); ArrayList<TableSynonym> list = new ArrayList<>();
for (Schema schema : schemas.values()) { for (Schema schema : schemas.values()) {
list.addAll(schema.getAllSynonyms()); list.addAll(schema.getAllSynonyms());
} }
...@@ -1616,7 +1616,8 @@ public class Database implements DataHandler { ...@@ -1616,7 +1616,8 @@ public class Database implements DataHandler {
* @return the list * @return the list
*/ */
public ArrayList<Table> getTableOrViewByName(String name) { public ArrayList<Table> getTableOrViewByName(String name) {
ArrayList<Table> list = New.arrayList(); // we expect that at most one table matches, at least in most cases
ArrayList<Table> list = new ArrayList<>(1);
for (Schema schema : schemas.values()) { for (Schema schema : schemas.values()) {
Table table = schema.getTableOrViewByName(name); Table table = schema.getTableOrViewByName(name);
if (table != null) { if (table != null) {
......
...@@ -7,6 +7,7 @@ package org.h2.engine; ...@@ -7,6 +7,7 @@ package org.h2.engine;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import org.h2.api.ErrorCode; import org.h2.api.ErrorCode;
import org.h2.message.DbException; import org.h2.message.DbException;
import org.h2.message.Trace; import org.h2.message.Trace;
...@@ -18,7 +19,6 @@ import org.h2.table.Table; ...@@ -18,7 +19,6 @@ import org.h2.table.Table;
import org.h2.table.TableType; import org.h2.table.TableType;
import org.h2.table.TableView; import org.h2.table.TableView;
import org.h2.util.MathUtils; import org.h2.util.MathUtils;
import org.h2.util.New;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
import org.h2.util.Utils; import org.h2.util.Utils;
...@@ -224,7 +224,7 @@ public class User extends RightOwner { ...@@ -224,7 +224,7 @@ public class User extends RightOwner {
@Override @Override
public ArrayList<DbObject> getChildren() { public ArrayList<DbObject> getChildren() {
ArrayList<DbObject> children = New.arrayList(); ArrayList<DbObject> children = new ArrayList<>();
for (Right right : database.getAllRights()) { for (Right right : database.getAllRights()) {
if (right.getGrantee() == this) { if (right.getGrantee() == this) {
children.add(right); children.add(right);
......
...@@ -33,6 +33,7 @@ import java.util.Locale; ...@@ -33,6 +33,7 @@ import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import java.util.Random; import java.util.Random;
import org.h2.api.ErrorCode; import org.h2.api.ErrorCode;
import org.h2.bnf.Bnf; import org.h2.bnf.Bnf;
import org.h2.bnf.context.DbColumn; import org.h2.bnf.context.DbColumn;
...@@ -55,7 +56,6 @@ import org.h2.tools.RunScript; ...@@ -55,7 +56,6 @@ import org.h2.tools.RunScript;
import org.h2.tools.Script; import org.h2.tools.Script;
import org.h2.tools.SimpleResultSet; import org.h2.tools.SimpleResultSet;
import org.h2.util.JdbcUtils; import org.h2.util.JdbcUtils;
import org.h2.util.New;
import org.h2.util.Profiler; import org.h2.util.Profiler;
import org.h2.util.ScriptReader; import org.h2.util.ScriptReader;
import org.h2.util.SortedProperties; import org.h2.util.SortedProperties;
...@@ -990,7 +990,7 @@ public class WebApp { ...@@ -990,7 +990,7 @@ public class WebApp {
String sql = attributes.getProperty("sql").trim(); String sql = attributes.getProperty("sql").trim();
try { try {
ScriptReader r = new ScriptReader(new StringReader(sql)); ScriptReader r = new ScriptReader(new StringReader(sql));
final ArrayList<String> list = New.arrayList(); final ArrayList<String> list = new ArrayList<>();
while (true) { while (true) {
String s = r.readStatement(); String s = r.readStatement();
if (s == null) { if (s == null) {
...@@ -1425,7 +1425,7 @@ public class WebApp { ...@@ -1425,7 +1425,7 @@ public class WebApp {
private String executeLoop(Connection conn, int count, String sql) private String executeLoop(Connection conn, int count, String sql)
throws SQLException { throws SQLException {
ArrayList<Integer> params = New.arrayList(); ArrayList<Integer> params = new ArrayList<>();
int idx = 0; int idx = 0;
while (!stop) { while (!stop) {
idx = sql.indexOf('?', idx); idx = sql.indexOf('?', idx);
......
...@@ -24,6 +24,7 @@ import java.util.Map; ...@@ -24,6 +24,7 @@ import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Properties; import java.util.Properties;
import java.util.Set; import java.util.Set;
import org.h2.engine.Constants; import org.h2.engine.Constants;
import org.h2.engine.SysProperties; import org.h2.engine.SysProperties;
import org.h2.message.DbException; import org.h2.message.DbException;
...@@ -34,7 +35,6 @@ import org.h2.util.DateTimeUtils; ...@@ -34,7 +35,6 @@ import org.h2.util.DateTimeUtils;
import org.h2.util.JdbcUtils; import org.h2.util.JdbcUtils;
import org.h2.util.MathUtils; import org.h2.util.MathUtils;
import org.h2.util.NetUtils; import org.h2.util.NetUtils;
import org.h2.util.New;
import org.h2.util.SortedProperties; import org.h2.util.SortedProperties;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
import org.h2.util.Tool; import org.h2.util.Tool;
...@@ -469,7 +469,7 @@ public class WebServer implements Service { ...@@ -469,7 +469,7 @@ public class WebServer implements Service {
} }
ArrayList<HashMap<String, Object>> getSessions() { ArrayList<HashMap<String, Object>> getSessions() {
ArrayList<HashMap<String, Object>> list = New.arrayList(); ArrayList<HashMap<String, Object>> list = new ArrayList<>();
for (WebSession s : sessions.values()) { for (WebSession s : sessions.values()) {
list.add(s.getInfo()); list.add(s.getInfo());
} }
...@@ -527,7 +527,7 @@ public class WebServer implements Service { ...@@ -527,7 +527,7 @@ public class WebServer implements Service {
} }
public ArrayList<String> getCommandHistoryList() { public ArrayList<String> getCommandHistoryList() {
ArrayList<String> result = New.arrayList(); ArrayList<String> result = new ArrayList<>();
if (commandHistoryString == null) { if (commandHistoryString == null) {
return result; return result;
} }
...@@ -634,7 +634,7 @@ public class WebServer implements Service { ...@@ -634,7 +634,7 @@ public class WebServer implements Service {
* @return the list * @return the list
*/ */
synchronized ArrayList<ConnectionInfo> getSettings() { synchronized ArrayList<ConnectionInfo> getSettings() {
ArrayList<ConnectionInfo> settings = New.arrayList(); ArrayList<ConnectionInfo> settings = new ArrayList<>();
if (connInfoMap.size() == 0) { if (connInfoMap.size() == 0) {
Properties prop = loadProperties(); Properties prop = loadProperties();
if (prop.size() == 0) { if (prop.size() == 0) {
......
...@@ -19,8 +19,6 @@ import javax.servlet.http.HttpServlet; ...@@ -19,8 +19,6 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.h2.util.New;
/** /**
* This servlet lets the H2 Console be used in a standard servlet container * This servlet lets the H2 Console be used in a standard servlet container
* such as Tomcat or Jetty. * such as Tomcat or Jetty.
...@@ -34,7 +32,7 @@ public class WebServlet extends HttpServlet { ...@@ -34,7 +32,7 @@ public class WebServlet extends HttpServlet {
public void init() { public void init() {
ServletConfig config = getServletConfig(); ServletConfig config = getServletConfig();
Enumeration<?> en = config.getInitParameterNames(); Enumeration<?> en = config.getInitParameterNames();
ArrayList<String> list = New.arrayList(); ArrayList<String> list = new ArrayList<>();
while (en.hasMoreElements()) { while (en.hasMoreElements()) {
String name = en.nextElement().toString(); String name = en.nextElement().toString();
String value = config.getInitParameter(name); String value = config.getInitParameter(name);
......
...@@ -338,7 +338,7 @@ public class Csv implements SimpleRowSource { ...@@ -338,7 +338,7 @@ public class Csv implements SimpleRowSource {
} }
private void readHeader() throws IOException { private void readHeader() throws IOException {
ArrayList<String> list = New.arrayList(); ArrayList<String> list = new ArrayList<>();
while (true) { while (true) {
String v = readValue(); String v = readValue();
if (v == null) { if (v == null) {
......
...@@ -66,7 +66,6 @@ import org.h2.store.fs.FileUtils; ...@@ -66,7 +66,6 @@ import org.h2.store.fs.FileUtils;
import org.h2.util.IOUtils; import org.h2.util.IOUtils;
import org.h2.util.IntArray; import org.h2.util.IntArray;
import org.h2.util.MathUtils; import org.h2.util.MathUtils;
import org.h2.util.New;
import org.h2.util.SmallLRUCache; import org.h2.util.SmallLRUCache;
import org.h2.util.StatementBuilder; import org.h2.util.StatementBuilder;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
...@@ -1534,7 +1533,7 @@ public class Recover extends Tool implements DataHandler { ...@@ -1534,7 +1533,7 @@ public class Recover extends Tool implements DataHandler {
} }
private void resetSchema() { private void resetSchema() {
schema = New.arrayList(); schema = new ArrayList<>();
objectIdSet = new HashSet<>(); objectIdSet = new HashSet<>();
tableMap = new HashMap<>(); tableMap = new HashMap<>();
columnTypeMap = new HashMap<>(); columnTypeMap = new HashMap<>();
......
...@@ -24,7 +24,6 @@ import java.util.concurrent.TimeUnit; ...@@ -24,7 +24,6 @@ import java.util.concurrent.TimeUnit;
import org.h2.engine.Constants; import org.h2.engine.Constants;
import org.h2.server.web.ConnectionInfo; import org.h2.server.web.ConnectionInfo;
import org.h2.util.JdbcUtils; import org.h2.util.JdbcUtils;
import org.h2.util.New;
import org.h2.util.ScriptReader; import org.h2.util.ScriptReader;
import org.h2.util.SortedProperties; import org.h2.util.SortedProperties;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
...@@ -49,7 +48,7 @@ public class Shell extends Tool implements Runnable { ...@@ -49,7 +48,7 @@ public class Shell extends Tool implements Runnable {
private Statement stat; private Statement stat;
private boolean listMode; private boolean listMode;
private int maxColumnSize = 100; private int maxColumnSize = 100;
private final ArrayList<String> history = New.arrayList(); private final ArrayList<String> history = new ArrayList<>();
private boolean stopHide; private boolean stopHide;
private String serverPropertiesDir = Constants.SERVER_PROPERTIES_DIR; private String serverPropertiesDir = Constants.SERVER_PROPERTIES_DIR;
...@@ -487,7 +486,7 @@ public class Shell extends Tool implements Runnable { ...@@ -487,7 +486,7 @@ public class Shell extends Tool implements Runnable {
ResultSetMetaData meta = rs.getMetaData(); ResultSetMetaData meta = rs.getMetaData();
int len = meta.getColumnCount(); int len = meta.getColumnCount();
boolean truncated = false; boolean truncated = false;
ArrayList<String[]> rows = New.arrayList(); ArrayList<String[]> rows = new ArrayList<>();
// buffer the header // buffer the header
String[] columns = new String[len]; String[] columns = new String[len];
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
......
...@@ -74,7 +74,7 @@ public class CacheTQ implements Cache { ...@@ -74,7 +74,7 @@ public class CacheTQ implements Cache {
@Override @Override
public ArrayList<CacheObject> getAllChanged() { public ArrayList<CacheObject> getAllChanged() {
ArrayList<CacheObject> changed = New.arrayList(); ArrayList<CacheObject> changed = new ArrayList<>();
changed.addAll(lru.getAllChanged()); changed.addAll(lru.getAllChanged());
changed.addAll(fifo.getAllChanged()); changed.addAll(fifo.getAllChanged());
return changed; return changed;
......
...@@ -144,7 +144,7 @@ public class JdbcUtils { ...@@ -144,7 +144,7 @@ public class JdbcUtils {
if (allowedClassNames == null) { if (allowedClassNames == null) {
// initialize the static fields // initialize the static fields
String s = SysProperties.ALLOWED_CLASSES; String s = SysProperties.ALLOWED_CLASSES;
ArrayList<String> prefixes = New.arrayList(); ArrayList<String> prefixes = new ArrayList<>();
boolean allowAll = false; boolean allowAll = false;
HashSet<String> classNames = new HashSet<>(); HashSet<String> classNames = new HashSet<>();
for (String p : StringUtils.arraySplit(s, ',', true)) { for (String p : StringUtils.arraySplit(s, ',', true)) {
......
...@@ -14,6 +14,7 @@ import java.lang.management.OperatingSystemMXBean; ...@@ -14,6 +14,7 @@ import java.lang.management.OperatingSystemMXBean;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
...@@ -306,6 +307,16 @@ public class Utils { ...@@ -306,6 +307,16 @@ public class Utils {
return new int[len]; return new int[len];
} }
/**
* Create a new ArrayList with an initial capacity of 4.
*
* @param <T> the type
* @return the object
*/
public static <T> ArrayList<T> newSmallArrayList() {
return new ArrayList<>(4);
}
/** /**
* Create a long array with the given size. * Create a long array with the given size.
* *
......
...@@ -436,7 +436,7 @@ java org.h2.test.TestAll timer ...@@ -436,7 +436,7 @@ java org.h2.test.TestAll timer
/** /**
* The list of tests. * The list of tests.
*/ */
ArrayList<TestBase> tests = New.arrayList(); ArrayList<TestBase> tests = new ArrayList<>();
private Server server; private Server server;
......
...@@ -26,8 +26,8 @@ import org.h2.util.New; ...@@ -26,8 +26,8 @@ import org.h2.util.New;
public class Coverage { public class Coverage {
private static final String IMPORT = "import " + private static final String IMPORT = "import " +
Coverage.class.getPackage().getName() + ".Profile"; Coverage.class.getPackage().getName() + ".Profile";
private final ArrayList<String> files = New.arrayList(); private final ArrayList<String> files = new ArrayList<>();
private final ArrayList<String> exclude = New.arrayList(); private final ArrayList<String> exclude = new ArrayList<>();
private Tokenizer tokenizer; private Tokenizer tokenizer;
private Writer writer; private Writer writer;
private Writer data; private Writer data;
......
...@@ -353,7 +353,7 @@ public class TestCsv extends TestBase { ...@@ -353,7 +353,7 @@ public class TestCsv extends TestBase {
int len = getSize(1000, 10000); int len = getSize(1000, 10000);
PreparedStatement prep = conn.prepareStatement( PreparedStatement prep = conn.prepareStatement(
"insert into test(a, b) values(?, ?)"); "insert into test(a, b) values(?, ?)");
ArrayList<String[]> list = New.arrayList(); ArrayList<String[]> list = new ArrayList<>();
Random random = new Random(1); Random random = new Random(1);
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
String a = randomData(random), b = randomData(random); String a = randomData(random), b = randomData(random);
......
...@@ -685,7 +685,7 @@ public class TestFunctions extends TestBase implements AggregateFunction { ...@@ -685,7 +685,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
*/ */
public static class MedianString implements AggregateFunction { public static class MedianString implements AggregateFunction {
private final ArrayList<String> list = New.arrayList(); private final ArrayList<String> list = new ArrayList<>();
@Override @Override
public void add(Object value) { public void add(Object value) {
...@@ -715,7 +715,7 @@ public class TestFunctions extends TestBase implements AggregateFunction { ...@@ -715,7 +715,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
*/ */
public static class MedianStringType implements Aggregate { public static class MedianStringType implements Aggregate {
private final ArrayList<String> list = New.arrayList(); private final ArrayList<String> list = new ArrayList<>();
@Override @Override
public void add(Object value) { public void add(Object value) {
......
...@@ -103,7 +103,7 @@ public class TestMultiThreadedKernel extends TestBase { ...@@ -103,7 +103,7 @@ public class TestMultiThreadedKernel extends TestBase {
} }
private void testConcurrentRead() throws Exception { private void testConcurrentRead() throws Exception {
ArrayList<Task> list = New.arrayList(); ArrayList<Task> list = new ArrayList<>();
int size = 2; int size = 2;
final int count = 1000; final int count = 1000;
final Connection[] connections = new Connection[count]; final Connection[] connections = new Connection[count];
...@@ -144,7 +144,7 @@ public class TestMultiThreadedKernel extends TestBase { ...@@ -144,7 +144,7 @@ public class TestMultiThreadedKernel extends TestBase {
} }
private void testCache() throws Exception { private void testCache() throws Exception {
ArrayList<Task> list = New.arrayList(); ArrayList<Task> list = new ArrayList<>();
int size = 3; int size = 3;
final int count = 100; final int count = 100;
final Connection[] connections = new Connection[count]; final Connection[] connections = new Connection[count];
......
...@@ -221,7 +221,7 @@ public class TestTableEngines extends TestBase { ...@@ -221,7 +221,7 @@ public class TestTableEngines extends TestBase {
stat.executeUpdate("CREATE INDEX IDX_C_B_A ON T(C, B, A)"); stat.executeUpdate("CREATE INDEX IDX_C_B_A ON T(C, B, A)");
stat.executeUpdate("CREATE INDEX IDX_B_A ON T(B, A)"); stat.executeUpdate("CREATE INDEX IDX_B_A ON T(B, A)");
List<List<Object>> dataSet = New.arrayList(); List<List<Object>> dataSet = new ArrayList<>();
dataSet.add(Arrays.<Object>asList(1, "1", 1L)); dataSet.add(Arrays.<Object>asList(1, "1", 1L));
dataSet.add(Arrays.<Object>asList(1, "0", 2L)); dataSet.add(Arrays.<Object>asList(1, "0", 2L));
...@@ -855,7 +855,7 @@ public class TestTableEngines extends TestBase { ...@@ -855,7 +855,7 @@ public class TestTableEngines extends TestBase {
private static List<List<Object>> query(List<List<Object>> dataSet, private static List<List<Object>> query(List<List<Object>> dataSet,
RowFilter filter, RowComparator sort) { RowFilter filter, RowComparator sort) {
List<List<Object>> res = New.arrayList(); List<List<Object>> res = new ArrayList<>();
if (filter == null) { if (filter == null) {
res.addAll(dataSet); res.addAll(dataSet);
} else { } else {
...@@ -874,7 +874,7 @@ public class TestTableEngines extends TestBase { ...@@ -874,7 +874,7 @@ public class TestTableEngines extends TestBase {
private static List<List<Object>> query(Statement stat, String query) throws SQLException { private static List<List<Object>> query(Statement stat, String query) throws SQLException {
ResultSet rs = stat.executeQuery(query); ResultSet rs = stat.executeQuery(query);
int cols = rs.getMetaData().getColumnCount(); int cols = rs.getMetaData().getColumnCount();
List<List<Object>> list = New.arrayList(); List<List<Object>> list = new ArrayList<>();
while (rs.next()) { while (rs.next()) {
List<Object> row = new ArrayList<>(cols); List<Object> row = new ArrayList<>(cols);
for (int i = 1; i <= cols; i++) { for (int i = 1; i <= cols; i++) {
...@@ -1544,7 +1544,7 @@ public class TestTableEngines extends TestBase { ...@@ -1544,7 +1544,7 @@ public class TestTableEngines extends TestBase {
} }
lookupBatches.incrementAndGet(); lookupBatches.incrementAndGet();
return new IndexLookupBatch() { return new IndexLookupBatch() {
List<SearchRow> searchRows = New.arrayList(); List<SearchRow> searchRows = new ArrayList<>();
@Override @Override
public String getPlanSQL() { public String getPlanSQL() {
......
...@@ -483,7 +483,7 @@ public class TestTransaction extends TestBase { ...@@ -483,7 +483,7 @@ public class TestTransaction extends TestBase {
test(stat, "CREATE TABLE NEST1(ID INT PRIMARY KEY,VALUE VARCHAR(255))"); test(stat, "CREATE TABLE NEST1(ID INT PRIMARY KEY,VALUE VARCHAR(255))");
test(stat, "CREATE TABLE NEST2(ID INT PRIMARY KEY,VALUE VARCHAR(255))"); test(stat, "CREATE TABLE NEST2(ID INT PRIMARY KEY,VALUE VARCHAR(255))");
DatabaseMetaData meta = conn.getMetaData(); DatabaseMetaData meta = conn.getMetaData();
ArrayList<String> result = New.arrayList(); ArrayList<String> result = new ArrayList<>();
ResultSet rs1, rs2; ResultSet rs1, rs2;
rs1 = meta.getTables(null, null, "NEST%", null); rs1 = meta.getTables(null, null, "NEST%", null);
while (rs1.next()) { while (rs1.next()) {
...@@ -497,7 +497,7 @@ public class TestTransaction extends TestBase { ...@@ -497,7 +497,7 @@ public class TestTransaction extends TestBase {
} }
// should be NEST1.ID, NEST1.NAME, NEST2.ID, NEST2.NAME // should be NEST1.ID, NEST1.NAME, NEST2.ID, NEST2.NAME
assertEquals(result.toString(), 4, result.size()); assertEquals(result.toString(), 4, result.size());
result = New.arrayList(); result = new ArrayList<>();
test(stat, "INSERT INTO NEST1 VALUES(1,'A')"); test(stat, "INSERT INTO NEST1 VALUES(1,'A')");
test(stat, "INSERT INTO NEST1 VALUES(2,'B')"); test(stat, "INSERT INTO NEST1 VALUES(2,'B')");
test(stat, "INSERT INTO NEST2 VALUES(1,'1')"); test(stat, "INSERT INTO NEST2 VALUES(1,'1')");
...@@ -515,7 +515,7 @@ public class TestTransaction extends TestBase { ...@@ -515,7 +515,7 @@ public class TestTransaction extends TestBase {
} }
// should be A/1, A/2, B/1, B/2 // should be A/1, A/2, B/1, B/2
assertEquals(result.toString(), 4, result.size()); assertEquals(result.toString(), 4, result.size());
result = New.arrayList(); result = new ArrayList<>();
rs1 = s1.executeQuery("SELECT * FROM NEST1 ORDER BY ID"); rs1 = s1.executeQuery("SELECT * FROM NEST1 ORDER BY ID");
rs2 = s1.executeQuery("SELECT * FROM NEST2 ORDER BY ID"); rs2 = s1.executeQuery("SELECT * FROM NEST2 ORDER BY ID");
assertThrows(ErrorCode.OBJECT_CLOSED, rs1).next(); assertThrows(ErrorCode.OBJECT_CLOSED, rs1).next();
......
...@@ -88,7 +88,7 @@ public class TestTwoPhaseCommit extends TestBase { ...@@ -88,7 +88,7 @@ public class TestTwoPhaseCommit extends TestBase {
private void openWith(boolean rollback) throws SQLException { private void openWith(boolean rollback) throws SQLException {
Connection conn = getConnection("twoPhaseCommit"); Connection conn = getConnection("twoPhaseCommit");
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
ArrayList<String> list = New.arrayList(); ArrayList<String> list = new ArrayList<>();
ResultSet rs = stat.executeQuery("SELECT * FROM INFORMATION_SCHEMA.IN_DOUBT"); ResultSet rs = stat.executeQuery("SELECT * FROM INFORMATION_SCHEMA.IN_DOUBT");
while (rs.next()) { while (rs.next()) {
list.add(rs.getString("TRANSACTION")); list.add(rs.getString("TRANSACTION"));
......
...@@ -7,11 +7,12 @@ package org.h2.test.jaqu; ...@@ -7,11 +7,12 @@ package org.h2.test.jaqu;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import org.h2.jaqu.Table.JQColumn; import org.h2.jaqu.Table.JQColumn;
import org.h2.jaqu.Table.JQTable; import org.h2.jaqu.Table.JQTable;
import org.h2.util.New;
/** /**
* A data class that contains a column for each data type. * A data class that contains a column for each data type.
...@@ -64,7 +65,7 @@ public class SupportedTypes { ...@@ -64,7 +65,7 @@ public class SupportedTypes {
private java.sql.Timestamp mySqlTimestamp; private java.sql.Timestamp mySqlTimestamp;
static List<SupportedTypes> createList() { static List<SupportedTypes> createList() {
List<SupportedTypes> list = New.arrayList(); List<SupportedTypes> list = new ArrayList<>();
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
list.add(randomValue()); list.add(randomValue());
} }
......
...@@ -106,7 +106,7 @@ public class TestRecover { ...@@ -106,7 +106,7 @@ public class TestRecover {
SimpleDateFormat sd = new SimpleDateFormat("yyMMdd-HHmmss"); SimpleDateFormat sd = new SimpleDateFormat("yyMMdd-HHmmss");
String date = sd.format(new Date()); String date = sd.format(new Date());
File zipFile = new File(root, "backup-" + date + "-" + node + ".zip"); File zipFile = new File(root, "backup-" + date + "-" + node + ".zip");
ArrayList<File> list = New.arrayList(); ArrayList<File> list = new ArrayList<>();
File base = new File(sourcePath); File base = new File(sourcePath);
listRecursive(list, base); listRecursive(list, base);
if (list.size() == 0) { if (list.size() == 0) {
......
...@@ -40,7 +40,7 @@ public class TestScript extends TestBase { ...@@ -40,7 +40,7 @@ public class TestScript extends TestBase {
/** If set to true, the test will exit at the first failure. */ /** If set to true, the test will exit at the first failure. */
private boolean failFast; private boolean failFast;
private final ArrayList<String> statements = New.arrayList(); private final ArrayList<String> statements = new ArrayList<>();
private boolean reconnectOften; private boolean reconnectOften;
private Connection conn; private Connection conn;
...@@ -49,7 +49,7 @@ public class TestScript extends TestBase { ...@@ -49,7 +49,7 @@ public class TestScript extends TestBase {
private LineNumberReader in; private LineNumberReader in;
private int outputLineNo; private int outputLineNo;
private PrintStream out; private PrintStream out;
private final ArrayList<String[]> result = New.arrayList(); private final ArrayList<String[]> result = new ArrayList<>();
private String putBack; private String putBack;
private StringBuilder errors; private StringBuilder errors;
......
...@@ -387,7 +387,7 @@ public class TestConcurrent extends TestMVStore { ...@@ -387,7 +387,7 @@ public class TestConcurrent extends TestMVStore {
fileName(fileName).autoCommitDisabled().open(); fileName(fileName).autoCommitDisabled().open();
try { try {
s.setRetentionTime(0); s.setRetentionTime(0);
final ArrayList<MVMap<Integer, Integer>> list = New.arrayList(); final ArrayList<MVMap<Integer, Integer>> list = new ArrayList<>();
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
MVMap<Integer, Integer> m = s.openMap("d" + i); MVMap<Integer, Integer> m = s.openMap("d" + i);
list.add(m); list.add(m);
......
...@@ -77,7 +77,7 @@ public class TestMVStoreBenchmark extends TestBase { ...@@ -77,7 +77,7 @@ public class TestMVStoreBenchmark extends TestBase {
ArrayList<Map<Integer, String>> mapList; ArrayList<Map<Integer, String>> mapList;
long mem; long mem;
mapList = New.arrayList(); mapList = new ArrayList<>();
mem = getMemory(); mem = getMemory();
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
mapList.add(new HashMap<Integer, String>(size)); mapList.add(new HashMap<Integer, String>(size));
...@@ -86,7 +86,7 @@ public class TestMVStoreBenchmark extends TestBase { ...@@ -86,7 +86,7 @@ public class TestMVStoreBenchmark extends TestBase {
hash = getMemory() - mem; hash = getMemory() - mem;
mapList.size(); mapList.size();
mapList = New.arrayList(); mapList = new ArrayList<>();
mem = getMemory(); mem = getMemory();
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
mapList.add(new TreeMap<Integer, String>()); mapList.add(new TreeMap<Integer, String>());
...@@ -95,7 +95,7 @@ public class TestMVStoreBenchmark extends TestBase { ...@@ -95,7 +95,7 @@ public class TestMVStoreBenchmark extends TestBase {
tree = getMemory() - mem; tree = getMemory() - mem;
mapList.size(); mapList.size();
mapList = New.arrayList(); mapList = new ArrayList<>();
mem = getMemory(); mem = getMemory();
MVStore store = MVStore.open(null); MVStore store = MVStore.open(null);
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
......
...@@ -326,7 +326,7 @@ public class TestTransactionStore extends TestBase { ...@@ -326,7 +326,7 @@ public class TestTransactionStore extends TestBase {
ts = new TransactionStore(s); ts = new TransactionStore(s);
ts.init(); ts.init();
ts.setMaxTransactionId(16); ts.setMaxTransactionId(16);
ArrayList<Transaction> fifo = New.arrayList(); ArrayList<Transaction> fifo = new ArrayList<>();
int open = 0; int open = 0;
for (int i = 0; i < 64; i++) { for (int i = 0; i < 64; i++) {
Transaction t = null; Transaction t = null;
...@@ -739,9 +739,9 @@ public class TestTransactionStore extends TestBase { ...@@ -739,9 +739,9 @@ public class TestTransactionStore extends TestBase {
} }
private void testCompareWithPostgreSQL() throws Exception { private void testCompareWithPostgreSQL() throws Exception {
ArrayList<Statement> statements = New.arrayList(); ArrayList<Statement> statements = new ArrayList<>();
ArrayList<Transaction> transactions = New.arrayList(); ArrayList<Transaction> transactions = new ArrayList<>();
ArrayList<TransactionMap<Integer, String>> maps = New.arrayList(); ArrayList<TransactionMap<Integer, String>> maps = new ArrayList<>();
int connectionCount = 3, opCount = 1000, rowCount = 10; int connectionCount = 3, opCount = 1000, rowCount = 10;
try { try {
Class.forName("org.postgresql.Driver"); Class.forName("org.postgresql.Driver");
......
...@@ -22,7 +22,7 @@ public class BnfRandom implements BnfVisitor { ...@@ -22,7 +22,7 @@ public class BnfRandom implements BnfVisitor {
private static final boolean SHOW_SYNTAX = false; private static final boolean SHOW_SYNTAX = false;
private final Random random = new Random(); private final Random random = new Random();
private final ArrayList<RuleHead> statements = New.arrayList(); private final ArrayList<RuleHead> statements = new ArrayList<>();
private int level; private int level;
private String sql; private String sql;
......
...@@ -61,11 +61,11 @@ public class TestCrashAPI extends TestBase implements Runnable { ...@@ -61,11 +61,11 @@ public class TestCrashAPI extends TestBase implements Runnable {
private static final String DIR = "synth"; private static final String DIR = "synth";
private final ArrayList<Object> objects = New.arrayList(); private final ArrayList<Object> objects = new ArrayList<>();
private final HashMap<Class <?>, ArrayList<Method>> classMethods = private final HashMap<Class <?>, ArrayList<Method>> classMethods =
new HashMap<>(); new HashMap<>();
private RandomGen random = new RandomGen(); private RandomGen random = new RandomGen();
private final ArrayList<String> statements = New.arrayList(); private final ArrayList<String> statements = new ArrayList<>();
private int openCount; private int openCount;
private long callCount; private long callCount;
private volatile long maxWait = 60; private volatile long maxWait = 60;
......
...@@ -105,7 +105,7 @@ public class TestFuzzOptimizations extends TestBase { ...@@ -105,7 +105,7 @@ public class TestFuzzOptimizations extends TestBase {
long seed = seedGenerator.nextLong(); long seed = seedGenerator.nextLong();
println("seed: " + seed); println("seed: " + seed);
Random random = new Random(seed); Random random = new Random(seed);
ArrayList<String> params = New.arrayList(); ArrayList<String> params = new ArrayList<>();
String condition = getRandomCondition(random, params, columns, String condition = getRandomCondition(random, params, columns,
compares, values); compares, values);
String message = "seed: " + seed + " " + condition; String message = "seed: " + seed + " " + condition;
......
...@@ -27,7 +27,7 @@ import org.h2.util.StringUtils; ...@@ -27,7 +27,7 @@ import org.h2.util.StringUtils;
*/ */
public class TestJoin extends TestBase { public class TestJoin extends TestBase {
private final ArrayList<Connection> connections = New.arrayList(); private final ArrayList<Connection> connections = new ArrayList<>();
private Random random; private Random random;
private int paramCount; private int paramCount;
private StringBuilder buff; private StringBuilder buff;
...@@ -288,7 +288,7 @@ public class TestJoin extends TestBase { ...@@ -288,7 +288,7 @@ public class TestJoin extends TestBase {
} }
b.append(":\n"); b.append(":\n");
String result = b.toString(); String result = b.toString();
ArrayList<String> list = New.arrayList(); ArrayList<String> list = new ArrayList<>();
while (rs.next()) { while (rs.next()) {
b = new StringBuilder(); b = new StringBuilder();
for (int i = 0; i < columnCount; i++) { for (int i = 0; i < columnCount; i++) {
......
...@@ -38,8 +38,8 @@ public class TestKillRestartMulti extends TestBase { ...@@ -38,8 +38,8 @@ public class TestKillRestartMulti extends TestBase {
private String url; private String url;
private String user = "sa"; private String user = "sa";
private String password = "sa"; private String password = "sa";
private final ArrayList<Connection> connections = New.arrayList(); private final ArrayList<Connection> connections = new ArrayList<>();
private final ArrayList<String> tables = New.arrayList(); private final ArrayList<String> tables = new ArrayList<>();
private int openCount; private int openCount;
......
...@@ -26,7 +26,7 @@ import org.h2.util.ScriptReader; ...@@ -26,7 +26,7 @@ import org.h2.util.ScriptReader;
*/ */
public class TestNestedJoins extends TestBase { public class TestNestedJoins extends TestBase {
private final ArrayList<Statement> dbs = New.arrayList(); private final ArrayList<Statement> dbs = new ArrayList<>();
/** /**
* Run just this test. * Run just this test.
...@@ -218,7 +218,7 @@ public class TestNestedJoins extends TestBase { ...@@ -218,7 +218,7 @@ public class TestNestedJoins extends TestBase {
} }
private static String getResult(ResultSet rs) throws SQLException { private static String getResult(ResultSet rs) throws SQLException {
ArrayList<String> list = New.arrayList(); ArrayList<String> list = new ArrayList<>();
while (rs.next()) { while (rs.next()) {
StringBuilder buff = new StringBuilder(); StringBuilder buff = new StringBuilder();
for (int i = 0; i < rs.getMetaData().getColumnCount(); i++) { for (int i = 0; i < rs.getMetaData().getColumnCount(); i++) {
......
...@@ -25,7 +25,7 @@ import org.h2.util.ScriptReader; ...@@ -25,7 +25,7 @@ import org.h2.util.ScriptReader;
*/ */
public class TestOuterJoins extends TestBase { public class TestOuterJoins extends TestBase {
private final ArrayList<Statement> dbs = New.arrayList(); private final ArrayList<Statement> dbs = new ArrayList<>();
/** /**
* Run just this test. * Run just this test.
...@@ -271,7 +271,7 @@ public class TestOuterJoins extends TestBase { ...@@ -271,7 +271,7 @@ public class TestOuterJoins extends TestBase {
} }
private static String getResult(ResultSet rs) throws SQLException { private static String getResult(ResultSet rs) throws SQLException {
ArrayList<String> list = New.arrayList(); ArrayList<String> list = new ArrayList<>();
while (rs.next()) { while (rs.next()) {
StringBuilder buff = new StringBuilder(); StringBuilder buff = new StringBuilder();
for (int i = 0; i < rs.getMetaData().getColumnCount(); i++) { for (int i = 0; i < rs.getMetaData().getColumnCount(); i++) {
......
...@@ -30,8 +30,8 @@ public class TestPowerOffFs2 extends TestBase { ...@@ -30,8 +30,8 @@ public class TestPowerOffFs2 extends TestBase {
private FilePathDebug fs; private FilePathDebug fs;
private String url; private String url;
private final ArrayList<Connection> connections = New.arrayList(); private final ArrayList<Connection> connections = new ArrayList<>();
private final ArrayList<String> tables = New.arrayList(); private final ArrayList<String> tables = new ArrayList<>();
/** /**
* Run just this test. * Run just this test.
......
...@@ -21,7 +21,7 @@ import org.h2.util.New; ...@@ -21,7 +21,7 @@ import org.h2.util.New;
*/ */
public class TestRandomCompare extends TestBase { public class TestRandomCompare extends TestBase {
private final ArrayList<Statement> dbs = New.arrayList(); private final ArrayList<Statement> dbs = new ArrayList<>();
private int aliasId; private int aliasId;
/** /**
...@@ -246,7 +246,7 @@ public class TestRandomCompare extends TestBase { ...@@ -246,7 +246,7 @@ public class TestRandomCompare extends TestBase {
} }
private static String getResult(ResultSet rs) throws SQLException { private static String getResult(ResultSet rs) throws SQLException {
ArrayList<String> list = New.arrayList(); ArrayList<String> list = new ArrayList<>();
while (rs.next()) { while (rs.next()) {
StringBuilder buff = new StringBuilder(); StringBuilder buff = new StringBuilder();
for (int i = 0; i < rs.getMetaData().getColumnCount(); i++) { for (int i = 0; i < rs.getMetaData().getColumnCount(); i++) {
......
...@@ -45,7 +45,7 @@ class DbConnection implements DbInterface { ...@@ -45,7 +45,7 @@ class DbConnection implements DbInterface {
log("reset;"); log("reset;");
DatabaseMetaData meta = conn.getMetaData(); DatabaseMetaData meta = conn.getMetaData();
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
ArrayList<String> tables = New.arrayList(); ArrayList<String> tables = new ArrayList<>();
ResultSet rs = meta.getTables(null, null, null, new String[] { "TABLE" }); ResultSet rs = meta.getTables(null, null, null, new String[] { "TABLE" });
while (rs.next()) { while (rs.next()) {
String schemaName = rs.getString("TABLE_SCHEM"); String schemaName = rs.getString("TABLE_SCHEM");
......
...@@ -16,8 +16,8 @@ public class DbState implements DbInterface { ...@@ -16,8 +16,8 @@ public class DbState implements DbInterface {
private boolean connected; private boolean connected;
private boolean autoCommit; private boolean autoCommit;
private final TestSynth config; private final TestSynth config;
private ArrayList<Table> tables = New.arrayList(); private ArrayList<Table> tables = new ArrayList<>();
private ArrayList<Index> indexes = New.arrayList(); private ArrayList<Index> indexes = new ArrayList<>();
DbState(TestSynth config) { DbState(TestSynth config) {
this.config = config; this.config = config;
...@@ -25,8 +25,8 @@ public class DbState implements DbInterface { ...@@ -25,8 +25,8 @@ public class DbState implements DbInterface {
@Override @Override
public void reset() { public void reset() {
tables = New.arrayList(); tables = new ArrayList<>();
indexes = New.arrayList(); indexes = new ArrayList<>();
} }
@Override @Override
......
...@@ -35,7 +35,7 @@ public class Expression { ...@@ -35,7 +35,7 @@ public class Expression {
if (config.random().getBoolean(30)) { if (config.random().getBoolean(30)) {
return new String[] { "*" }; return new String[] { "*" };
} }
ArrayList<String> exp = New.arrayList(); ArrayList<String> exp = new ArrayList<>();
String sql = ""; String sql = "";
if (config.random().getBoolean(10)) { if (config.random().getBoolean(10)) {
sql += "DISTINCT "; sql += "DISTINCT ";
......
...@@ -59,8 +59,8 @@ class Result implements Comparable<Result> { ...@@ -59,8 +59,8 @@ class Result implements Comparable<Result> {
this.sql = sql; this.sql = sql;
type = RESULT_SET; type = RESULT_SET;
try { try {
rows = New.arrayList(); rows = new ArrayList<>();
header = New.arrayList(); header = new ArrayList<>();
ResultSetMetaData meta = rs.getMetaData(); ResultSetMetaData meta = rs.getMetaData();
int len = meta.getColumnCount(); int len = meta.getColumnCount();
Column[] cols = new Column[len]; Column[] cols = new Column[len];
......
...@@ -18,7 +18,7 @@ class Table { ...@@ -18,7 +18,7 @@ class Table {
private boolean globalTemporary; private boolean globalTemporary;
private Column[] columns; private Column[] columns;
private Column[] primaryKeys; private Column[] primaryKeys;
private final ArrayList<Index> indexes = New.arrayList(); private final ArrayList<Index> indexes = new ArrayList<>();
Table(TestSynth config) { Table(TestSynth config) {
this.config = config; this.config = config;
...@@ -178,7 +178,7 @@ class Table { ...@@ -178,7 +178,7 @@ class Table {
* @return the column * @return the column
*/ */
Column getRandomConditionColumn() { Column getRandomConditionColumn() {
ArrayList<Column> list = New.arrayList(); ArrayList<Column> list = new ArrayList<>();
for (Column col : columns) { for (Column col : columns) {
if (Column.isConditionType(config, col.getType())) { if (Column.isConditionType(config, col.getType())) {
list.add(col); list.add(col);
...@@ -205,7 +205,7 @@ class Table { ...@@ -205,7 +205,7 @@ class Table {
* @return the column or null if no such column was found * @return the column or null if no such column was found
*/ */
Column getRandomColumnOfType(int type) { Column getRandomColumnOfType(int type) {
ArrayList<Column> list = New.arrayList(); ArrayList<Column> list = new ArrayList<>();
for (Column col : columns) { for (Column col : columns) {
if (col.getType() == type) { if (col.getType() == type) {
list.add(col); list.add(col);
......
...@@ -144,7 +144,7 @@ public class TestSynth extends TestBase { ...@@ -144,7 +144,7 @@ public class TestSynth extends TestBase {
private void testRun(int seed) throws Exception { private void testRun(int seed) throws Exception {
random.setSeed(seed); random.setSeed(seed);
commands = New.arrayList(); commands = new ArrayList<>();
add(Command.getConnect(this)); add(Command.getConnect(this));
add(Command.getReset(this)); add(Command.getReset(this));
...@@ -202,7 +202,7 @@ public class TestSynth extends TestBase { ...@@ -202,7 +202,7 @@ public class TestSynth extends TestBase {
private boolean process(int seed, int id, Command command) throws Exception { private boolean process(int seed, int id, Command command) throws Exception {
try { try {
ArrayList<Result> results = New.arrayList(); ArrayList<Result> results = new ArrayList<>();
for (int i = 0; i < databases.size(); i++) { for (int i = 0; i < databases.size(); i++) {
DbInterface db = databases.get(i); DbInterface db = databases.get(i);
Result result = command.run(db); Result result = command.run(db);
...@@ -278,7 +278,7 @@ public class TestSynth extends TestBase { ...@@ -278,7 +278,7 @@ public class TestSynth extends TestBase {
public TestBase init(TestAll conf) throws Exception { public TestBase init(TestAll conf) throws Exception {
super.init(conf); super.init(conf);
deleteDb("synth/synth"); deleteDb("synth/synth");
databases = New.arrayList(); databases = new ArrayList<>();
// mode = HSQLDB; // mode = HSQLDB;
// addDatabase("org.hsqldb.jdbcDriver", "jdbc:hsqldb:test", "sa", "" ); // addDatabase("org.hsqldb.jdbcDriver", "jdbc:hsqldb:test", "sa", "" );
......
...@@ -209,7 +209,7 @@ class Parser { ...@@ -209,7 +209,7 @@ class Parser {
read("["); read("[");
read("]"); read("]");
read("{"); read("{");
ArrayList<Object> values = New.arrayList(); ArrayList<Object> values = new ArrayList<>();
do { do {
values.add(parseValue().getValue()); values.add(parseValue().getValue());
} while (readIf(",")); } while (readIf(","));
...@@ -250,7 +250,7 @@ class Parser { ...@@ -250,7 +250,7 @@ class Parser {
private void parseCall(String objectName, Object o, String methodName) { private void parseCall(String objectName, Object o, String methodName) {
stat.setMethodCall(objectName, o, methodName); stat.setMethodCall(objectName, o, methodName);
ArrayList<Arg> args = New.arrayList(); ArrayList<Arg> args = new ArrayList<>();
read("("); read("(");
while (true) { while (true) {
if (readIf(")")) { if (readIf(")")) {
......
...@@ -57,7 +57,7 @@ public class TestClassLoaderLeak extends TestBase { ...@@ -57,7 +57,7 @@ public class TestClassLoaderLeak extends TestBase {
// (check incoming references to TestClassLoader) // (check incoming references to TestClassLoader)
boolean fillMemory = false; boolean fillMemory = false;
if (fillMemory) { if (fillMemory) {
ArrayList<byte[]> memory = New.arrayList(); ArrayList<byte[]> memory = new ArrayList<>();
for (int i = 0; i < Integer.MAX_VALUE; i++) { for (int i = 0; i < Integer.MAX_VALUE; i++) {
memory.add(new byte[1024]); memory.add(new byte[1024]);
} }
......
...@@ -93,7 +93,7 @@ public class TestClearReferences extends TestBase { ...@@ -93,7 +93,7 @@ public class TestClearReferences extends TestBase {
} }
private void clear() throws Exception { private void clear() throws Exception {
ArrayList<Class <?>> classes = New.arrayList(); ArrayList<Class <?>> classes = new ArrayList<>();
findClasses(classes, new File("bin/org/h2")); findClasses(classes, new File("bin/org/h2"));
findClasses(classes, new File("temp/org/h2")); findClasses(classes, new File("temp/org/h2"));
for (Class<?> clazz : classes) { for (Class<?> clazz : classes) {
......
...@@ -179,7 +179,7 @@ public class TestCompress extends TestBase { ...@@ -179,7 +179,7 @@ public class TestCompress extends TestBase {
} }
for (int j = 0; j < 4; j++) { for (int j = 0; j < 4; j++) {
ArrayList<byte[]> comp = New.arrayList(); ArrayList<byte[]> comp = new ArrayList<>();
InputStream in = FileUtils.newInputStream("memFS:compress.h2.db"); InputStream in = FileUtils.newInputStream("memFS:compress.h2.db");
while (true) { while (true) {
int len = in.read(buff2); int len = in.read(buff2);
......
...@@ -474,7 +474,7 @@ public class TestDate extends TestBase { ...@@ -474,7 +474,7 @@ public class TestDate extends TestBase {
* @return the list * @return the list
*/ */
public static ArrayList<TimeZone> getDistinctTimeZones() { public static ArrayList<TimeZone> getDistinctTimeZones() {
ArrayList<TimeZone> distinct = New.arrayList(); ArrayList<TimeZone> distinct = new ArrayList<>();
for (String id : TimeZone.getAvailableIDs()) { for (String id : TimeZone.getAvailableIDs()) {
TimeZone t = TimeZone.getTimeZone(id); TimeZone t = TimeZone.getTimeZone(id);
for (TimeZone d : distinct) { for (TimeZone d : distinct) {
......
...@@ -76,7 +76,7 @@ public class TestFileLockProcess extends TestBase { ...@@ -76,7 +76,7 @@ public class TestFileLockProcess extends TestBase {
String[] procDef = { "java", selfDestruct, String[] procDef = { "java", selfDestruct,
"-cp", getClassPath(), "-cp", getClassPath(),
getClass().getName(), url }; getClass().getName(), url };
ArrayList<Process> processes = New.arrayList(); ArrayList<Process> processes = new ArrayList<>();
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
Thread.sleep(100); Thread.sleep(100);
if (i % 10 == 0) { if (i % 10 == 0) {
......
...@@ -42,7 +42,7 @@ public class TestOverflow extends TestBase { ...@@ -42,7 +42,7 @@ public class TestOverflow extends TestBase {
} }
private void test(int type, long minValue, long maxValue) { private void test(int type, long minValue, long maxValue) {
values = New.arrayList(); values = new ArrayList<>();
this.dataType = type; this.dataType = type;
this.min = new BigInteger("" + minValue); this.min = new BigInteger("" + minValue);
this.max = new BigInteger("" + maxValue); this.max = new BigInteger("" + maxValue);
......
...@@ -179,7 +179,7 @@ public class TestPageStore extends TestBase { ...@@ -179,7 +179,7 @@ public class TestPageStore extends TestBase {
stat.execute("insert into test " + stat.execute("insert into test " +
"select x, space(1100+x) from system_range(1, 100)"); "select x, space(1100+x) from system_range(1, 100)");
Random r = new Random(1); Random r = new Random(1);
ArrayList<Connection> list = New.arrayList(); ArrayList<Connection> list = new ArrayList<>();
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
Connection conn2 = getConnection(url, getUser(), getPassword()); Connection conn2 = getConnection(url, getUser(), getPassword());
list.add(conn2); list.add(conn2);
......
...@@ -68,7 +68,7 @@ public class ArchiveToolStore { ...@@ -68,7 +68,7 @@ public class ArchiveToolStore {
start(); start();
long tempSize = 8 * 1024 * 1024; long tempSize = 8 * 1024 * 1024;
String tempFileName = fileName + ".temp"; String tempFileName = fileName + ".temp";
ArrayList<String> fileNames = New.arrayList(); ArrayList<String> fileNames = new ArrayList<>();
System.out.println("Reading the file list"); System.out.println("Reading the file list");
long totalSize = addFiles(sourceDir, fileNames); long totalSize = addFiles(sourceDir, fileNames);
...@@ -160,7 +160,7 @@ public class ArchiveToolStore { ...@@ -160,7 +160,7 @@ public class ArchiveToolStore {
filesTemp.put(name, posArray); filesTemp.put(name, posArray);
} }
storeTemp.commit(); storeTemp.commit();
ArrayList<Cursor<int[], byte[]>> list = New.arrayList(); ArrayList<Cursor<int[], byte[]>> list = new ArrayList<>();
totalSize = 0; totalSize = 0;
for (int i = 1; i <= segmentId; i++) { for (int i = 1; i <= segmentId; i++) {
MVMap<int[], byte[]> data = storeTemp.openMap("data" + i); MVMap<int[], byte[]> data = storeTemp.openMap("data" + i);
...@@ -379,7 +379,7 @@ public class ArchiveToolStore { ...@@ -379,7 +379,7 @@ public class ArchiveToolStore {
storeTemp.commit(); storeTemp.commit();
} }
ArrayList<Cursor<int[], byte[]>> list = New.arrayList(); ArrayList<Cursor<int[], byte[]>> list = new ArrayList<>();
totalSize = 0; totalSize = 0;
currentSize = 0; currentSize = 0;
for (int i = 1; i <= lastSegment; i++) { for (int i = 1; i <= lastSegment; i++) {
......
...@@ -217,7 +217,7 @@ public class FilePathZip2 extends FilePath { ...@@ -217,7 +217,7 @@ public class FilePathZip2 extends FilePath {
ZipInputStream file = openZip(); ZipInputStream file = openZip();
String dirName = getEntryName(); String dirName = getEntryName();
String prefix = path.substring(0, path.length() - dirName.length()); String prefix = path.substring(0, path.length() - dirName.length());
ArrayList<FilePath> list = New.arrayList(); ArrayList<FilePath> list = new ArrayList<>();
while (true) { while (true) {
ZipEntry entry = file.getNextEntry(); ZipEntry entry = file.getNextEntry();
if (entry == null) { if (entry == null) {
......
...@@ -278,7 +278,7 @@ public class FileShell extends Tool { ...@@ -278,7 +278,7 @@ public class FileShell extends Tool {
recursive = true; recursive = true;
} }
String target = getFile(list[i++]); String target = getFile(list[i++]);
ArrayList<String> source = New.arrayList(); ArrayList<String> source = new ArrayList<>();
readFileList(list, i, source, recursive); readFileList(list, i, source, recursive);
zip(target, currentWorkingDirectory, source); zip(target, currentWorkingDirectory, source);
} }
......
...@@ -58,7 +58,7 @@ public class DbInspector { ...@@ -58,7 +58,7 @@ public class DbInspector {
public List<String> generateModel(String schema, String table, public List<String> generateModel(String schema, String table,
String packageName, boolean annotateSchema, boolean trimStrings) { String packageName, boolean annotateSchema, boolean trimStrings) {
try { try {
List<String> models = New.arrayList(); List<String> models = new ArrayList<>();
List<TableInspector> tables = getTables(schema, table); List<TableInspector> tables = getTables(schema, table);
for (TableInspector t : tables) { for (TableInspector t : tables) {
t.read(metaData); t.read(metaData);
...@@ -134,7 +134,7 @@ public class DbInspector { ...@@ -134,7 +134,7 @@ public class DbInspector {
ResultSet rs = null; ResultSet rs = null;
try { try {
rs = getMetaData().getSchemas(); rs = getMetaData().getSchemas();
ArrayList<String> schemaList = New.arrayList(); ArrayList<String> schemaList = new ArrayList<>();
while (rs.next()) { while (rs.next()) {
schemaList.add(rs.getString("TABLE_SCHEM")); schemaList.add(rs.getString("TABLE_SCHEM"));
} }
...@@ -143,7 +143,7 @@ public class DbInspector { ...@@ -143,7 +143,7 @@ public class DbInspector {
String jaquTables = DbVersion.class.getAnnotation(JQTable.class) String jaquTables = DbVersion.class.getAnnotation(JQTable.class)
.name(); .name();
List<TableInspector> tables = New.arrayList(); List<TableInspector> tables = new ArrayList<>();
if (schemaList.size() == 0) { if (schemaList.size() == 0) {
schemaList.add(null); schemaList.add(null);
} }
...@@ -165,7 +165,7 @@ public class DbInspector { ...@@ -165,7 +165,7 @@ public class DbInspector {
return tables; return tables;
} }
// schema subset OR table subset OR exact match // schema subset OR table subset OR exact match
List<TableInspector> matches = New.arrayList(); List<TableInspector> matches = new ArrayList<>();
for (TableInspector t : tables) { for (TableInspector t : tables) {
if (t.matches(schema, table)) { if (t.matches(schema, table)) {
matches.add(t); matches.add(t);
......
...@@ -14,11 +14,11 @@ import java.util.ArrayList; ...@@ -14,11 +14,11 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.IdentityHashMap; import java.util.IdentityHashMap;
import java.util.List; import java.util.List;
import org.h2.jaqu.bytecode.ClassReader; import org.h2.jaqu.bytecode.ClassReader;
import org.h2.jaqu.util.StatementLogger;
import org.h2.jaqu.util.ClassUtils; import org.h2.jaqu.util.ClassUtils;
import org.h2.jaqu.util.StatementLogger;
import org.h2.util.JdbcUtils; import org.h2.util.JdbcUtils;
import org.h2.util.New;
/** /**
* This class represents a query. * This class represents a query.
...@@ -29,13 +29,12 @@ public class Query<T> { ...@@ -29,13 +29,12 @@ public class Query<T> {
private final Db db; private final Db db;
private SelectTable<T> from; private SelectTable<T> from;
private final ArrayList<Token> conditions = New.arrayList(); private final ArrayList<Token> conditions = new ArrayList<>();
private final ArrayList<UpdateColumn> updateColumnDeclarations = New private final ArrayList<UpdateColumn> updateColumnDeclarations = new ArrayList<>();
.arrayList(); private final ArrayList<SelectTable<?>> joins = new ArrayList<>();
private final ArrayList<SelectTable<?>> joins = New.arrayList();
private final IdentityHashMap<Object, SelectColumn<T>> aliasMap = ClassUtils private final IdentityHashMap<Object, SelectColumn<T>> aliasMap = ClassUtils
.newIdentityHashMap(); .newIdentityHashMap();
private final ArrayList<OrderExpression<T>> orderByList = New.arrayList(); private final ArrayList<OrderExpression<T>> orderByList = new ArrayList<>();
private Object[] groupByExpressions; private Object[] groupByExpressions;
private long limit; private long limit;
private long offset; private long offset;
...@@ -99,7 +98,7 @@ public class Query<T> { ...@@ -99,7 +98,7 @@ public class Query<T> {
} }
private List<T> select(boolean distinct) { private List<T> select(boolean distinct) {
List<T> result = New.arrayList(); List<T> result = new ArrayList<>();
TableDefinition<T> def = from.getAliasDefinition(); TableDefinition<T> def = from.getAliasDefinition();
SQLStatement stat = getSelectStatement(distinct); SQLStatement stat = getSelectStatement(distinct);
def.appendSelectList(stat); def.appendSelectList(stat);
...@@ -178,7 +177,7 @@ public class Query<T> { ...@@ -178,7 +177,7 @@ public class Query<T> {
} }
private <X> List<X> select(Class<X> clazz, X x, boolean distinct) { private <X> List<X> select(Class<X> clazz, X x, boolean distinct) {
List<X> result = New.arrayList(); List<X> result = new ArrayList<>();
TableDefinition<X> def = db.define(clazz); TableDefinition<X> def = db.define(clazz);
SQLStatement stat = getSelectStatement(distinct); SQLStatement stat = getSelectStatement(distinct);
def.appendSelectList(stat, this, x); def.appendSelectList(stat, this, x);
...@@ -207,7 +206,7 @@ public class Query<T> { ...@@ -207,7 +206,7 @@ public class Query<T> {
appendSQL(stat, x); appendSQL(stat, x);
appendFromWhere(stat); appendFromWhere(stat);
ResultSet rs = stat.executeQuery(); ResultSet rs = stat.executeQuery();
List<X> result = New.arrayList(); List<X> result = new ArrayList<>();
Statement s = null; Statement s = null;
try { try {
s = rs.getStatement(); s = rs.getStatement();
......
...@@ -23,7 +23,7 @@ class SelectTable<T> { ...@@ -23,7 +23,7 @@ class SelectTable<T> {
private final String as; private final String as;
private final TableDefinition<T> aliasDef; private final TableDefinition<T> aliasDef;
private final boolean outerJoin; private final boolean outerJoin;
private final ArrayList<Token> joinConditions = New.arrayList(); private final ArrayList<Token> joinConditions = new ArrayList<>();
private final T alias; private final T alias;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
......
...@@ -96,12 +96,12 @@ class TableDefinition<T> { ...@@ -96,12 +96,12 @@ class TableDefinition<T> {
int tableVersion; int tableVersion;
private boolean createTableIfRequired = true; private boolean createTableIfRequired = true;
private final Class<T> clazz; private final Class<T> clazz;
private final ArrayList<FieldDefinition> fields = New.arrayList(); private final ArrayList<FieldDefinition> fields = new ArrayList<>();
private final IdentityHashMap<Object, FieldDefinition> fieldMap = private final IdentityHashMap<Object, FieldDefinition> fieldMap =
ClassUtils.newIdentityHashMap(); ClassUtils.newIdentityHashMap();
private List<String> primaryKeyColumnNames; private List<String> primaryKeyColumnNames;
private final ArrayList<IndexDefinition> indexes = New.arrayList(); private final ArrayList<IndexDefinition> indexes = new ArrayList<>();
private boolean memoryTable; private boolean memoryTable;
TableDefinition(Class<T> clazz) { TableDefinition(Class<T> clazz) {
...@@ -156,7 +156,7 @@ class TableDefinition<T> { ...@@ -156,7 +156,7 @@ class TableDefinition<T> {
} }
private ArrayList<String> mapColumnNames(Object[] columns) { private ArrayList<String> mapColumnNames(Object[] columns) {
ArrayList<String> columnNames = New.arrayList(); ArrayList<String> columnNames = new ArrayList<>();
for (Object column : columns) { for (Object column : columns) {
columnNames.add(getColumnName(column)); columnNames.add(getColumnName(column));
} }
...@@ -209,7 +209,7 @@ class TableDefinition<T> { ...@@ -209,7 +209,7 @@ class TableDefinition<T> {
strictTypeMapping = tableAnnotation.strictTypeMapping(); strictTypeMapping = tableAnnotation.strictTypeMapping();
} }
List<Field> classFields = New.arrayList(); List<Field> classFields = new ArrayList<>();
classFields.addAll(Arrays.asList(clazz.getDeclaredFields())); classFields.addAll(Arrays.asList(clazz.getDeclaredFields()));
if (inheritColumns) { if (inheritColumns) {
Class<?> superClass = clazz.getSuperclass(); Class<?> superClass = clazz.getSuperclass();
...@@ -254,7 +254,7 @@ class TableDefinition<T> { ...@@ -254,7 +254,7 @@ class TableDefinition<T> {
fields.add(fieldDef); fields.add(fieldDef);
} }
} }
List<String> primaryKey = New.arrayList(); List<String> primaryKey = new ArrayList<>();
for (FieldDefinition fieldDef : fields) { for (FieldDefinition fieldDef : fields) {
if (fieldDef.isPrimaryKey) { if (fieldDef.isPrimaryKey) {
primaryKey.add(fieldDef.columnName); primaryKey.add(fieldDef.columnName);
...@@ -500,7 +500,7 @@ class TableDefinition<T> { ...@@ -500,7 +500,7 @@ class TableDefinition<T> {
* @return the column list * @return the column list
*/ */
private static List<String> getColumns(String index) { private static List<String> getColumns(String index) {
List<String> cols = New.arrayList(); List<String> cols = new ArrayList<>();
if (index == null || index.length() == 0) { if (index == null || index.length() == 0) {
return null; return null;
} }
...@@ -573,7 +573,7 @@ class TableDefinition<T> { ...@@ -573,7 +573,7 @@ class TableDefinition<T> {
} }
List<IndexDefinition> getIndexes(IndexType type) { List<IndexDefinition> getIndexes(IndexType type) {
List<IndexDefinition> list = New.arrayList(); List<IndexDefinition> list = new ArrayList<>();
for (IndexDefinition def:indexes) { for (IndexDefinition def:indexes) {
if (def.type.equals(type)) { if (def.type.equals(type)) {
list.add(def); list.add(def);
......
...@@ -47,7 +47,7 @@ public class TableInspector { ...@@ -47,7 +47,7 @@ public class TableInspector {
private final String table; private final String table;
private final boolean forceUpperCase; private final boolean forceUpperCase;
private final Class<? extends java.util.Date> dateTimeClass; private final Class<? extends java.util.Date> dateTimeClass;
private final List<String> primaryKeys = New.arrayList(); private final List<String> primaryKeys = new ArrayList<>();
private Map<String, IndexInspector> indexes; private Map<String, IndexInspector> indexes;
private Map<String, ColumnInspector> columns; private Map<String, ColumnInspector> columns;
...@@ -268,7 +268,7 @@ public class TableInspector { ...@@ -268,7 +268,7 @@ public class TableInspector {
if (list.size() == 1) { if (list.size() == 1) {
ap.addParameter(parameter, list.get(0).getColumnsString()); ap.addParameter(parameter, list.get(0).getColumnsString());
} else { } else {
List<String> parameters = New.arrayList(); List<String> parameters = new ArrayList<>();
for (IndexInspector index : list) { for (IndexInspector index : list) {
parameters.add(index.getColumnsString()); parameters.add(index.getColumnsString());
} }
...@@ -278,7 +278,7 @@ public class TableInspector { ...@@ -278,7 +278,7 @@ public class TableInspector {
} }
private List<IndexInspector> getIndexes(IndexType type) { private List<IndexInspector> getIndexes(IndexType type) {
List<IndexInspector> list = New.arrayList(); List<IndexInspector> list = new ArrayList<>();
for (IndexInspector index : indexes.values()) { for (IndexInspector index : indexes.values()) {
if (index.type.equals(type)) { if (index.type.equals(type)) {
list.add(index); list.add(index);
...@@ -378,7 +378,7 @@ public class TableInspector { ...@@ -378,7 +378,7 @@ public class TableInspector {
*/ */
<T> List<ValidationRemark> validate(TableDefinition<T> def, <T> List<ValidationRemark> validate(TableDefinition<T> def,
boolean throwError) { boolean throwError) {
List<ValidationRemark> remarks = New.arrayList(); List<ValidationRemark> remarks = new ArrayList<>();
// model class definition validation // model class definition validation
if (!Modifier.isPublic(def.getModelClass().getModifiers())) { if (!Modifier.isPublic(def.getModelClass().getModifiers())) {
......
...@@ -44,7 +44,7 @@ public class JavaParser { ...@@ -44,7 +44,7 @@ public class JavaParser {
private static final HashSet<String> RESERVED = new HashSet<>(); private static final HashSet<String> RESERVED = new HashSet<>();
private static final HashMap<String, String> JAVA_IMPORT_MAP = new HashMap<>(); private static final HashMap<String, String> JAVA_IMPORT_MAP = new HashMap<>();
private final ArrayList<ClassObj> allClasses = New.arrayList(); private final ArrayList<ClassObj> allClasses = new ArrayList<>();
private String source; private String source;
...@@ -60,7 +60,7 @@ public class JavaParser { ...@@ -60,7 +60,7 @@ public class JavaParser {
private final LinkedHashMap<String, FieldObj> localVars = private final LinkedHashMap<String, FieldObj> localVars =
new LinkedHashMap<>(); new LinkedHashMap<>();
private final HashMap<String, MethodObj> allMethodsMap = new HashMap<>(); private final HashMap<String, MethodObj> allMethodsMap = new HashMap<>();
private final ArrayList<Statement> nativeHeaders = New.arrayList(); private final ArrayList<Statement> nativeHeaders = new ArrayList<>();
private final HashMap<String, String> stringToStringConstantMap = new HashMap<>(); private final HashMap<String, String> stringToStringConstantMap = new HashMap<>();
private final HashMap<String, String> stringConstantToStringMap = new HashMap<>(); private final HashMap<String, String> stringConstantToStringMap = new HashMap<>();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论