diff --git a/ugs-core/src/com/willwinder/universalgcodesender/types/Macro.java b/ugs-core/src/com/willwinder/universalgcodesender/types/Macro.java index 2764509ddb..7370272928 100644 --- a/ugs-core/src/com/willwinder/universalgcodesender/types/Macro.java +++ b/ugs-core/src/com/willwinder/universalgcodesender/types/Macro.java @@ -4,6 +4,8 @@ import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; +import java.io.Serial; +import java.util.Objects; import java.io.Serializable; import java.util.UUID; @@ -15,6 +17,7 @@ public class Macro implements Serializable { private String name; private String description; private String gcode; + private Integer version; public Macro() { } @@ -67,6 +70,14 @@ public void setGcode(String gcode) { this.gcode = gcode; } + public Integer getVersion() { + return version; + } + + public void setVersion(Integer version) { + this.version = Objects.requireNonNullElse(version, 1); + } + @Override public String toString() { return "Macro{" + @@ -74,9 +85,22 @@ public String toString() { "name='" + name + '\'' + ", description='" + description + '\'' + ", gcode='" + gcode + '\'' + + ", version=" + version + '}'; } + @Serial + public Object readResolve() { + this.version = Objects.requireNonNullElse(this.version, 1); + return this; + } + + @Serial + public Object writeReplace() { + this.version = Objects.requireNonNullElse(this.version, 1); + return this; + } + @Override public int hashCode() { return HashCodeBuilder.reflectionHashCode(this); diff --git a/ugs-pendant/src/main/java/com/willwinder/universalgcodesender/pendantui/v1/model/Macro.java b/ugs-pendant/src/main/java/com/willwinder/universalgcodesender/pendantui/v1/model/Macro.java index 4e339a031e..47848450cc 100644 --- a/ugs-pendant/src/main/java/com/willwinder/universalgcodesender/pendantui/v1/model/Macro.java +++ b/ugs-pendant/src/main/java/com/willwinder/universalgcodesender/pendantui/v1/model/Macro.java @@ -9,6 +9,7 @@ public class Macro implements Serializable { private String gcode; private String description; private String name; + private Integer version; public String getGcode() { return gcode; @@ -33,4 +34,12 @@ public String getName() { public void setName(String name) { this.name = name; } + + public Integer getVersion() { + return version; + } + + public void setVersion(Integer version) { + this.version = version; + } }