Change default Jackson behaviour to not serialize nulls
All checks were successful
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 1m23s

This commit is contained in:
Braydon 2024-04-10 08:23:38 -04:00
parent d2a54ac828
commit 592bca234b
4 changed files with 8 additions and 7 deletions

@ -23,7 +23,6 @@
*/ */
package me.braydon.mc.model; package me.braydon.mc.model;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.*; import lombok.*;
import me.braydon.mc.common.ColorUtils; import me.braydon.mc.common.ColorUtils;
import me.braydon.mc.service.pinger.MinecraftServerPinger; import me.braydon.mc.service.pinger.MinecraftServerPinger;
@ -68,7 +67,7 @@ public class MinecraftServer {
/** /**
* Player count data for a server. * Player count data for a server.
*/ */
@AllArgsConstructor @Getter @ToString @JsonInclude(JsonInclude.Include.NON_NULL) @AllArgsConstructor @Getter @ToString
public static class Players { public static class Players {
/** /**
* The online players on this server. * The online players on this server.

@ -23,7 +23,6 @@
*/ */
package me.braydon.mc.model; package me.braydon.mc.model;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.*; import lombok.*;
import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Id;
@ -36,7 +35,7 @@ import java.util.UUID;
*/ */
@AllArgsConstructor @Getter @AllArgsConstructor @Getter
@EqualsAndHashCode(onlyExplicitlyIncluded = true) @EqualsAndHashCode(onlyExplicitlyIncluded = true)
@ToString @JsonInclude(JsonInclude.Include.NON_NULL) @ToString
public class Player { public class Player {
/** /**
* The unique id of this player. * The unique id of this player.

@ -23,7 +23,6 @@
*/ */
package me.braydon.mc.model.server; package me.braydon.mc.model.server;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
import lombok.*; import lombok.*;
import me.braydon.mc.common.JavaMinecraftVersion; import me.braydon.mc.common.JavaMinecraftVersion;
@ -39,7 +38,7 @@ import net.md_5.bungee.chat.ComponentSerializer;
* *
* @author Braydon * @author Braydon
*/ */
@Setter @Getter @ToString(callSuper = true) @JsonInclude(JsonInclude.Include.NON_NULL) @Setter @Getter @ToString(callSuper = true)
public final class JavaMinecraftServer extends MinecraftServer { public final class JavaMinecraftServer extends MinecraftServer {
/** /**
* The version information of this server. * The version information of this server.
@ -115,7 +114,7 @@ public final class JavaMinecraftServer extends MinecraftServer {
/** /**
* Version information for a server. * Version information for a server.
*/ */
@AllArgsConstructor @Getter @ToString @JsonInclude(JsonInclude.Include.NON_NULL) @AllArgsConstructor @Getter @ToString
public static class Version { public static class Version {
/** /**
* The version name of the server. * The version name of the server.

@ -21,6 +21,10 @@ spring:
database: 0 database: 0
auth: "" # Leave blank for no auth auth: "" # Leave blank for no auth
# Don't serialize null values by default with Jackson
jackson:
default-property-inclusion: non_null
# Ignore # Ignore
banner: banner:
location: "classpath:banner.txt" location: "classpath:banner.txt"