diff --git a/src/main/java/io/github/spannm/jackcess/Cursor.java b/src/main/java/io/github/spannm/jackcess/Cursor.java index 3bc58f0..f862a67 100644 --- a/src/main/java/io/github/spannm/jackcess/Cursor.java +++ b/src/main/java/io/github/spannm/jackcess/Cursor.java @@ -21,6 +21,7 @@ import io.github.spannm.jackcess.util.IterableBuilder; import java.io.IOException; +import java.io.UncheckedIOException; import java.util.Collection; import java.util.Iterator; import java.util.Map; diff --git a/src/main/java/io/github/spannm/jackcess/Database.java b/src/main/java/io/github/spannm/jackcess/Database.java index af41c24..77d47c2 100644 --- a/src/main/java/io/github/spannm/jackcess/Database.java +++ b/src/main/java/io/github/spannm/jackcess/Database.java @@ -24,10 +24,7 @@ import io.github.spannm.jackcess.util.LinkResolver; import io.github.spannm.jackcess.util.TableIterableBuilder; -import java.io.Closeable; -import java.io.File; -import java.io.Flushable; -import java.io.IOException; +import java.io.*; import java.nio.charset.Charset; import java.nio.file.Path; import java.time.ZoneId; diff --git a/src/main/java/io/github/spannm/jackcess/Table.java b/src/main/java/io/github/spannm/jackcess/Table.java index 868824c..5713c0c 100644 --- a/src/main/java/io/github/spannm/jackcess/Table.java +++ b/src/main/java/io/github/spannm/jackcess/Table.java @@ -20,6 +20,7 @@ import io.github.spannm.jackcess.util.OleBlob; import java.io.IOException; +import java.io.UncheckedIOException; import java.time.LocalDateTime; import java.util.Iterator; import java.util.List; diff --git a/src/main/java/io/github/spannm/jackcess/TableBuilder.java b/src/main/java/io/github/spannm/jackcess/TableBuilder.java index bb8d6f9..dce0d53 100644 --- a/src/main/java/io/github/spannm/jackcess/TableBuilder.java +++ b/src/main/java/io/github/spannm/jackcess/TableBuilder.java @@ -54,38 +54,37 @@ private static final class ReservedWords { /** * All of the reserved words in Access that should be escaped when creating table or column names */ - private static final Set VALUES = - new HashSet<>(Arrays.asList( - "add", "all", "alphanumeric", "alter", "and", "any", "application", "as", - "asc", "assistant", "autoincrement", "avg", "between", "binary", "bit", - "boolean", "by", "byte", "char", "character", "column", "compactdatabase", - "constraint", "container", "count", "counter", "create", "createdatabase", - "createfield", "creategroup", "createindex", "createobject", "createproperty", - "createrelation", "createtabledef", "createuser", "createworkspace", - "currency", "currentuser", "database", "date", "datetime", "delete", - "desc", "description", "disallow", "distinct", "distinctrow", "document", - "double", "drop", "echo", "else", "end", "eqv", "error", "exists", "exit", - "false", "field", "fields", "fillcache", "float", "float4", "float8", - "foreign", "form", "forms", "from", "full", "function", "general", - "getobject", "getoption", "gotopage", "group", "group by", "guid", "having", - "idle", "ieeedouble", "ieeesingle", "if", "ignore", "imp", "in", "index", - "indexes", "inner", "insert", "inserttext", "int", "integer", "integer1", - "integer2", "integer4", "into", "is", "join", "key", "lastmodified", "left", - "level", "like", "logical", "logical1", "long", "longbinary", "longtext", - "macro", "match", "max", "min", "mod", "memo", "module", "money", "move", - "name", "newpassword", "no", "not", "null", "number", "numeric", "object", - "oleobject", "off", "on", "openrecordset", "option", "or", "order", "outer", - "owneraccess", "parameter", "parameters", "partial", "percent", "pivot", - "primary", "procedure", "property", "queries", "query", "quit", "real", - "recalc", "recordset", "references", "refresh", "refreshlink", - "registerdatabase", "relation", "repaint", "repairdatabase", "report", - "reports", "requery", "right", "screen", "section", "select", "set", - "setfocus", "setoption", "short", "single", "smallint", "some", "sql", - "stdev", "stdevp", "string", "sum", "table", "tabledef", "tabledefs", - "tableid", "text", "time", "timestamp", "top", "transform", "true", "type", - "union", "unique", "update", "user", "value", "values", "var", "varp", - "varbinary", "varchar", "where", "with", "workspace", "xor", "year", "yes", - "yesno")); + private static final Set VALUES = Set.of( + "add", "all", "alphanumeric", "alter", "and", "any", "application", "as", + "asc", "assistant", "autoincrement", "avg", "between", "binary", "bit", + "boolean", "by", "byte", "char", "character", "column", "compactdatabase", + "constraint", "container", "count", "counter", "create", "createdatabase", + "createfield", "creategroup", "createindex", "createobject", "createproperty", + "createrelation", "createtabledef", "createuser", "createworkspace", + "currency", "currentuser", "database", "date", "datetime", "delete", + "desc", "description", "disallow", "distinct", "distinctrow", "document", + "double", "drop", "echo", "else", "end", "eqv", "error", "exists", "exit", + "false", "field", "fields", "fillcache", "float", "float4", "float8", + "foreign", "form", "forms", "from", "full", "function", "general", + "getobject", "getoption", "gotopage", "group", "group by", "guid", "having", + "idle", "ieeedouble", "ieeesingle", "if", "ignore", "imp", "in", "index", + "indexes", "inner", "insert", "inserttext", "int", "integer", "integer1", + "integer2", "integer4", "into", "is", "join", "key", "lastmodified", "left", + "level", "like", "logical", "logical1", "long", "longbinary", "longtext", + "macro", "match", "max", "min", "mod", "memo", "module", "money", "move", + "name", "newpassword", "no", "not", "null", "number", "numeric", "object", + "oleobject", "off", "on", "openrecordset", "option", "or", "order", "outer", + "owneraccess", "parameter", "parameters", "partial", "percent", "pivot", + "primary", "procedure", "property", "queries", "query", "quit", "real", + "recalc", "recordset", "references", "refresh", "refreshlink", + "registerdatabase", "relation", "repaint", "repairdatabase", "report", + "reports", "requery", "right", "screen", "section", "select", "set", + "setfocus", "setoption", "short", "single", "smallint", "some", "sql", + "stdev", "stdevp", "string", "sum", "table", "tabledef", "tabledefs", + "tableid", "text", "time", "timestamp", "top", "transform", "true", "type", + "union", "unique", "update", "user", "value", "values", "var", "varp", + "varbinary", "varchar", "where", "with", "workspace", "xor", "year", "yes", + "yesno"); } /** name of the new table */ diff --git a/src/main/java/io/github/spannm/jackcess/impl/DatabaseImpl.java b/src/main/java/io/github/spannm/jackcess/impl/DatabaseImpl.java index 8be56d1..c537c59 100644 --- a/src/main/java/io/github/spannm/jackcess/impl/DatabaseImpl.java +++ b/src/main/java/io/github/spannm/jackcess/impl/DatabaseImpl.java @@ -747,7 +747,7 @@ public void setLinkResolver(LinkResolver newLinkResolver) { @Override public Map getLinkedDatabases() { - return _linkedDbs == null ? Collections.emptyMap() : Collections.unmodifiableMap(_linkedDbs); + return _linkedDbs == null ? Map.of() : Collections.unmodifiableMap(_linkedDbs); } @Override diff --git a/src/main/java/io/github/spannm/jackcess/impl/FKEnforcer.java b/src/main/java/io/github/spannm/jackcess/impl/FKEnforcer.java index eaf63eb..aef2a57 100644 --- a/src/main/java/io/github/spannm/jackcess/impl/FKEnforcer.java +++ b/src/main/java/io/github/spannm/jackcess/impl/FKEnforcer.java @@ -61,7 +61,7 @@ private void initColumns() { } } } - _cols = !cols.isEmpty() ? List.copyOf(cols) : Collections.emptyList(); + _cols = !cols.isEmpty() ? List.copyOf(cols) : List.of(); } /** @@ -225,7 +225,7 @@ private static void requirePrimaryValues(Joiner joiner, Object[] row) // this table is a secondary table. however, null values are allowed if (!areNull(joiner, row) && !joiner.hasRows(row)) { throw new ConstraintViolationException( - "Adding new row " + Arrays.asList(row) + " violates constraint " + joiner.toFKString()); + "Adding new row " + Arrays.toString(row) + " violates constraint " + joiner.toFKString()); } } @@ -235,7 +235,7 @@ private static void requireNoSecondaryValues(Joiner joiner, Object[] row) // the primary table. if (joiner.hasRows(row)) { throw new ConstraintViolationException( - "Removing old row " + Arrays.asList(row) + " violates constraint " + joiner.toFKString()); + "Removing old row " + Arrays.toString(row) + " violates constraint " + joiner.toFKString()); } } @@ -248,7 +248,7 @@ private static void updateSecondaryValues(Joiner joiner, Object[] oldFromRow, Object[] toRow = new Object[joiner.getToTable().getColumnCount()]; for (Iterator iter = joiner.findRows(oldFromRow) - .withColumnNames(Collections.emptySet()) + .withColumnNames(Set.of()) .iterator(); iter.hasNext();) { iter.next(); @@ -271,7 +271,7 @@ private static void nullSecondaryValues(Joiner joiner, Object[] oldFromRow) Object[] toRow = new Object[joiner.getToTable().getColumnCount()]; for (Iterator iter = joiner.findRows(oldFromRow) - .withColumnNames(Collections.emptySet()) + .withColumnNames(Set.of()) .iterator(); iter.hasNext();) { iter.next(); diff --git a/src/main/java/io/github/spannm/jackcess/impl/GeneralLegacyIndexCodes.java b/src/main/java/io/github/spannm/jackcess/impl/GeneralLegacyIndexCodes.java index ce624df..c1f95f1 100644 --- a/src/main/java/io/github/spannm/jackcess/impl/GeneralLegacyIndexCodes.java +++ b/src/main/java/io/github/spannm/jackcess/impl/GeneralLegacyIndexCodes.java @@ -426,7 +426,7 @@ private static CharHandler parseCodes(Map prefixMap, */ private static CharHandler parseSimpleCodes(String[] codeStrings) { if (codeStrings.length != 1) { - throw new IllegalStateException("Unexpected code strings " + Arrays.asList(codeStrings)); + throw new IllegalStateException("Unexpected code strings " + Arrays.toString(codeStrings)); } return new SimpleCharHandler(codesToBytes(codeStrings[0], true)); } @@ -436,7 +436,7 @@ private static CharHandler parseSimpleCodes(String[] codeStrings) { */ private static CharHandler parseInternationalCodes(String[] codeStrings) { if (codeStrings.length != 2) { - throw new IllegalStateException("Unexpected code strings " + Arrays.asList(codeStrings)); + throw new IllegalStateException("Unexpected code strings " + Arrays.toString(codeStrings)); } return new InternationalCharHandler(codesToBytes(codeStrings[0], true), codesToBytes(codeStrings[1], true)); @@ -447,7 +447,7 @@ private static CharHandler parseInternationalCodes(String[] codeStrings) { */ private static CharHandler parseUnprintableCodes(String[] codeStrings) { if (codeStrings.length != 1) { - throw new IllegalStateException("Unexpected code strings " + Arrays.asList(codeStrings)); + throw new IllegalStateException("Unexpected code strings " + Arrays.toString(codeStrings)); } return new UnprintableCharHandler(codesToBytes(codeStrings[0], true)); } @@ -457,11 +457,11 @@ private static CharHandler parseUnprintableCodes(String[] codeStrings) { */ private static CharHandler parseUnprintableExtCodes(String[] codeStrings) { if (codeStrings.length != 1) { - throw new IllegalStateException("Unexpected code strings " + Arrays.asList(codeStrings)); + throw new IllegalStateException("Unexpected code strings " + Arrays.toString(codeStrings)); } byte[] bytes = codesToBytes(codeStrings[0], true); if (bytes.length != 1) { - throw new IllegalStateException("Unexpected code strings " + Arrays.asList(codeStrings)); + throw new IllegalStateException("Unexpected code strings " + Arrays.toString(codeStrings)); } return new UnprintableExtCharHandler(bytes[0]); } @@ -471,7 +471,7 @@ private static CharHandler parseUnprintableExtCodes(String[] codeStrings) { */ private static CharHandler parseInternationalExtCodes(String[] codeStrings) { if (codeStrings.length != 3) { - throw new IllegalStateException("Unexpected code strings " + Arrays.asList(codeStrings)); + throw new IllegalStateException("Unexpected code strings " + Arrays.toString(codeStrings)); } byte crazyFlag = "1".equals(codeStrings[2]) ? CRAZY_CODE_1 : CRAZY_CODE_2; @@ -483,7 +483,7 @@ private static CharHandler parseInternationalExtCodes(String[] codeStrings) { */ private static CharHandler parseSignificantCodes(String[] codeStrings) { if (codeStrings.length != 1) { - throw new IllegalStateException("Unexpected code strings " + Arrays.asList(codeStrings)); + throw new IllegalStateException("Unexpected code strings " + Arrays.toString(codeStrings)); } return new SignificantCharHandler(codesToBytes(codeStrings[0], true)); } diff --git a/src/main/java/io/github/spannm/jackcess/impl/IndexData.java b/src/main/java/io/github/spannm/jackcess/impl/IndexData.java index 1e9ea63..5799f8c 100644 --- a/src/main/java/io/github/spannm/jackcess/impl/IndexData.java +++ b/src/main/java/io/github/spannm/jackcess/impl/IndexData.java @@ -565,7 +565,7 @@ private PendingChange prepareAddRow(Object[] row, RowIdImpl rowId, AddRowPending return change; } if (nullCount > 0 && (isBackingPrimaryKey() || isRequired())) { - throw new ConstraintViolationException(withErrorContext("Null value found in row " + Arrays.asList(row) + " for primary key or required index")); + throw new ConstraintViolationException(withErrorContext("Null value found in row " + Arrays.toString(row) + " for primary key or required index")); } // make sure we've parsed the entries @@ -594,7 +594,7 @@ private PendingChange prepareAddEntry(Entry newEntry, boolean isNullEntry, Objec // defined by Access. boolean isDupeEntry = nextPos != null && newEntry.equalsEntryBytes(nextPos.getEntry()) || prevPos != null && newEntry.equalsEntryBytes(prevPos.getEntry()); if (isUnique() && !isNullEntry && isDupeEntry) { - throw new ConstraintViolationException(withErrorContext("New row " + Arrays.asList(row) + " violates uniqueness constraint for index")); + throw new ConstraintViolationException(withErrorContext("New row " + Arrays.toString(row) + " violates uniqueness constraint for index")); } change.setAddRow(newEntry, dataPage, idx, isDupeEntry); @@ -671,7 +671,7 @@ private Entry deleteRowImpl(Object[] row, RowIdImpl rowId) throws IOException { if (removedEntry != null) { ++_modCount; } else { - LOG.warn(withErrorContext("Failed removing index entry " + oldEntry + " for row: " + Arrays.asList(row))); + LOG.warn(withErrorContext("Failed removing index entry " + oldEntry + " for row: " + Arrays.toString(row))); } return removedEntry; } @@ -2511,7 +2511,7 @@ public void setEntryPrefix(byte[] entryPrefix) { @Override public List getEntries() { - return Collections.emptyList(); + return List.of(); } @Override diff --git a/src/main/java/io/github/spannm/jackcess/impl/IndexPageCache.java b/src/main/java/io/github/spannm/jackcess/impl/IndexPageCache.java index 5465496..713c0be 100644 --- a/src/main/java/io/github/spannm/jackcess/impl/IndexPageCache.java +++ b/src/main/java/io/github/spannm/jackcess/impl/IndexPageCache.java @@ -18,6 +18,8 @@ import static io.github.spannm.jackcess.impl.IndexData.*; +import io.github.spannm.jackcess.impl.IndexData.DataPage; +import io.github.spannm.jackcess.impl.IndexData.Entry; import org.apache.commons.lang3.builder.ToStringBuilder; import java.io.IOException; diff --git a/src/main/java/io/github/spannm/jackcess/impl/TableCreator.java b/src/main/java/io/github/spannm/jackcess/impl/TableCreator.java index cf706ee..d334535 100644 --- a/src/main/java/io/github/spannm/jackcess/impl/TableCreator.java +++ b/src/main/java/io/github/spannm/jackcess/impl/TableCreator.java @@ -140,7 +140,7 @@ public TableImpl createTable(TableBuilder table) throws IOException { _columns = table.getColumns(); _indexes = table.getIndexes(); if (_indexes == null) { - _indexes = Collections.emptyList(); + _indexes = List.of(); } validate(); diff --git a/src/main/java/io/github/spannm/jackcess/impl/TableImpl.java b/src/main/java/io/github/spannm/jackcess/impl/TableImpl.java index 71b1f34..a8725c6 100644 --- a/src/main/java/io/github/spannm/jackcess/impl/TableImpl.java +++ b/src/main/java/io/github/spannm/jackcess/impl/TableImpl.java @@ -1037,7 +1037,7 @@ protected static void writeTableDefinition(TableCreator creator) buffer.flip(); // write table buffer to database - writeTableDefinitionBuffer(buffer, creator.getTdefPageNumber(), creator, Collections.emptyList()); + writeTableDefinitionBuffer(buffer, creator.getTdefPageNumber(), creator, List.of()); } private static void writeTableDefinitionBuffer( @@ -2619,7 +2619,7 @@ private ByteBuffer newDataPage() throws IOException { // exposed for unit tests protected ByteBuffer createRow(Object[] rowArray, ByteBuffer buffer) throws IOException { - return createRow(rowArray, buffer, 0, Collections.emptyMap()); + return createRow(rowArray, buffer, 0, Map.of()); } /** diff --git a/src/main/java/io/github/spannm/jackcess/impl/complex/AttachmentColumnInfoImpl.java b/src/main/java/io/github/spannm/jackcess/impl/complex/AttachmentColumnInfoImpl.java index 1075070..13e2fa3 100644 --- a/src/main/java/io/github/spannm/jackcess/impl/complex/AttachmentColumnInfoImpl.java +++ b/src/main/java/io/github/spannm/jackcess/impl/complex/AttachmentColumnInfoImpl.java @@ -28,9 +28,7 @@ import java.io.*; import java.nio.ByteBuffer; import java.time.LocalDateTime; -import java.util.Arrays; import java.util.Date; -import java.util.HashSet; import java.util.Set; import java.util.zip.Deflater; import java.util.zip.DeflaterOutputStream; @@ -41,12 +39,11 @@ * * @author James Ahlborn */ -public class AttachmentColumnInfoImpl extends ComplexColumnInfoImpl - implements AttachmentColumnInfo { +public class AttachmentColumnInfoImpl extends ComplexColumnInfoImpl implements AttachmentColumnInfo { + /** some file formats which may not be worth re-compressing */ - private static final Set COMPRESSED_FORMATS = new HashSet<>( - Arrays.asList("jpg", "zip", "gz", "bz2", "z", "7z", "cab", "rar", - "mp3", "mpg")); + private static final Set COMPRESSED_FORMATS = Set.of( + "jpg", "zip", "gz", "bz2", "z", "7z", "cab", "rar", "mp3", "mpg"); private static final String FILE_NAME_COL_NAME = "FileName"; private static final String FILE_TYPE_COL_NAME = "FileType"; diff --git a/src/main/java/io/github/spannm/jackcess/impl/complex/ComplexColumnInfoImpl.java b/src/main/java/io/github/spannm/jackcess/impl/complex/ComplexColumnInfoImpl.java index 43871bf..e07445e 100644 --- a/src/main/java/io/github/spannm/jackcess/impl/complex/ComplexColumnInfoImpl.java +++ b/src/main/java/io/github/spannm/jackcess/impl/complex/ComplexColumnInfoImpl.java @@ -141,7 +141,7 @@ public List getRawValues(int complexValueFk, Iterator entryIter = getComplexValFkIter(complexValueFk, columnNames); if (!entryIter.hasNext()) { - return Collections.emptyList(); + return List.of(); } List values = new ArrayList<>(); @@ -157,7 +157,7 @@ public List getValues(ComplexValueForeignKey complexValueFk) throws IOException { List rawValues = getRawValues(complexValueFk.get()); if (rawValues.isEmpty()) { - return Collections.emptyList(); + return List.of(); } return toValues(complexValueFk, rawValues); @@ -237,7 +237,7 @@ public void deleteValues(Collection values) throws IOException { @Override public void deleteAllValues(int complexValueFk) throws IOException { - Iterator entryIter = getComplexValFkIter(complexValueFk, Collections.emptySet()); + Iterator entryIter = getComplexValFkIter(complexValueFk, Set.of()); while (entryIter.hasNext()) { entryIter.next(); entryIter.remove(); diff --git a/src/main/java/io/github/spannm/jackcess/impl/expr/ExpressionTokenizer.java b/src/main/java/io/github/spannm/jackcess/impl/expr/ExpressionTokenizer.java index b694a45..68b8dba 100644 --- a/src/main/java/io/github/spannm/jackcess/impl/expr/ExpressionTokenizer.java +++ b/src/main/java/io/github/spannm/jackcess/impl/expr/ExpressionTokenizer.java @@ -63,8 +63,7 @@ enum TokenType { } private static final byte[] CHAR_FLAGS = new byte[128]; - private static final Set TWO_CHAR_COMP_OPS = new HashSet<>( - Arrays.asList("<=", ">=", "<>")); + private static final Set TWO_CHAR_COMP_OPS = Set.of("<=", ">=", "<>"); static { setCharFlag(IS_OP_FLAG, '+', '-', '*', '/', '\\', '^', '&'); diff --git a/src/main/java/io/github/spannm/jackcess/impl/expr/Expressionator.java b/src/main/java/io/github/spannm/jackcess/impl/expr/Expressionator.java index 04bfd15..c05a5f2 100644 --- a/src/main/java/io/github/spannm/jackcess/impl/expr/Expressionator.java +++ b/src/main/java/io/github/spannm/jackcess/impl/expr/Expressionator.java @@ -60,8 +60,8 @@ public class Expressionator { setWordType(WordType.DELIM, ".", "!", ",", "(", ")"); } - private static final Collection TRUE_STRS = Arrays.asList("true", "yes", "on"); - private static final Collection FALSE_STRS = Arrays.asList("false", "no", "off"); + private static final Collection TRUE_STRS = List.of("true", "yes", "on"); + private static final Collection FALSE_STRS = List.of("false", "no", "off"); // Useful links: // - syntax: @@ -416,8 +416,8 @@ public String toString() { new OpType[] {LogOp.IMP}, new OpType[] {SpecOp.IN, SpecOp.NOT_IN, SpecOp.BETWEEN, SpecOp.NOT_BETWEEN}); - private static final Set REGEX_SPEC_CHARS = new HashSet<>( - Arrays.asList('\\', '.', '%', '=', '+', '$', '^', '|', '(', ')', '{', '}', '&', '[', ']', '*', '?')); + private static final Set REGEX_SPEC_CHARS = Set.of( + '\\', '.', '%', '=', '+', '$', '^', '|', '(', ')', '{', '}', '&', '[', ']', '*', '?'); // this is a regular expression which will never match any string private static final Pattern UNMATCHABLE_REGEX = Pattern.compile("(?!)"); @@ -729,7 +729,7 @@ private static List findParenExprs( Token t = buf.peekNext(); if (isDelim(t, CLOSE_PAREN)) { buf.next(); - return Collections.emptyList(); + return List.of(); } } diff --git a/src/main/java/io/github/spannm/jackcess/util/Joiner.java b/src/main/java/io/github/spannm/jackcess/util/Joiner.java index b6d540e..ae8a6e4 100644 --- a/src/main/java/io/github/spannm/jackcess/util/Joiner.java +++ b/src/main/java/io/github/spannm/jackcess/util/Joiner.java @@ -171,7 +171,7 @@ public EntryIterableBuilder findRows(Object[] fromRow) { * @return {@code true} if any "to" rows were deleted, {@code false} otherwise */ public boolean deleteRows(Map fromRow) throws IOException { - return deleteRowsImpl(findRows(fromRow).withColumnNames(Collections.emptySet()).iterator()); + return deleteRowsImpl(findRows(fromRow).withColumnNames(Set.of()).iterator()); } /** @@ -181,7 +181,7 @@ public boolean deleteRows(Map fromRow) throws IOException { * @return {@code true} if any "to" rows were deleted, {@code false} otherwise */ public boolean deleteRows(Object[] fromRow) throws IOException { - return deleteRowsImpl(findRows(fromRow).withColumnNames(Collections.emptySet()).iterator()); + return deleteRowsImpl(findRows(fromRow).withColumnNames(Set.of()).iterator()); } /** diff --git a/src/test/java/io/github/spannm/jackcess/CursorTest.java b/src/test/java/io/github/spannm/jackcess/CursorTest.java index 9ba450b..76d5bb3 100644 --- a/src/test/java/io/github/spannm/jackcess/CursorTest.java +++ b/src/test/java/io/github/spannm/jackcess/CursorTest.java @@ -181,10 +181,10 @@ public void testRowId() throws Exception { List sortedRowIds = new ArrayList<>(new TreeSet<>( - Arrays.asList(rowId1, rowId2, rowId3, RowIdImpl.FIRST_ROW_ID, + List.of(rowId1, rowId2, rowId3, RowIdImpl.FIRST_ROW_ID, RowIdImpl.LAST_ROW_ID))); - assertEquals(Arrays.asList(RowIdImpl.FIRST_ROW_ID, rowId1, rowId2, rowId3, + assertEquals(List.of(RowIdImpl.FIRST_ROW_ID, rowId1, rowId2, rowId3, RowIdImpl.LAST_ROW_ID), sortedRowIds); } @@ -1012,21 +1012,21 @@ private static void doTestMatcher(Table table, Cursor cursor, cursor.getCurrentRow()); } - assertEquals(Arrays.asList(createExpectedRow("id", 4, + assertEquals(List.of(createExpectedRow("id", 4, "value", "data" + 4)), RowFilterTest.toList( cursor.newIterable() .withMatchPattern("value", "data4") .withColumnMatcher(SimpleColumnMatcher.INSTANCE))); - assertEquals(Arrays.asList(createExpectedRow("id", 3, + assertEquals(List.of(createExpectedRow("id", 3, "value", "data" + 3)), RowFilterTest.toList( cursor.newIterable() .withMatchPattern("value", "DaTa3") .withColumnMatcher(CaseInsensitiveColumnMatcher.INSTANCE))); - assertEquals(Arrays.asList(createExpectedRow("id", 2, + assertEquals(List.of(createExpectedRow("id", 2, "value", "data" + 2)), RowFilterTest.toList( cursor.newIterable() @@ -1074,7 +1074,7 @@ public void testIndexCursorDelete() throws Exception { .stream().map(r -> r.getString("data")) .collect(Collectors.toList()); - assertEquals(Arrays.asList("baz11", "baz11-2"), expectedData); + assertEquals(List.of("baz11", "baz11-2"), expectedData); expectedData = new ArrayList<>(); for (Iterator iter = @@ -1098,7 +1098,7 @@ public void testIndexCursorDelete() throws Exception { } } - assertEquals(Arrays.asList("baz11", "baz11-2"), expectedData); + assertEquals(List.of("baz11", "baz11-2"), expectedData); expectedData = new ArrayList<>(); for (Row row : cursor.newEntryIterable(1) @@ -1120,12 +1120,12 @@ public void testCursorDelete() throws Exception { Cursor cursor = CursorBuilder.createCursor(t1); List expectedData = cursor.newIterable().withColumnNames( - Arrays.asList("otherfk1", "data")).stream() + List.of("otherfk1", "data")).stream() .filter(r -> r.get("otherfk1").equals(1)) .map(r -> r.getString("data")) .collect(Collectors.toList()); - assertEquals(Arrays.asList("baz11", "baz11-2"), expectedData); + assertEquals(List.of("baz11", "baz11-2"), expectedData); expectedData = new ArrayList<>(); for (Iterator iter = cursor.iterator(); iter.hasNext();) { @@ -1151,11 +1151,11 @@ public void testCursorDelete() throws Exception { } } - assertEquals(Arrays.asList("baz11", "baz11-2"), expectedData); + assertEquals(List.of("baz11", "baz11-2"), expectedData); expectedData = new ArrayList<>(); for (Row row : cursor.newIterable().withColumnNames( - Arrays.asList("otherfk1", "data"))) { + List.of("otherfk1", "data"))) { if (row.get("otherfk1").equals(1)) { expectedData.add(row.getString("data")); } @@ -1306,67 +1306,67 @@ public void testPartialIndexFind() throws Exception { .addIndex(DatabaseBuilder.newIndex("idx3").withColumns("data1", "num2", "key3")) .toTable(db); - Index idx = t.findIndexForColumns(Arrays.asList("data1"), + Index idx = t.findIndexForColumns(List.of("data1"), TableImpl.IndexFeature.ANY_MATCH); assertEquals("idx3", idx.getName()); - idx = t.findIndexForColumns(Arrays.asList("data1", "num2"), + idx = t.findIndexForColumns(List.of("data1", "num2"), TableImpl.IndexFeature.ANY_MATCH); assertEquals("idx3", idx.getName()); - idx = t.findIndexForColumns(Arrays.asList("data1", "num2", "key3"), + idx = t.findIndexForColumns(List.of("data1", "num2", "key3"), TableImpl.IndexFeature.ANY_MATCH); assertEquals("idx3", idx.getName()); - assertNull(t.findIndexForColumns(Arrays.asList("num2"), + assertNull(t.findIndexForColumns(List.of("num2"), TableImpl.IndexFeature.ANY_MATCH)); - assertNull(t.findIndexForColumns(Arrays.asList("data1", "key3"), + assertNull(t.findIndexForColumns(List.of("data1", "key3"), TableImpl.IndexFeature.ANY_MATCH)); - assertNull(t.findIndexForColumns(Arrays.asList("data1"), + assertNull(t.findIndexForColumns(List.of("data1"), TableImpl.IndexFeature.EXACT_MATCH)); DatabaseBuilder.newIndex("idx2") .withColumns("data1", "num2") .addToTable(t); - idx = t.findIndexForColumns(Arrays.asList("data1"), + idx = t.findIndexForColumns(List.of("data1"), TableImpl.IndexFeature.ANY_MATCH); assertEquals("idx2", idx.getName()); - idx = t.findIndexForColumns(Arrays.asList("data1", "num2"), + idx = t.findIndexForColumns(List.of("data1", "num2"), TableImpl.IndexFeature.ANY_MATCH); assertEquals("idx2", idx.getName()); - idx = t.findIndexForColumns(Arrays.asList("data1", "num2", "key3"), + idx = t.findIndexForColumns(List.of("data1", "num2", "key3"), TableImpl.IndexFeature.ANY_MATCH); assertEquals("idx3", idx.getName()); - assertNull(t.findIndexForColumns(Arrays.asList("num2"), + assertNull(t.findIndexForColumns(List.of("num2"), TableImpl.IndexFeature.ANY_MATCH)); - assertNull(t.findIndexForColumns(Arrays.asList("data1", "key3"), + assertNull(t.findIndexForColumns(List.of("data1", "key3"), TableImpl.IndexFeature.ANY_MATCH)); - assertNull(t.findIndexForColumns(Arrays.asList("data1"), + assertNull(t.findIndexForColumns(List.of("data1"), TableImpl.IndexFeature.EXACT_MATCH)); DatabaseBuilder.newIndex("idx1") .withColumns("data1") .addToTable(t); - idx = t.findIndexForColumns(Arrays.asList("data1"), + idx = t.findIndexForColumns(List.of("data1"), TableImpl.IndexFeature.ANY_MATCH); assertEquals("idx1", idx.getName()); - idx = t.findIndexForColumns(Arrays.asList("data1", "num2"), + idx = t.findIndexForColumns(List.of("data1", "num2"), TableImpl.IndexFeature.ANY_MATCH); assertEquals("idx2", idx.getName()); - idx = t.findIndexForColumns(Arrays.asList("data1", "num2", "key3"), + idx = t.findIndexForColumns(List.of("data1", "num2", "key3"), TableImpl.IndexFeature.ANY_MATCH); assertEquals("idx3", idx.getName()); - assertNull(t.findIndexForColumns(Arrays.asList("num2"), + assertNull(t.findIndexForColumns(List.of("num2"), TableImpl.IndexFeature.ANY_MATCH)); - assertNull(t.findIndexForColumns(Arrays.asList("data1", "key3"), + assertNull(t.findIndexForColumns(List.of("data1", "key3"), TableImpl.IndexFeature.ANY_MATCH)); db.close(); @@ -1391,7 +1391,7 @@ public void testPartialIndexLookup() throws Exception { .toTable(db); int id = 1; - for (String str : Arrays.asList("A", "B", "C", "D")) { + for (String str : List.of("A", "B", "C", "D")) { for (int i = 4; i >= 0; --i) { // for(int i = 0; i < 5; ++i) { for (int j = 1; j < 3; ++j) { diff --git a/src/test/java/io/github/spannm/jackcess/DatabaseTest.java b/src/test/java/io/github/spannm/jackcess/DatabaseTest.java index 79534b0..1559bea 100644 --- a/src/test/java/io/github/spannm/jackcess/DatabaseTest.java +++ b/src/test/java/io/github/spannm/jackcess/DatabaseTest.java @@ -182,7 +182,7 @@ public void testDeleteCurrentRow() throws Exception { Map row2 = createTestRowMap("Tim2"); Map row3 = createTestRowMap("Tim3"); Table table = db.getTable("Test"); - List> rows = Arrays.asList(row1, row2, row3); + List> rows = List.of(row1, row2, row3); table.addRowsFromMaps(rows); assertRowCount(3, table); @@ -336,7 +336,7 @@ public void testCurrency() throws Exception { foundValues.add(row.get("A")); } - assertEquals(Arrays.asList( + assertEquals(List.of( new BigDecimal("-2341234.0345"), new BigDecimal("37.0000"), new BigDecimal("10000.4500")), @@ -375,7 +375,7 @@ public void testGUID() throws Exception { foundValues.add(row.get("A")); } - assertEquals(Arrays.asList( + assertEquals(List.of( "{32A59F01-AA34-3E29-453F-4523453CD2E6}", "{32A59F01-AA34-3E29-453F-4523453CD2E6}", "{11111111-1111-1111-1111-111111111111}", @@ -423,12 +423,12 @@ public void testNumeric() throws Exception { foundBigValues.add(row.get("B")); } - assertEquals(Arrays.asList( + assertEquals(List.of( new BigDecimal("-1234.0345"), new BigDecimal("37.0000"), new BigDecimal("1000.4500")), foundSmallValues); - assertEquals(Arrays.asList( + assertEquals(List.of( new BigDecimal("23923434453436.36234219"), new BigDecimal("37.00000000"), new BigDecimal("-3452345321000.00000000")), @@ -507,17 +507,13 @@ public void testOverflow() throws Exception { table.getNextRow(); Map row = table.getNextRow(); - assertEquals(Arrays.asList( - null, "row3col3", null, null, null, null, null, - "row3col9", null), + assertEquals(Arrays.asList(null, "row3col3", null, null, null, null, null, "row3col9", null), new ArrayList<>(row.values())); table.getNextRow(); row = table.getNextRow(); - assertEquals(Arrays.asList( - null, "row5col2", null, null, null, null, null, null, - null), + assertEquals(Arrays.asList(null, "row5col2", null, null, null, null, null, null, null), new ArrayList<>(row.values())); table.reset(); @@ -609,14 +605,12 @@ public void testWriteAndReadDate() throws Exception { curTimeNoMillis *= 1000L; DateFormat df = new SimpleDateFormat("yyyyMMdd HH:mm:ss"); - List dates = - new ArrayList<>( - Arrays.asList( - df.parse("19801231 00:00:00"), - df.parse("19930513 14:43:27"), - null, - df.parse("20210102 02:37:00"), - new Date(curTimeNoMillis))); + List dates = new ArrayList<>(Arrays.asList( + df.parse("19801231 00:00:00"), + df.parse("19930513 14:43:27"), + null, + df.parse("20210102 02:37:00"), + new Date(curTimeNoMillis))); Calendar c = Calendar.getInstance(); for (int year = 1801; year < 2050; year += 3) { @@ -658,7 +652,7 @@ public void testWriteAndReadDate() throws Exception { public void testAncientDatesWrite() throws Exception { SimpleDateFormat sdf = DatabaseBuilder.createDateFormat("yyyy-MM-dd"); - List dates = Arrays.asList("1582-10-15", "1582-10-14", + List dates = List.of("1582-10-15", "1582-10-14", "1492-01-10", "1392-01-10"); for (final FileFormat fileFormat : SUPPORTED_FILEFORMATS) { @@ -694,7 +688,7 @@ public void testAncientDatesRead() throws Exception { SimpleDateFormat sdf = DatabaseBuilder.createDateFormat("yyyy-MM-dd"); sdf.getCalendar().setTimeZone(tz); - List dates = Arrays.asList("1582-10-15", "1582-10-14", + List dates = List.of("1582-10-15", "1582-10-14", "1492-01-10", "1392-01-10"); for (final TestDB testDB : TestDB.getSupportedForBasename(Basename.OLD_DATES)) { @@ -723,7 +717,7 @@ public void testSystemTable() throws Exception { Set sysTables = new TreeSet<>( String.CASE_INSENSITIVE_ORDER); sysTables.addAll( - Arrays.asList("MSysObjects", "MSysQueries", "MSysACES", + List.of("MSysObjects", "MSysQueries", "MSysACES", "MSysRelationships")); if (fileFormat == FileFormat.GENERIC_JET4) { @@ -735,12 +729,12 @@ public void testSystemTable() throws Exception { // v2003+ template files have no "MSysAccessObjects" table assertNull("file format: " + fileFormat, db.getSystemTable("MSysAccessObjects")); sysTables.addAll( - Arrays.asList("MSysNavPaneGroupCategories", + List.of("MSysNavPaneGroupCategories", "MSysNavPaneGroups", "MSysNavPaneGroupToObjects", "MSysNavPaneObjectIDs", "MSysAccessStorage")); if (fileFormat.ordinal() >= FileFormat.V2007.ordinal()) { sysTables.addAll( - Arrays.asList( + List.of( "MSysComplexColumns", "MSysComplexType_Attachment", "MSysComplexType_Decimal", "MSysComplexType_GUID", "MSysComplexType_IEEEDouble", "MSysComplexType_IEEESingle", @@ -923,9 +917,7 @@ public void testIterateTableNames() throws Exception { } assertTrue(sysCount > 4); - assertEquals(new HashSet<>(Arrays.asList("Table1", "Table2", "Table3", - "Table4")), - names); + assertEquals(Set.of("Table1", "Table2", "Table3", "Table4"), names); } for (final TestDB testDB : TestDB.getSupportedForBasename(Basename.LINKED)) { @@ -948,8 +940,7 @@ public void testIterateTableNames() throws Exception { names.add(tmd.getName()); } - assertEquals(new HashSet<>(Arrays.asList("Table1", "Table2")), - names); + assertEquals(Set.of("Table1", "Table2"), names); } } diff --git a/src/test/java/io/github/spannm/jackcess/IndexTest.java b/src/test/java/io/github/spannm/jackcess/IndexTest.java index f601765..583bad2 100644 --- a/src/test/java/io/github/spannm/jackcess/IndexTest.java +++ b/src/test/java/io/github/spannm/jackcess/IndexTest.java @@ -69,8 +69,7 @@ public void testByteCodeComparator() { byte[] b8 = new byte[] {(byte) 0xFF, (byte) 0x01}; List expectedList = Arrays.asList(b0, b1, b2, b3, b4, b5, b6, b7, b8); - SortedSet sortedSet = new TreeSet<>( - IndexData.BYTE_CODE_COMPARATOR); + SortedSet sortedSet = new TreeSet<>(IndexData.BYTE_CODE_COMPARATOR); sortedSet.addAll(expectedList); assertEquals(expectedList, new ArrayList<>(sortedSet)); @@ -131,7 +130,7 @@ public void testLogicalIndexes() throws Exception { assertTrue(fkIdx.isForeignKey()); assertSame(pkIdx.getIndexData(), fkIdx.getIndexData()); IndexData indexData = pkIdx.getIndexData(); - assertEquals(Arrays.asList(pkIdx, fkIdx), indexData.getIndexes()); + assertEquals(List.of(pkIdx, fkIdx), indexData.getIndexes()); assertSame(pkIdx, indexData.getPrimaryIndex()); table = (TableImpl) mdb.getTable("Table3"); @@ -152,7 +151,7 @@ public void testLogicalIndexes() throws Exception { assertTrue(fkIdx.isForeignKey()); assertSame(pkIdx.getIndexData(), fkIdx.getIndexData()); indexData = pkIdx.getIndexData(); - assertEquals(Arrays.asList(pkIdx, fkIdx), indexData.getIndexes()); + assertEquals(List.of(pkIdx, fkIdx), indexData.getIndexes()); assertSame(pkIdx, indexData.getPrimaryIndex()); } } @@ -340,8 +339,8 @@ public void testUniqueEntryCount() throws Exception { assertEquals(2, indA.getUniqueEntryCount()); assertEquals(2, indB.getUniqueEntryCount()); - List bElems = Arrays.asList("bar", null, "baz", "argle", null, - "bazzle", "37", "bar", "bar", "BAZ"); + List bElems = Arrays.asList( + "bar", null, "baz", "argle", null, "bazzle", "37", "bar", "bar", "BAZ"); for (int i = 0; i < 10; ++i) { table.addRow("foo" + i, bElems.get(i), (byte) 42 + i, (short) 53 + i, diff --git a/src/test/java/io/github/spannm/jackcess/LocalDateTimeTest.java b/src/test/java/io/github/spannm/jackcess/LocalDateTimeTest.java index 9936471..bf31597 100644 --- a/src/test/java/io/github/spannm/jackcess/LocalDateTimeTest.java +++ b/src/test/java/io/github/spannm/jackcess/LocalDateTimeTest.java @@ -60,14 +60,12 @@ public void testWriteAndReadLocalDate() throws Exception { curTimeNoMillis *= 1000L; DateFormat df = new SimpleDateFormat("yyyyMMdd HH:mm:ss"); - List dates = - new ArrayList<>( - Arrays.asList( - df.parse("19801231 00:00:00"), - df.parse("19930513 14:43:27"), - null, - df.parse("20210102 02:37:00"), - new Date(curTimeNoMillis))); + List dates = new ArrayList<>(Arrays.asList( + df.parse("19801231 00:00:00"), + df.parse("19930513 14:43:27"), + null, + df.parse("20210102 02:37:00"), + new Date(curTimeNoMillis))); Calendar c = Calendar.getInstance(); for (int year = 1801; year < 2050; year += 3) { @@ -111,8 +109,7 @@ public void testAncientLocalDates() throws Exception { ZoneId zoneId = ZoneId.of("America/New_York"); DateTimeFormatter sdf = DateTimeFormatter.ofPattern("uuuu-MM-dd"); - List dates = Arrays.asList("1582-10-15", "1582-10-14", - "1492-01-10", "1392-01-10"); + List dates = List.of("1582-10-15", "1582-10-14", "1492-01-10", "1392-01-10"); for (final FileFormat fileFormat : SUPPORTED_FILEFORMATS) { Database db = createMem(fileFormat); @@ -227,13 +224,11 @@ public void testWriteAndReadTemporals() throws Exception { curTimeNoMillis *= 1000L; DateFormat df = new SimpleDateFormat("yyyyMMdd HH:mm:ss"); - List tmpDates = - new ArrayList<>( - Arrays.asList( - df.parse("19801231 00:00:00"), - df.parse("19930513 14:43:27"), - df.parse("20210102 02:37:00"), - new Date(curTimeNoMillis))); + List tmpDates = new ArrayList<>(List.of( + df.parse("19801231 00:00:00"), + df.parse("19930513 14:43:27"), + df.parse("20210102 02:37:00"), + new Date(curTimeNoMillis))); List objs = new ArrayList<>(); List expected = new ArrayList<>(); diff --git a/src/test/java/io/github/spannm/jackcess/PropertiesTest.java b/src/test/java/io/github/spannm/jackcess/PropertiesTest.java index 90f3b9a..da0052a 100644 --- a/src/test/java/io/github/spannm/jackcess/PropertiesTest.java +++ b/src/test/java/io/github/spannm/jackcess/PropertiesTest.java @@ -87,7 +87,7 @@ public void testPropertyMaps() throws Exception { } } - assertEquals(Arrays.asList(defMap.get("foo"), defMap.get("baz"), + assertEquals(List.of(defMap.get("foo"), defMap.get("baz"), colMap.get("buzz")), props); } diff --git a/src/test/java/io/github/spannm/jackcess/RelationshipTest.java b/src/test/java/io/github/spannm/jackcess/RelationshipTest.java index 18bfb6f..eb42b25 100644 --- a/src/test/java/io/github/spannm/jackcess/RelationshipTest.java +++ b/src/test/java/io/github/spannm/jackcess/RelationshipTest.java @@ -24,7 +24,6 @@ import junit.framework.TestCase; import java.util.ArrayList; -import java.util.Arrays; import java.util.Comparator; import java.util.List; @@ -51,10 +50,10 @@ public void testTwoTables() throws Exception { Relationship rel = rels.get(0); assertEquals("Table2Table1", rel.getName()); assertEquals(t2, rel.getFromTable()); - assertEquals(Arrays.asList(t2.getColumn("id")), + assertEquals(List.of(t2.getColumn("id")), rel.getFromColumns()); assertEquals(t1, rel.getToTable()); - assertEquals(Arrays.asList(t1.getColumn("otherfk1")), + assertEquals(List.of(t1.getColumn("otherfk1")), rel.getToColumns()); assertTrue(rel.hasReferentialIntegrity()); assertEquals(4096, ((RelationshipImpl) rel).getFlags()); @@ -70,10 +69,10 @@ public void testTwoTables() throws Exception { rel = rels.get(0); assertEquals("Table3Table1", rel.getName()); assertEquals(t3, rel.getFromTable()); - assertEquals(Arrays.asList(t3.getColumn("id")), + assertEquals(List.of(t3.getColumn("id")), rel.getFromColumns()); assertEquals(t1, rel.getToTable()); - assertEquals(Arrays.asList(t1.getColumn("otherfk2")), + assertEquals(List.of(t1.getColumn("otherfk2")), rel.getToColumns()); assertTrue(rel.hasReferentialIntegrity()); assertEquals(256, ((RelationshipImpl) rel).getFlags()); diff --git a/src/test/java/io/github/spannm/jackcess/TableTest.java b/src/test/java/io/github/spannm/jackcess/TableTest.java index 1414577..e0d10f2 100644 --- a/src/test/java/io/github/spannm/jackcess/TableTest.java +++ b/src/test/java/io/github/spannm/jackcess/TableTest.java @@ -104,10 +104,10 @@ public void testUnicodeCompression() throws Exception { assertTrue(Arrays.equals(toBytes(buf2[i]), toBytes(bufCmp2[i]))); } - assertEquals(Arrays.asList(small, large), - Arrays.asList(decodeColumns(bufCmp1))); - assertEquals(Arrays.asList(smallNotAscii, largeNotAscii), - Arrays.asList(decodeColumns(bufCmp2))); + assertEquals(List.of(small, large), + List.of(decodeColumns(bufCmp1))); + assertEquals(List.of(smallNotAscii, largeNotAscii), + List.of(decodeColumns(bufCmp2))); } diff --git a/src/test/java/io/github/spannm/jackcess/TableUpdaterTest.java b/src/test/java/io/github/spannm/jackcess/TableUpdaterTest.java index 7d9c94f..73fe364 100644 --- a/src/test/java/io/github/spannm/jackcess/TableUpdaterTest.java +++ b/src/test/java/io/github/spannm/jackcess/TableUpdaterTest.java @@ -25,7 +25,10 @@ import io.github.spannm.jackcess.impl.TableImpl; import junit.framework.TestCase; -import java.util.*; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; /** * @@ -128,9 +131,9 @@ private void doTestUpdating(Database db, boolean oneToOne, boolean enforce, Stri assertEquals(relationshipName, rel.getName()); } assertSame(t1, rel.getFromTable()); - assertEquals(Arrays.asList(t1.getColumn("id")), rel.getFromColumns()); + assertEquals(List.of(t1.getColumn("id")), rel.getFromColumns()); assertSame(t2, rel.getToTable()); - assertEquals(Arrays.asList(t2.getColumn("id2")), rel.getToColumns()); + assertEquals(List.of(t2.getColumn("id2")), rel.getToColumns()); assertEquals(oneToOne, rel.isOneToOne()); assertEquals(enforce, rel.hasReferentialIntegrity()); assertEquals(enforce, rel.cascadeDeletes()); diff --git a/src/test/java/io/github/spannm/jackcess/TestUtil.java b/src/test/java/io/github/spannm/jackcess/TestUtil.java index 06424e0..1321e33 100644 --- a/src/test/java/io/github/spannm/jackcess/TestUtil.java +++ b/src/test/java/io/github/spannm/jackcess/TestUtil.java @@ -260,7 +260,7 @@ public static RowImpl createExpectedRow(Object... rowElements) { } public static List createExpectedTable(Row... rows) { - return Arrays.asList(rows); + return List.of(rows); } public static void dumpDatabase(Database mdb) throws Exception { diff --git a/src/test/java/io/github/spannm/jackcess/impl/CalcFieldTest.java b/src/test/java/io/github/spannm/jackcess/impl/CalcFieldTest.java index 52e0640..796e0e3 100644 --- a/src/test/java/io/github/spannm/jackcess/impl/CalcFieldTest.java +++ b/src/test/java/io/github/spannm/jackcess/impl/CalcFieldTest.java @@ -26,7 +26,6 @@ import java.math.BigDecimal; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.Map; @@ -151,7 +150,7 @@ public void testReadCalcFields() throws Exception { rows.add(r.entrySet().toString()); } - List expectedRows = Arrays.asList( + List expectedRows = List.of( "[ID=1, FirstName=Bruce, LastName=Wayne, LastFirst=Wayne, Bruce, City=Gotham, LastFirstLen=12, Salary=1000000.0000, MonthlySalary=83333.3333, IsRich=true, AllNames=Wayne, Bruce=Wayne, Bruce, WeeklySalary=19230.7692307692, SalaryTest=1000000.0000, BoolTest=true, Popularity=50.325000, DecimalTest=50.325000, FloatTest=2583.2092, BigNumTest=56505085819.424791296572280180]", "[ID=2, FirstName=Bart, LastName=Simpson, LastFirst=Simpson, Bart, City=Springfield, LastFirstLen=13, Salary=-1.0000, MonthlySalary=-0.0833, IsRich=false, AllNames=Simpson, Bart=Simpson, Bart, WeeklySalary=-0.0192307692307692, SalaryTest=-1.0000, BoolTest=true, Popularity=-36.222200, DecimalTest=-36.222200, FloatTest=0.0035889593, BigNumTest=-0.0784734499180612994241100748]", "[ID=3, FirstName=John, LastName=Doe, LastFirst=Doe, John, City=Nowhere, LastFirstLen=9, Salary=0.0000, MonthlySalary=0.0000, IsRich=false, AllNames=Doe, John=Doe, John, WeeklySalary=0, SalaryTest=0.0000, BoolTest=true, Popularity=0.012300, DecimalTest=0.012300, FloatTest=0.0, BigNumTest=0E-8]", diff --git a/src/test/java/io/github/spannm/jackcess/impl/IndexCodesTest.java b/src/test/java/io/github/spannm/jackcess/impl/IndexCodesTest.java index 7f8f5f6..4e54de9 100644 --- a/src/test/java/io/github/spannm/jackcess/impl/IndexCodesTest.java +++ b/src/test/java/io/github/spannm/jackcess/impl/IndexCodesTest.java @@ -452,7 +452,7 @@ public void x_testReverseIsoMdb2010() throws Exception { String crazyCode = ""; if (crazyCodes != null) { if (crazyCodes.length != 1 || !"A0".equals(crazyCodes[0])) { - throw new RuntimeException("CC " + Arrays.asList(crazyCodes)); + throw new RuntimeException("CC " + Arrays.toString(crazyCodes)); } crazyCode = "1"; } @@ -619,7 +619,7 @@ public void x_testReverseIsoMdb() throws Exception { String crazyCode = ""; if (crazyCodes != null) { if (crazyCodes.length != 1 || !"A0".equals(crazyCodes[0])) { - throw new RuntimeException("CC " + Arrays.asList(crazyCodes)); + throw new RuntimeException("CC " + Arrays.toString(crazyCodes)); } crazyCode = "1"; } diff --git a/src/test/java/io/github/spannm/jackcess/impl/LongValueTest.java b/src/test/java/io/github/spannm/jackcess/impl/LongValueTest.java index 9275eda..fb0150b 100644 --- a/src/test/java/io/github/spannm/jackcess/impl/LongValueTest.java +++ b/src/test/java/io/github/spannm/jackcess/impl/LongValueTest.java @@ -167,8 +167,7 @@ public void testManyMemos() throws Exception { Iterator expIter = expectedRows.iterator(); for (Map row : bigTable) { Object[] expectedRow = expIter.next(); - assertEquals(Arrays.asList(expectedRow), - new ArrayList<>(row.values())); + assertEquals(Arrays.asList(expectedRow), new ArrayList<>(row.values())); } db.close(); diff --git a/src/test/java/io/github/spannm/jackcess/impl/TopoSorterTest.java b/src/test/java/io/github/spannm/jackcess/impl/TopoSorterTest.java index 10548fd..6701b64 100644 --- a/src/test/java/io/github/spannm/jackcess/impl/TopoSorterTest.java +++ b/src/test/java/io/github/spannm/jackcess/impl/TopoSorterTest.java @@ -31,17 +31,17 @@ public TopoSorterTest(String name) { } public void testTopoSort() throws Exception { - doTopoTest(Arrays.asList("A", "B", "C"), - Arrays.asList("A", "B", "C")); + doTopoTest(List.of("A", "B", "C"), + List.of("A", "B", "C")); - doTopoTest(Arrays.asList("B", "A", "C"), - Arrays.asList("A", "B", "C"), + doTopoTest(List.of("B", "A", "C"), + List.of("A", "B", "C"), "B", "C", "A", "B"); try { - doTopoTest(Arrays.asList("B", "A", "C"), - Arrays.asList("C", "B", "A"), + doTopoTest(List.of("B", "A", "C"), + List.of("C", "B", "A"), "B", "C", "A", "B", "C", "A"); @@ -52,8 +52,8 @@ public void testTopoSort() throws Exception { } try { - doTopoTest(Arrays.asList("B", "A", "C"), - Arrays.asList("C", "B", "A"), + doTopoTest(List.of("B", "A", "C"), + List.of("C", "B", "A"), "B", "D"); fail("IllegalStateException should have been thrown"); } catch (IllegalStateException expected) { @@ -61,36 +61,36 @@ public void testTopoSort() throws Exception { assertTrue(expected.getMessage().startsWith("Unknown descendent")); } - doTopoTest(Arrays.asList("B", "D", "A", "C"), - Arrays.asList("D", "A", "B", "C"), + doTopoTest(List.of("B", "D", "A", "C"), + List.of("D", "A", "B", "C"), "B", "C", "A", "B"); - doTopoTest(Arrays.asList("B", "D", "A", "C"), - Arrays.asList("A", "D", "B", "C"), + doTopoTest(List.of("B", "D", "A", "C"), + List.of("A", "D", "B", "C"), "B", "C", "A", "B", "A", "D"); - doTopoTest(Arrays.asList("B", "D", "A", "C"), - Arrays.asList("D", "A", "C", "B"), + doTopoTest(List.of("B", "D", "A", "C"), + List.of("D", "A", "C", "B"), "D", "A", "C", "B"); - doTopoTest(Arrays.asList("B", "D", "A", "C"), - Arrays.asList("D", "C", "A", "B"), + doTopoTest(List.of("B", "D", "A", "C"), + List.of("D", "C", "A", "B"), "D", "A", "C", "B", "C", "A"); - doTopoTest(Arrays.asList("B", "D", "A", "C"), - Arrays.asList("C", "D", "A", "B"), + doTopoTest(List.of("B", "D", "A", "C"), + List.of("C", "D", "A", "B"), "D", "A", "C", "B", "C", "D"); - doTopoTest(Arrays.asList("B", "D", "A", "C"), - Arrays.asList("D", "A", "C", "B"), + doTopoTest(List.of("B", "D", "A", "C"), + List.of("D", "A", "C", "B"), "D", "A", "C", "B", "D", "B"); @@ -137,7 +137,7 @@ private static class TestTopoSorter extends TopoSorter { void addDescendents(String from, String... tos) { List descs = _descMap.computeIfAbsent(from, k -> new ArrayList<>()); - descs.addAll(Arrays.asList(tos)); + descs.addAll(List.of(tos)); } @Override diff --git a/src/test/java/io/github/spannm/jackcess/util/ColumnFormatterTest.java b/src/test/java/io/github/spannm/jackcess/util/ColumnFormatterTest.java index 2e27666..20b52e7 100644 --- a/src/test/java/io/github/spannm/jackcess/util/ColumnFormatterTest.java +++ b/src/test/java/io/github/spannm/jackcess/util/ColumnFormatterTest.java @@ -24,7 +24,6 @@ import junit.framework.TestCase; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; /** @@ -68,7 +67,7 @@ public void testFormat() throws Exception { found.add(d3Fmt.getRowValue(r)); } - assertEquals(Arrays.asList( + assertEquals(List.of( "FOxxOBAR", "3.7E+1", "$0.03", "37xx", "4.5E+3", "$4,500.00", "FOxxOBARBAZ", "-3.7E+1", "($37.13)", @@ -91,7 +90,7 @@ public void testFormat() throws Exception { found.add(d3Fmt.getRowValue(r)); } - assertEquals(Arrays.asList( + assertEquals(List.of( "foobar", "37", "12:43:12 AM", "3.70E+1", "4500", "4/26/1912", "foobarbaz", "-37", "11/23/1899 3:07:12 AM", diff --git a/src/test/java/io/github/spannm/jackcess/util/ImportTest.java b/src/test/java/io/github/spannm/jackcess/util/ImportTest.java index 4ffbec6..4bb1994 100644 --- a/src/test/java/io/github/spannm/jackcess/util/ImportTest.java +++ b/src/test/java/io/github/spannm/jackcess/util/ImportTest.java @@ -31,7 +31,6 @@ import java.sql.ResultSetMetaData; import java.sql.Types; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.Map; @@ -56,7 +55,7 @@ public void testImportFromFile() throws Exception { for (Column c : t.getColumns()) { colNames.add(c.getName()); } - assertEquals(Arrays.asList("Test1", "Test2", "Test3"), colNames); + assertEquals(List.of("Test1", "Test2", "Test3"), colNames); List> expectedRows = createExpectedTable( @@ -146,7 +145,7 @@ public Object[] filterRow(Object[] row) { for (Column c : t.getColumns()) { colNames.add(c.getName()); } - assertEquals(Arrays.asList("Test1", "Test2", "Test3"), colNames); + assertEquals(List.of("Test1", "Test2", "Test3"), colNames); expectedRows = createExpectedTable( @@ -181,7 +180,7 @@ public void testImportFromFileWithOnlyHeaders() throws Exception { for (Column c : t.getColumns()) { colNames.add(c.getName()); } - assertEquals(Arrays.asList( + assertEquals(List.of( "RESULT_PHYS_ID", "FIRST", "MIDDLE", "LAST", "OUTLIER", "RANK", "CLAIM_COUNT", "PROCEDURE_COUNT", "WEIGHTED_CLAIM_COUNT", "WEIGHTED_PROCEDURE_COUNT"), diff --git a/src/test/java/io/github/spannm/jackcess/util/JoinerTest.java b/src/test/java/io/github/spannm/jackcess/util/JoinerTest.java index 0ea0cdb..e706c53 100644 --- a/src/test/java/io/github/spannm/jackcess/util/JoinerTest.java +++ b/src/test/java/io/github/spannm/jackcess/util/JoinerTest.java @@ -80,8 +80,7 @@ public void testJoiner() throws Exception { private static void doTestJoiner( Joiner join, Map> expectedData) throws Exception { - final Set colNames = new HashSet<>( - Arrays.asList("id", "data")); + final Set colNames = Set.of("id", "data"); Joiner revJoin = join.createReverse(); for (Row row : join.getFromTable()) { diff --git a/src/test/java/io/github/spannm/jackcess/util/PatternColumnPredicateTest.java b/src/test/java/io/github/spannm/jackcess/util/PatternColumnPredicateTest.java index 8e3c72e..372e32d 100644 --- a/src/test/java/io/github/spannm/jackcess/util/PatternColumnPredicateTest.java +++ b/src/test/java/io/github/spannm/jackcess/util/PatternColumnPredicateTest.java @@ -23,7 +23,6 @@ import io.github.spannm.jackcess.Database.FileFormat; import junit.framework.TestCase; -import java.util.Arrays; import java.util.List; import java.util.function.Predicate; import java.util.stream.Collectors; @@ -45,47 +44,47 @@ public void testRegexPredicate() throws Exception { Table t = db.getTable("Test"); assertEquals( - Arrays.asList("Foo", "some row", "aNoThEr row", "nonsense"), + List.of("Foo", "some row", "aNoThEr row", "nonsense"), findRowsByPattern( t, PatternColumnPredicate.forJavaRegex(".*o.*"))); assertEquals( - Arrays.asList("Bar", "0102", "FOO", "BAR", "67", "bunch_13_data", "42 is the ANSWER", "[try] matching t.h+i}s"), + List.of("Bar", "0102", "FOO", "BAR", "67", "bunch_13_data", "42 is the ANSWER", "[try] matching t.h+i}s"), findRowsByPattern( t, PatternColumnPredicate.forJavaRegex(".*o.*").negate())); assertEquals( - Arrays.asList("Foo", "some row", "FOO", "aNoThEr row", "nonsense"), + List.of("Foo", "some row", "FOO", "aNoThEr row", "nonsense"), findRowsByPattern( t, PatternColumnPredicate.forAccessLike("*o*"))); assertEquals( - Arrays.asList("0102", "67", "bunch_13_data", "42 is the ANSWER"), + List.of("0102", "67", "bunch_13_data", "42 is the ANSWER"), findRowsByPattern( t, PatternColumnPredicate.forAccessLike("*##*"))); assertEquals( - Arrays.asList("42 is the ANSWER"), + List.of("42 is the ANSWER"), findRowsByPattern( t, PatternColumnPredicate.forAccessLike("## *"))); assertEquals( - Arrays.asList("Foo"), + List.of("Foo"), findRowsByPattern( t, PatternColumnPredicate.forSqlLike("F_o"))); assertEquals( - Arrays.asList("Foo", "FOO"), + List.of("Foo", "FOO"), findRowsByPattern( t, PatternColumnPredicate.forSqlLike("F_o", true))); assertEquals( - Arrays.asList("[try] matching t.h+i}s"), + List.of("[try] matching t.h+i}s"), findRowsByPattern( t, PatternColumnPredicate.forSqlLike("[try] % t.h+i}s"))); assertEquals( - Arrays.asList("bunch_13_data"), + List.of("bunch_13_data"), findRowsByPattern( t, PatternColumnPredicate.forSqlLike("bunch\\_%\\_data"))); diff --git a/src/test/java/io/github/spannm/jackcess/util/RowFilterTest.java b/src/test/java/io/github/spannm/jackcess/util/RowFilterTest.java index e95c7da..6caa316 100644 --- a/src/test/java/io/github/spannm/jackcess/util/RowFilterTest.java +++ b/src/test/java/io/github/spannm/jackcess/util/RowFilterTest.java @@ -24,7 +24,6 @@ import junit.framework.TestCase; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; /** @@ -48,42 +47,42 @@ public void testFilter() throws Exception { Row row4 = createExpectedRow(ID_COL, 4, COL1, "foo", COL2, 13, COL3, null); Row row5 = createExpectedRow(ID_COL, 5, COL1, "bla", COL2, 13, COL3, "bar"); - List rows = Arrays.asList(row0, row1, row2, row3, row4, row5); + List rows = List.of(row0, row1, row2, row3, row4, row5); ColumnImpl testCol = new ColumnImpl(null, COL1, DataType.TEXT, 0, 0, 0) { }; - assertEquals(Arrays.asList(row0, row2, row4), + assertEquals(List.of(row0, row2, row4), toList(RowFilter.matchPattern(testCol, "foo").apply(rows))); - assertEquals(Arrays.asList(row1, row3, row5), + assertEquals(List.of(row1, row3, row5), toList(RowFilter.invert( RowFilter.matchPattern( testCol, "foo")) .apply(rows))); - assertEquals(Arrays.asList(row0, row2, row4), + assertEquals(List.of(row0, row2, row4), toList(RowFilter.matchPattern( createExpectedRow(COL1, "foo")) .apply(rows))); - assertEquals(Arrays.asList(row0, row2), + assertEquals(List.of(row0, row2), toList(RowFilter.matchPattern( createExpectedRow(COL1, "foo", COL3, "bar")) .apply(rows))); - assertEquals(Arrays.asList(row4), + assertEquals(List.of(row4), toList(RowFilter.matchPattern( createExpectedRow(COL1, "foo", COL3, null)) .apply(rows))); - assertEquals(Arrays.asList(row0, row4, row5), + assertEquals(List.of(row0, row4, row5), toList(RowFilter.matchPattern( createExpectedRow(COL2, 13)) .apply(rows))); - assertEquals(Arrays.asList(row1), + assertEquals(List.of(row1), toList(RowFilter.matchPattern(row1) .apply(rows))); assertEquals(rows, toList(RowFilter.apply(null, rows))); - assertEquals(Arrays.asList(row1), + assertEquals(List.of(row1), toList(RowFilter.apply(RowFilter.matchPattern(row1), rows))); }