Skip to content

Commit 32f60d9

Browse files
cursoragentsimbo1905
andcommitted
Issue #130 Fix json-transforms compilation visibility and warnings
Co-authored-by: simbo1905 <simbo1905@60hertz.com>
1 parent 2c00678 commit 32f60d9

File tree

6 files changed

+33
-27
lines changed

6 files changed

+33
-27
lines changed

json-transforms/src/main/java/json/java21/transforms/JsonTransformException.java

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

33
/// Exception thrown for invalid transform syntax or runtime failures applying a transform.
44
public final class JsonTransformException extends RuntimeException {
5+
private static final long serialVersionUID = 1L;
6+
57
public JsonTransformException(String message) {
68
super(message);
79
}

json-transforms/src/main/java/json/java21/transforms/TransformAst.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ record ObjectTransform(
1818
List<MergeOp> merges,
1919
List<RenameOp> renames
2020
) implements TransformAst {
21-
ObjectTransform {
21+
public ObjectTransform {
2222
Objects.requireNonNull(nonVerbMembers, "nonVerbMembers must not be null");
2323
Objects.requireNonNull(childObjects, "childObjects must not be null");
2424
Objects.requireNonNull(removes, "removes must not be null");
@@ -36,15 +36,15 @@ record ObjectTransform(
3636

3737
sealed interface RemoveOp extends TransformAst permits RemoveOp.ByName, RemoveOp.RemoveThis, RemoveOp.ByPath {
3838
record ByName(String name) implements RemoveOp {
39-
ByName {
39+
public ByName {
4040
Objects.requireNonNull(name, "name must not be null");
4141
}
4242
}
4343

4444
record RemoveThis() implements RemoveOp {}
4545

4646
record ByPath(String rawPath, JsonPath path) implements RemoveOp {
47-
ByPath {
47+
public ByPath {
4848
Objects.requireNonNull(rawPath, "rawPath must not be null");
4949
Objects.requireNonNull(path, "path must not be null");
5050
}
@@ -53,13 +53,13 @@ record ByPath(String rawPath, JsonPath path) implements RemoveOp {
5353

5454
sealed interface ReplaceOp extends TransformAst permits ReplaceOp.ReplaceThis, ReplaceOp.ByPath {
5555
record ReplaceThis(JsonValue value) implements ReplaceOp {
56-
ReplaceThis {
56+
public ReplaceThis {
5757
Objects.requireNonNull(value, "value must not be null");
5858
}
5959
}
6060

6161
record ByPath(String rawPath, JsonPath path, JsonValue value) implements ReplaceOp {
62-
ByPath {
62+
public ByPath {
6363
Objects.requireNonNull(rawPath, "rawPath must not be null");
6464
Objects.requireNonNull(path, "path must not be null");
6565
Objects.requireNonNull(value, "value must not be null");
@@ -70,13 +70,13 @@ record ByPath(String rawPath, JsonPath path, JsonValue value) implements Replace
7070
sealed interface MergeOp extends TransformAst permits MergeOp.MergeThis, MergeOp.ByPath {
7171

7272
record MergeThis(Value value) implements MergeOp {
73-
MergeThis {
73+
public MergeThis {
7474
Objects.requireNonNull(value, "value must not be null");
7575
}
7676
}
7777

7878
record ByPath(String rawPath, JsonPath path, Value value) implements MergeOp {
79-
ByPath {
79+
public ByPath {
8080
Objects.requireNonNull(rawPath, "rawPath must not be null");
8181
Objects.requireNonNull(path, "path must not be null");
8282
Objects.requireNonNull(value, "value must not be null");
@@ -85,13 +85,13 @@ record ByPath(String rawPath, JsonPath path, Value value) implements MergeOp {
8585

8686
sealed interface Value permits Value.Raw, Value.TransformObjectValue {
8787
record Raw(JsonValue value) implements Value {
88-
Raw {
88+
public Raw {
8989
Objects.requireNonNull(value, "value must not be null");
9090
}
9191
}
9292

9393
record TransformObjectValue(JsonObject rawObject, ObjectTransform compiled) implements Value {
94-
TransformObjectValue {
94+
public TransformObjectValue {
9595
Objects.requireNonNull(rawObject, "rawObject must not be null");
9696
Objects.requireNonNull(compiled, "compiled must not be null");
9797
}
@@ -101,14 +101,14 @@ record TransformObjectValue(JsonObject rawObject, ObjectTransform compiled) impl
101101

102102
sealed interface RenameOp extends TransformAst permits RenameOp.Mapping, RenameOp.ByPath {
103103
record Mapping(Map<String, String> renames) implements RenameOp {
104-
Mapping {
104+
public Mapping {
105105
Objects.requireNonNull(renames, "renames must not be null");
106106
renames = Map.copyOf(renames);
107107
}
108108
}
109109

110110
record ByPath(String rawPath, JsonPath path, String newName) implements RenameOp {
111-
ByPath {
111+
public ByPath {
112112
Objects.requireNonNull(rawPath, "rawPath must not be null");
113113
Objects.requireNonNull(path, "path must not be null");
114114
Objects.requireNonNull(newName, "newName must not be null");

json-transforms/src/main/java/json/java21/transforms/TransformCompiler.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212

1313
import static json.java21.transforms.TransformSyntax.*;
1414

15-
sealed interface TransformCompiler permits TransformCompiler.Nothing {
16-
enum Nothing implements TransformCompiler { INSTANCE }
15+
final class TransformCompiler {
16+
17+
private TransformCompiler() {}
1718

1819
static TransformAst.ObjectTransform compileObject(JsonObject transformObject) {
1920
Objects.requireNonNull(transformObject, "transformObject must not be null");

json-transforms/src/main/java/json/java21/transforms/TransformPatch.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
import java.util.List;
99
import java.util.Objects;
1010

11-
sealed interface TransformPatch permits TransformPatch.Nothing {
12-
enum Nothing implements TransformPatch { INSTANCE }
11+
final class TransformPatch {
12+
13+
private TransformPatch() {}
1314

1415
static JsonValue removeAt(JsonValue root, List<JsonPathLocationStep> location) {
1516
Objects.requireNonNull(root, "root must not be null");

json-transforms/src/main/java/json/java21/transforms/TransformRunner.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99

1010
import static json.java21.transforms.TransformPatch.*;
1111

12-
sealed interface TransformRunner permits TransformRunner.Nothing {
13-
enum Nothing implements TransformRunner { INSTANCE }
12+
final class TransformRunner {
1413

15-
Logger LOG = Logger.getLogger(TransformRunner.class.getName());
14+
private static final Logger LOG = Logger.getLogger(TransformRunner.class.getName());
15+
16+
private TransformRunner() {}
1617

1718
static JsonValue applyAtDocumentRoot(JsonObject source, TransformAst.ObjectTransform transform) {
1819
Objects.requireNonNull(source, "source must not be null");

json-transforms/src/main/java/json/java21/transforms/TransformSyntax.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@
22

33
import java.util.Objects;
44

5-
sealed interface TransformSyntax permits TransformSyntax.Nothing {
6-
enum Nothing implements TransformSyntax { INSTANCE }
5+
final class TransformSyntax {
76

8-
String SYNTAX_PREFIX = "@jdt.";
7+
private TransformSyntax() {}
98

10-
String VERB_REMOVE = "@jdt.remove";
11-
String VERB_REPLACE = "@jdt.replace";
12-
String VERB_MERGE = "@jdt.merge";
13-
String VERB_RENAME = "@jdt.rename";
9+
static final String SYNTAX_PREFIX = "@jdt.";
1410

15-
String ATTR_PATH = "@jdt.path";
16-
String ATTR_VALUE = "@jdt.value";
11+
static final String VERB_REMOVE = "@jdt.remove";
12+
static final String VERB_REPLACE = "@jdt.replace";
13+
static final String VERB_MERGE = "@jdt.merge";
14+
static final String VERB_RENAME = "@jdt.rename";
15+
16+
static final String ATTR_PATH = "@jdt.path";
17+
static final String ATTR_VALUE = "@jdt.value";
1718

1819
static boolean isSyntaxKey(String key) {
1920
return key != null && key.startsWith(SYNTAX_PREFIX);

0 commit comments

Comments
 (0)