Skip to content

Commit 664cd3f

Browse files
authored
style,chore: added code format using spotless (#34)
1 parent 01be7fd commit 664cd3f

18 files changed

Lines changed: 837 additions & 754 deletions

build.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ compile() {
1717
errcheck $?
1818
}
1919

20+
format() {
21+
mvn spotless:apply
22+
errcheck $?
23+
}
24+
2025
test() {
2126
mvn test
2227
errcheck $?
@@ -60,9 +65,9 @@ deploy() {
6065

6166
if [[ "$#" == "0" ]]; then
6267
clean
68+
format
6369
jar
6470
javadoc
65-
#trace_test
6671
native_test
6772
else
6873
for a in "$@"; do
@@ -73,6 +78,9 @@ else
7378
compile)
7479
compile
7580
;;
81+
format)
82+
format
83+
;;
7684
test)
7785
test
7886
;;
@@ -88,7 +96,7 @@ else
8896
sver)
8997
sver $2
9098
;;
91-
'trace_test')
99+
'trace-test')
92100
trace_test
93101
;;
94102
'native-test')

pom.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,16 @@
153153
<artifactId>maven-surefire-plugin</artifactId>
154154
<version>3.5.3</version>
155155
</plugin>
156+
<plugin>
157+
<groupId>com.diffplug.spotless</groupId>
158+
<artifactId>spotless-maven-plugin</artifactId>
159+
<version>2.44.5</version>
160+
<configuration>
161+
<java>
162+
<googleJavaFormat/>
163+
</java>
164+
</configuration>
165+
</plugin>
156166
</plugins>
157167
</build>
158168

src/main/java/com/github/sttk/sabi/AsyncGroup.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,9 @@
44
*/
55
package com.github.sttk.sabi;
66

7-
import com.github.sttk.errs.Exc;
8-
9-
import java.util.Map;
10-
import java.util.HashMap;
11-
127
public interface AsyncGroup {
138
record RunnerFailed() {}
9+
1410
record RunnerInterrupted() {}
1511

1612
void add(final Runner runner);

src/main/java/com/github/sttk/sabi/DataConn.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,18 @@
88

99
public interface DataConn {
1010
void commit(AsyncGroup ag) throws Exc;
11+
1112
default void preCommit(AsyncGroup ag) throws Exc {}
13+
1214
default void postCommit(AsyncGroup ag) {}
13-
default boolean shouldForceBack() { return false; }
15+
16+
default boolean shouldForceBack() {
17+
return false;
18+
}
19+
1420
void rollback(AsyncGroup ag);
21+
1522
default void forceBack(AsyncGroup ag) {}
23+
1624
void close();
1725
}

src/main/java/com/github/sttk/sabi/DataHub.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,29 @@
44
*/
55
package com.github.sttk.sabi;
66

7-
import com.github.sttk.sabi.internal.DataHubInner;
87
import com.github.sttk.errs.Exc;
8+
import com.github.sttk.sabi.internal.DataHubInner;
99
import java.util.Map;
10-
import java.util.HashMap;
11-
import java.util.concurrent.atomic.AtomicBoolean;
1210

13-
public class DataHub implements DataAcc, AutoCloseable {
11+
public class DataHub implements DataAcc, AutoCloseable {
1412
public record FailToSetupGlobalDataSrcs(Map<String, Exc> errors) {}
13+
1514
public record FailToSetupLocalDataSrcs(Map<String, Exc> errors) {}
15+
1616
public record FailToCommitDataConn(Map<String, Exc> errors) {}
17+
1718
public record FailToPreCommitDataConn(Map<String, Exc> errors) {}
19+
1820
public record NoDataSrcToCreateDataConn(String name, String dataConnType) {}
21+
1922
public record FailToCreateDataConn(String name, String dataConnType) {}
23+
2024
public record CreatedDataConnIsNull(String name, String dataConnType) {}
25+
2126
public record FailToCastDataConn(String name, String castToType) {}
27+
2228
public record FailToCastDataHub(String castFromType) {}
29+
2330
public record RuntimeExceptionOccured() {}
2431

2532
private final DataHubInner inner = new DataHubInner();

src/main/java/com/github/sttk/sabi/DataSrc.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
public interface DataSrc {
1010
void setup(AsyncGroup ag) throws Exc;
11+
1112
void close();
13+
1214
DataConn createDataConn() throws Exc;
1315
}

src/main/java/com/github/sttk/sabi/Runner.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,15 @@
66

77
import com.github.sttk.errs.Exc;
88

9-
/**
10-
* {@code Runner} is the interface that runs any procedure.
11-
*/
9+
/** {@code Runner} is the interface that runs any procedure. */
1210
@FunctionalInterface
1311
public interface Runner {
1412

1513
/**
16-
* Runs the procedure that this instance represents.
17-
* This method takes no argument and returns nothing.
18-
* And this method throws an {@link Exc} exception if this method failed.
14+
* Runs the procedure that this instance represents. This method takes no argument and returns
15+
* nothing. And this method throws an {@link Exc} exception if this method failed.
1916
*
20-
* @throws Exc If this method failed.
17+
* @throws Exc If this method failed.
2118
*/
2219
void run() throws Exc;
2320
}

src/main/java/com/github/sttk/sabi/Sabi.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@
44
*/
55
package com.github.sttk.sabi;
66

7-
import com.github.sttk.sabi.internal.DataHubInner;
87
import com.github.sttk.errs.Exc;
9-
import java.util.Map;
10-
import java.util.HashMap;
11-
import java.util.concurrent.atomic.AtomicBoolean;
8+
import com.github.sttk.sabi.internal.DataHubInner;
129

1310
public final class Sabi {
1411
private Sabi() {}
@@ -21,4 +18,3 @@ public static AutoCloseable setup() throws Exc {
2118
return DataHubInner.setupGlobals();
2219
}
2320
}
24-

src/main/java/com/github/sttk/sabi/internal/AsyncGroupImpl.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
import com.github.sttk.errs.Exc;
88
import com.github.sttk.sabi.AsyncGroup;
99
import com.github.sttk.sabi.Runner;
10-
1110
import java.util.Map;
12-
import java.util.HashMap;
1311

1412
public class AsyncGroupImpl implements AsyncGroup {
1513
private ExcEntry excHead;
@@ -23,13 +21,16 @@ public AsyncGroupImpl() {}
2321
@Override
2422
public void add(final Runner runner) {
2523
final var name = this.name;
26-
var vth = Thread.ofVirtual().start(() -> {
27-
try {
28-
runner.run();
29-
} catch (Exc | RuntimeException e) {
30-
addExc(name, e);
31-
}
32-
});
24+
var vth =
25+
Thread.ofVirtual()
26+
.start(
27+
() -> {
28+
try {
29+
runner.run();
30+
} catch (Exc | RuntimeException e) {
31+
addExc(name, e);
32+
}
33+
});
3334

3435
var ent = new VthEntry(name, vth);
3536
if (this.vthLast == null) {
@@ -72,7 +73,8 @@ void joinAndIgnoreExcs() {
7273
for (var ent = this.vthHead; ent != null; ent = ent.next) {
7374
try {
7475
ent.thread.join();
75-
} catch (InterruptedException e) {}
76+
} catch (InterruptedException e) {
77+
}
7678
}
7779
clear();
7880
}

src/main/java/com/github/sttk/sabi/internal/DataConnList.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
*/
55
package com.github.sttk.sabi.internal;
66

7-
import com.github.sttk.errs.Exc;
8-
97
public class DataConnList {
108
DataConnContainer head;
119
DataConnContainer last;

0 commit comments

Comments
 (0)