Skip to content

Commit

Permalink
added macro versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewmurraydavid committed Feb 13, 2024
1 parent f06322c commit 2915497
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
24 changes: 24 additions & 0 deletions ugs-core/src/com/willwinder/universalgcodesender/types/Macro.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -15,6 +17,7 @@ public class Macro implements Serializable {
private String name;
private String description;
private String gcode;
private Integer version;

public Macro() {
}
Expand Down Expand Up @@ -67,16 +70,37 @@ 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{" +
"uuid='" + uuid + '\'' +
"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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
}

0 comments on commit 2915497

Please sign in to comment.