Skip to content

Commit ab218af

Browse files
committed
feat: update Manifest to include JSON ignore annotations and non-null inclusion
1 parent 9bdce11 commit ab218af

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

  • addon-bridge-core/src/main/java/net/easecation/bridge/core

addon-bridge-core/src/main/java/net/easecation/bridge/core/Manifest.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package net.easecation.bridge.core;
22

3+
import com.fasterxml.jackson.annotation.JsonIgnore;
34
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
45
import com.fasterxml.jackson.annotation.JsonInclude;
56
import com.fasterxml.jackson.annotation.JsonProperty;
@@ -12,6 +13,7 @@
1213
* Contains metadata, modules, dependencies and capabilities.
1314
*/
1415
@JsonIgnoreProperties(ignoreUnknown = true)
16+
@JsonInclude(JsonInclude.Include.NON_NULL)
1517
public record Manifest(
1618
@JsonProperty("format_version") int formatVersion,
1719
@JsonProperty("header") Header header,
@@ -33,7 +35,6 @@ public Manifest(String uuid, String name, String version) {
3335
}
3436

3537
@JsonIgnoreProperties(ignoreUnknown = true)
36-
@JsonInclude(JsonInclude.Include.ALWAYS)
3738
public record Header(
3839
@JsonProperty("uuid") String uuid,
3940
@JsonProperty("name") String name,
@@ -69,14 +70,17 @@ public record Metadata(
6970
) {}
7071

7172
// Helper methods
73+
@JsonIgnore
7274
public String getUuid() {
7375
return header.uuid();
7476
}
7577

78+
@JsonIgnore
7679
public String getName() {
7780
return header.name();
7881
}
7982

83+
@JsonIgnore
8084
public String getVersion() {
8185
List<Integer> ver = header.version();
8286
if (ver == null || ver.isEmpty()) return "0.0.0";
@@ -86,6 +90,7 @@ public String getVersion() {
8690
return major + "." + minor + "." + patch;
8791
}
8892

93+
@JsonIgnore
8994
public boolean isBehaviorPack() {
9095
if (modules == null || modules.isEmpty()) {
9196
return false;
@@ -96,6 +101,7 @@ public boolean isBehaviorPack() {
96101
"javascript".equalsIgnoreCase(m.type()));
97102
}
98103

104+
@JsonIgnore
99105
public boolean isResourcePack() {
100106
return modules != null && modules.stream()
101107
.anyMatch(m -> "resources".equals(m.type()));
@@ -108,6 +114,7 @@ public boolean isResourcePack() {
108114
*
109115
* @return PackType.RESOURCE if the pack contains resources, PackType.BEHAVIOR otherwise
110116
*/
117+
@JsonIgnore
111118
public PackType getPackType() {
112119
return isResourcePack() ? PackType.RESOURCE : PackType.BEHAVIOR;
113120
}

0 commit comments

Comments
 (0)