Skip to content

Commit b6fa61e

Browse files
committed
edit
1 parent 8199e14 commit b6fa61e

File tree

7 files changed

+29
-50
lines changed

7 files changed

+29
-50
lines changed

src/main/java/org/usf/jquery/core/AsciiResultMapper.java

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -94,20 +94,10 @@ public Void map(ResultSet rs) throws SQLException {
9494
}
9595

9696
private static boolean isNumer(int type) {
97-
switch (type) {
98-
case BOOLEAN:
99-
case BIT:
100-
case TINYINT:
101-
case SMALLINT:
102-
case INTEGER:
103-
case BIGINT:
104-
case REAL:
105-
case FLOAT:
106-
case DOUBLE:
107-
case NUMERIC:
108-
case DECIMAL: return true;
109-
default: return false;
110-
}
97+
return switch (type) {
98+
case BOOLEAN, BIT, TINYINT, SMALLINT, INTEGER, BIGINT, REAL, FLOAT, DOUBLE, NUMERIC, DECIMAL: yield true;
99+
default: yield false;
100+
};
111101
}
112102

113103
private static Object[] array(int size, String v) {

src/main/java/org/usf/jquery/web/view/Chart2DView.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import static java.lang.System.lineSeparator;
55
import static java.nio.file.Files.readString;
66
import static java.util.Map.ofEntries;
7-
import static java.util.stream.Collectors.toList;
87
import static org.usf.jquery.core.SqlStringBuilder.doubleQuote;
98
import static org.usf.jquery.web.view.WebViewMapper.DataTable.fromMetaData;
109
import static org.usf.jquery.web.view.WebViewMapper.WebType.NUMBER;
@@ -54,7 +53,7 @@ public Void map(ResultSet rs) throws SQLException {
5453
var sb1 = new StringBuilder();
5554
var xAxis = dt.getXAxis();
5655
sb1.append("[").append(doubleQuote(xAxis.getType().typeName())).append(",").append(doubleQuote(xAxis.getName())).append("]");
57-
var cols = dt.getRows().stream().flatMap(c-> c.stream().skip(1)).map(Entry::getKey).distinct().sorted().collect(toList());
56+
var cols = dt.getRows().stream().flatMap(c-> c.stream().skip(1)).map(Entry::getKey).distinct().sorted().toList();
5857
if(cols.isEmpty()) { //no data
5958
for(var c : dt.getYAxis()) {
6059
sb1.append(",[").append(doubleQuote(NUMBER.typeName())).append(",").append(doubleQuote(c.getName())).append("]");

src/main/java/org/usf/jquery/web/view/ChartMappers.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,19 @@
2020
public final class ChartMappers {
2121

2222
public static WebViewMapper webChart(String view, Writer w) {
23-
switch (view) {
24-
case "table" : return new TableView(w);
25-
case "pie" : return new PieChartView(w);
26-
case "column" : return columnChart(w);
27-
case "bar" : return barChart(w);
28-
case "area" : return areaChart(w);
29-
case "combo" : return comboChart(w);
30-
case "line" : return lineChart(w);
31-
case "timeline" : return new TimelineChartView(w);
32-
case "calendar" : return new CalendarView(w);
33-
case "sankey" : return new SankeyView(w);
23+
return switch (view) {
24+
case "table" : yield new TableView(w);
25+
case "pie" : yield new PieChartView(w);
26+
case "column" : yield columnChart(w);
27+
case "bar" : yield barChart(w);
28+
case "area" : yield areaChart(w);
29+
case "combo" : yield comboChart(w);
30+
case "line" : yield lineChart(w);
31+
case "timeline" : yield new TimelineChartView(w);
32+
case "calendar" : yield new CalendarView(w);
33+
case "sankey" : yield new SankeyView(w);
3434
default : throw new IllegalArgumentException(view);
35-
}
35+
};
3636
}
3737

3838
}

src/main/java/org/usf/jquery/web/view/PieChartView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public Void map(ResultSet rs) throws SQLException { //scroll.
4545
var bg = currentTimeMillis();
4646
var rw = 0;
4747
var cols = TableColumn.columns(rs.getMetaData());
48-
var numb = Stream.of(cols).filter(c-> c.getType() == NUMBER).collect(toList());
48+
var numb = Stream.of(cols).filter(c-> c.getType() == NUMBER).toList();
4949
if(numb.isEmpty()) {
5050
throw new IllegalArgumentException("require number column");
5151
}

src/main/java/org/usf/jquery/web/view/SankeyView.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import static java.lang.System.currentTimeMillis;
44
import static java.lang.System.lineSeparator;
55
import static java.nio.file.Files.readString;
6-
import static java.util.stream.Collectors.toList;
76
import static org.usf.jquery.web.view.WebViewMapper.TableColumn.columns;
87
import static org.usf.jquery.web.view.WebViewMapper.WebType.NUMBER;
98
import static org.usf.jquery.web.view.WebViewMapper.WebType.STRING;
@@ -46,7 +45,7 @@ public Void map(ResultSet rs) throws SQLException {
4645
var bg = currentTimeMillis();
4746
var rw = 0;
4847
var cols = columns(rs.getMetaData());
49-
var xAxis = Stream.of(cols).filter(c-> c.getType() == STRING).collect(toList());
48+
var xAxis = Stream.of(cols).filter(c-> c.getType() == STRING).toList();
5049
if(xAxis.size() != 2) {
5150
throw new IllegalArgumentException("require [STRING, STRING, NUMBER] columns");
5251
}

src/main/java/org/usf/jquery/web/view/TimelineChartView.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ public Void map(ResultSet rs) throws SQLException {
4545
var bg = currentTimeMillis();
4646
var rw = 0;
4747
var cols = columns(rs.getMetaData());
48-
var numb = Stream.of(cols).filter(c-> c.getType() == NUMBER).collect(toList());
48+
var numb = Stream.of(cols).filter(c-> c.getType() == NUMBER).toList();
4949
if(numb.isEmpty()) {
50-
numb = Stream.of(cols).filter(c-> c.getType().isDate()).collect(toList());
50+
numb = Stream.of(cols).filter(c-> c.getType().isDate()).toList();
5151
}
5252
if(numb.isEmpty() || numb.size() != 2) {
5353
throw new IllegalArgumentException("require NUMBER or DATE columns");
5454
}
5555
var yAxis = numb;
56-
var xAxis = Stream.of(cols).filter(c-> yAxis.stream().noneMatch(v-> v.getName().equals(c.getName()))).collect(toList());
56+
var xAxis = Stream.of(cols).filter(c-> yAxis.stream().noneMatch(v-> v.getName().equals(c.getName()))).toList();
5757
if(xAxis.isEmpty()) {
5858

5959
}

src/main/java/org/usf/jquery/web/view/WebViewMapper.java

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -87,23 +87,14 @@ public String typeName() {
8787
}
8888

8989
static WebType typeOf(int type) {
90-
switch (type) {
91-
case Types.BOOLEAN: return BOOLEAN;
92-
case Types.BIT:
93-
case Types.TINYINT:
94-
case Types.SMALLINT:
95-
case Types.INTEGER:
96-
case Types.BIGINT:
97-
case Types.REAL:
98-
case Types.FLOAT:
99-
case Types.DOUBLE:
100-
case Types.NUMERIC:
101-
case Types.DECIMAL: return NUMBER;
102-
case Types.DATE: return DATE;
103-
case Types.TIMESTAMP: return DATETIME;
90+
return switch (type) {
91+
case Types.BOOLEAN: yield BOOLEAN;
92+
case Types.BIT, Types.TINYINT, Types.SMALLINT, Types.INTEGER, Types.BIGINT, Types.REAL, Types.FLOAT, Types.DOUBLE, Types.NUMERIC, Types.DECIMAL: yield NUMBER;
93+
case Types.DATE: yield DATE;
94+
case Types.TIMESTAMP: yield DATETIME;
10495
//case Types.TIME: //need explicit cast format !?
105-
default: return STRING;
106-
}
96+
default: yield STRING;
97+
};
10798
}
10899
}
109100

0 commit comments

Comments
 (0)