From 1437029eb38d6b2043fc93c9ec430533ad082beb Mon Sep 17 00:00:00 2001 From: Jonathan Shook Date: Thu, 2 Jun 2022 17:12:36 -0500 Subject: [PATCH] remove pattern matching in switch syntax and remove --enable-preview completely. It is too onerous for users at runtime. --- .../CQLD4PreparedStmtDiagnostics.java | 43 +++++++++---------- mvn-defaults/pom.xml | 13 ++---- 2 files changed, 24 insertions(+), 32 deletions(-) diff --git a/adapter-cqld4/src/main/java/io/nosqlbench/adapter/cqld4/opdispensers/CQLD4PreparedStmtDiagnostics.java b/adapter-cqld4/src/main/java/io/nosqlbench/adapter/cqld4/opdispensers/CQLD4PreparedStmtDiagnostics.java index f8908d266..3aae9270c 100644 --- a/adapter-cqld4/src/main/java/io/nosqlbench/adapter/cqld4/opdispensers/CQLD4PreparedStmtDiagnostics.java +++ b/adapter-cqld4/src/main/java/io/nosqlbench/adapter/cqld4/opdispensers/CQLD4PreparedStmtDiagnostics.java @@ -54,42 +54,42 @@ public class CQLD4PreparedStmtDiagnostics { public static BoundStatement bindStatement(BoundStatement bound, CqlIdentifier colname, Object colval, DataType coltype) { - return switch (coltype) { - case PrimitiveType pt -> switch (pt.getProtocolCode()) { + if (coltype instanceof PrimitiveType pt) { + return switch (pt.getProtocolCode()) { case CUSTOM -> throw new OpConfigError("Error with Custom DataType"); case ASCII, VARCHAR -> bound.setString(colname, (String) colval); - case BIGINT, COUNTER ->bound.setLong(colname, (long) colval); + case BIGINT, COUNTER -> bound.setLong(colname, (long) colval); case BLOB -> bound.setByteBuffer(colname, (ByteBuffer) colval); case BOOLEAN -> bound.setBoolean(colname, (boolean) colval); - case DECIMAL ->bound.setBigDecimal(colname, (BigDecimal) colval); - case DOUBLE ->bound.setDouble(colname, (double) colval); - case FLOAT ->bound.setFloat(colname, (float) colval); + case DECIMAL -> bound.setBigDecimal(colname, (BigDecimal) colval); + case DOUBLE -> bound.setDouble(colname, (double) colval); + case FLOAT -> bound.setFloat(colname, (float) colval); case INT, SMALLINT, TINYINT -> bound.setInt(colname, (int) colval); case TIMESTAMP -> bound.setInstant(colname, (Instant) colval); - case TIMEUUID, UUID ->bound.setUuid(colname, (UUID) colval); - case VARINT ->bound.setBigInteger(colname, (BigInteger) colval); - case INET ->bound.setInetAddress(colname, (InetAddress) colval); - case DATE ->bound.setLocalDate(colname, (LocalDate) colval); + case TIMEUUID, UUID -> bound.setUuid(colname, (UUID) colval); + case VARINT -> bound.setBigInteger(colname, (BigInteger) colval); + case INET -> bound.setInetAddress(colname, (InetAddress) colval); + case DATE -> bound.setLocalDate(colname, (LocalDate) colval); case TIME -> bound.setLocalTime(colname, (LocalTime) colval); - case DURATION ->bound.setCqlDuration(colname, (CqlDuration) colval); - case LIST -> bound.setList(colname,(List)colval,((List)colval).get(0).getClass()); + case DURATION -> bound.setCqlDuration(colname, (CqlDuration) colval); + case LIST -> bound.setList(colname, (List) colval, ((List) colval).get(0).getClass()); case MAP -> { Map map = (Map) colval; Set entries = map.entrySet(); Optional first = entries.stream().findFirst(); if (first.isPresent()) { - yield bound.setMap(colname,map,first.get().getKey().getClass(),first.get().getValue().getClass()); + yield bound.setMap(colname, map, first.get().getKey().getClass(), first.get().getValue().getClass()); } else { - yield bound.setMap(colname,map,Object.class,Object.class); + yield bound.setMap(colname, map, Object.class, Object.class); } } case SET -> { - Set set = (Set)colval; + Set set = (Set) colval; Optional first = set.stream().findFirst(); if (first.isPresent()) { - yield bound.setSet(colname,set,first.get().getClass()); + yield bound.setSet(colname, set, first.get().getClass()); } else { - yield bound.setSet(colname,Set.of(),Object.class); + yield bound.setSet(colname, Set.of(), Object.class); } } case UDT -> { @@ -98,13 +98,12 @@ public class CQLD4PreparedStmtDiagnostics { } case TUPLE -> { TupleValue tuple = (TupleValue) colval; - yield bound.setTupleValue(colname,tuple); + yield bound.setTupleValue(colname, tuple); } - default-> throw new RuntimeException("Unknown CQL type for diagnostic (type:'" + coltype +"',code:'" + coltype.getProtocolCode()+"'"); + default -> throw new RuntimeException("Unknown CQL type for diagnostic (type:'" + coltype + "',code:'" + coltype.getProtocolCode() + "'"); }; - - default -> throw new IllegalStateException("Unexpected value: " + coltype); - }; + } + throw new IllegalStateException("Unexpected value: " + coltype); } diff --git a/mvn-defaults/pom.xml b/mvn-defaults/pom.xml index f27eed01c..73fd7a7ce 100644 --- a/mvn-defaults/pom.xml +++ b/mvn-defaults/pom.xml @@ -462,10 +462,9 @@ 17 17 - --enable-preview + + - - @@ -474,9 +473,6 @@ maven-surefire-plugin 3.0.0-M6 - --enable-preview - - **/*Integrated*Test*.java **/*IntegrationTest.java @@ -505,8 +501,6 @@ - --enable-preview - 1 false @@ -537,9 +531,8 @@ -Xdoclint:none - --enable-preview - + none