Skip to content

Commit 0000701

Browse files
committed
refactor: restructure the flat package into seperate subpackages and classes
1 parent 1ed850c commit 0000701

21 files changed

Lines changed: 1225 additions & 558 deletions

‎justfile‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ test-show-only-failed: (test "test" "-PtestLogEvents=failed")
2828

2929
[group('chore')]
3030
clean-whitespace:
31-
sed 's/[ \t]*$//' lib/src/main/java/io/github/ahmadnull/dataserialization/* -i
32-
sed 's/[ \t]*$//' lib/src/test/java/io/github/ahmadnull/dataserialization/* -i
31+
# Recursive, the package directories contain sub packages since the library
32+
# was split per format. `just format` already covers this via spotless.
33+
find lib/src -name '*.java' -exec sed -i 's/[ \t]*$//' {} +
3334

3435
[group('chore')]
3536
format:

‎lib/build.gradle.kts‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,13 @@ dependencies {
2424
sourceSets {
2525
// The shared conformance corpora live in the repository root, outside of any
2626
// module, and are copied onto the test classpath so the tests can list and
27-
// read them as resources.
27+
// read them as resources. Every format registers its own directory here, the
28+
// suites must not be nested into one another to keep the corpus paths flat.
2829
named("test") {
29-
resources.srcDir(rootProject.file("test_suites/json"))
30+
resources.srcDirs(
31+
rootProject.file("test_suites/json"),
32+
// rootProject.file("test_suites/toml"),
33+
)
3034
}
3135
}
3236

@@ -50,6 +54,11 @@ tasks.withType<Test> {
5054
// Use JUnit Platform for unit tests.
5155
useJUnitPlatform()
5256

57+
// The module descriptor is asserted from ModuleApiSurfaceTest, which reads
58+
// module-info.class off the test classpath. The tests deliberately stay on
59+
// the classpath: inferModulePath only takes effect when the main runtime is
60+
// a jar, while the test task consumes the class directory.
61+
5362
// ./gradlew test -PtestLogEvents=failed logs nothing but the failures,
5463
// any other value keeps the default event set.
5564
val testLogEvents = when (providers.gradleProperty("testLogEvents").orNull) {

‎lib/src/main/java/io/github/ahmadnull/dataserialization/DataPath.java‎

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

77
public class DataPath {
88

9-
public enum Seperator {
9+
public enum Separator {
1010
Dot {
1111
public String toString() {
1212
return squareBracketsRegex + Pattern.quote(".") + ']';
@@ -24,22 +24,22 @@ public String toString() {
2424
}
2525

2626
public static Object getByPath(Map<String, Object> map, String path) {
27-
return getByPath(map, DataPath.Seperator.Dot, path);
27+
return getByPath(map, DataPath.Separator.Dot, path);
2828
}
2929

30-
public static Object getByPath(Map<String, Object> map, DataPath.Seperator seperator, String path) {
31-
String seperatorRegex = seperator.toString();
30+
public static Object getByPath(Map<String, Object> map, DataPath.Separator separator, String path) {
31+
String separatorRegex = separator.toString();
3232

33-
String[] splittedPath = path.split(seperatorRegex);
33+
String[] splittedPath = path.split(separatorRegex);
3434

35-
return getByPath(map, seperator, splittedPath);
35+
return getByPath(map, separator, splittedPath);
3636
}
3737

3838
public static Object getByPath(Map<String, Object> map, String... path) {
39-
return getByPath(map, DataPath.Seperator.Dot, path);
39+
return getByPath(map, DataPath.Separator.Dot, path);
4040
}
4141

42-
public static Object getByPath(Map<String, Object> map, DataPath.Seperator seperator, String... path) {
42+
public static Object getByPath(Map<String, Object> map, DataPath.Separator separator, String... path) {
4343
Object node = map.get(path[0]);
4444

4545
int length = path.length;
@@ -56,22 +56,22 @@ public static Object getByPath(Map<String, Object> map, DataPath.Seperator seper
5656
}
5757

5858
public static Object getByPath(List<Object> list, String path) {
59-
return getByPath(list, DataPath.Seperator.Dot, path);
59+
return getByPath(list, DataPath.Separator.Dot, path);
6060
}
6161

62-
public static Object getByPath(List<Object> list, DataPath.Seperator seperator, String path) {
63-
String seperatorRegex = seperator.toString();
62+
public static Object getByPath(List<Object> list, DataPath.Separator separator, String path) {
63+
String separatorRegex = separator.toString();
6464

65-
String[] splittedPath = path.split(seperatorRegex);
65+
String[] splittedPath = path.split(separatorRegex);
6666

67-
return getByPath(list, seperator, splittedPath);
67+
return getByPath(list, separator, splittedPath);
6868
}
6969

7070
public static Object getByPath(List<Object> list, String... path) {
71-
return getByPath(list, DataPath.Seperator.Dot, path);
71+
return getByPath(list, DataPath.Separator.Dot, path);
7272
}
7373

74-
public static Object getByPath(List<Object> list, DataPath.Seperator seperator, String... path) {
74+
public static Object getByPath(List<Object> list, DataPath.Separator separator, String... path) {
7575
Object node = list.get(Integer.parseInt(path[0]));
7676

7777
int length = path.length;

0 commit comments

Comments
 (0)