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

#1091 Get rid if the New class

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