diff --git a/pom.xml b/pom.xml
index 2a9bf26..0882215 100644
--- a/pom.xml
+++ b/pom.xml
@@ -128,12 +128,6 @@
slf4j-simple
2.0.17
-
-
- com.fasterxml.jackson.datatype
- jackson-datatype-jdk8
- 2.15.0
-
diff --git a/src/main/java/cz/jzitnik/game/Game.java b/src/main/java/cz/jzitnik/game/Game.java
index dc3600c..280e109 100644
--- a/src/main/java/cz/jzitnik/game/Game.java
+++ b/src/main/java/cz/jzitnik/game/Game.java
@@ -1,6 +1,5 @@
package cz.jzitnik.game;
-import com.fasterxml.jackson.annotation.JsonIgnore;
import cz.jzitnik.game.entities.Block;
import cz.jzitnik.game.entities.GameStates;
import cz.jzitnik.game.entities.Player;
diff --git a/src/main/java/cz/jzitnik/game/entities/MyOptional.java b/src/main/java/cz/jzitnik/game/entities/MyOptional.java
index 3f74c8b..b82e529 100644
--- a/src/main/java/cz/jzitnik/game/entities/MyOptional.java
+++ b/src/main/java/cz/jzitnik/game/entities/MyOptional.java
@@ -5,11 +5,9 @@ import java.util.NoSuchElementException;
import java.util.function.*;
public class MyOptional implements Serializable {
- private static final long serialVersionUID = 1L;
private T value;
private boolean isPresent;
- // Constructor
public MyOptional() {
this.isPresent = false;
}
@@ -19,12 +17,10 @@ public class MyOptional implements Serializable {
this.isPresent = true;
}
- // Check if value is present
public boolean isPresent() {
return isPresent;
}
- // Get the value (or throw exception if not present)
public T get() {
if (!isPresent) {
throw new NoSuchElementException("No value present");
@@ -32,12 +28,10 @@ public class MyOptional implements Serializable {
return value;
}
- // Get the value or return default
public T orElse(T other) {
return isPresent ? value : other;
}
- // If value is present, apply function, else return another Optional
public MyOptional map(Function super T, ? extends U> mapper) {
if (!isPresent) {
return new MyOptional<>();
@@ -45,7 +39,6 @@ public class MyOptional implements Serializable {
return new MyOptional<>(mapper.apply(value));
}
- // If value is present, apply function and return a new Optional
public MyOptional flatMap(Function super T, ? extends MyOptional> mapper) {
if (!isPresent) {
return new MyOptional<>();
@@ -53,14 +46,12 @@ public class MyOptional implements Serializable {
return mapper.apply(value);
}
- // Perform an action if value is present
public void ifPresent(Consumer super T> action) {
if (isPresent) {
action.accept(value);
}
}
- // Return the value inside the Optional or default if not present
public T orElseGet(Supplier extends T> other) {
return isPresent ? value : other.get();
}
@@ -73,7 +64,7 @@ public class MyOptional implements Serializable {
return this;
}
- // Serialize the value
+ @Serial
private void writeObject(ObjectOutputStream out) throws IOException {
out.writeBoolean(isPresent);
if (isPresent) {
@@ -81,7 +72,7 @@ public class MyOptional implements Serializable {
}
}
- // Deserialize the value
+ @Serial
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
isPresent = in.readBoolean();
if (isPresent) {
@@ -94,17 +85,14 @@ public class MyOptional implements Serializable {
return isPresent ? "SerializableOptional[" + value + "]" : "SerializableOptional.empty";
}
- // Static factory method for an empty SerializableOptional
public static MyOptional empty() {
return new MyOptional<>();
}
- // Static factory method for a present value
public static MyOptional of(T value) {
return new MyOptional<>(value);
}
- // Static factory method for a present value or null
public static MyOptional ofNullable(T value) {
return value == null ? empty() : new MyOptional<>(value);
}