summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorralph isenmann2021-06-24 10:39:10 +0200
committerralph isenmann2021-06-24 10:39:10 +0200
commit76e1d65eea2b1a38fe423002039b100e0ccd602f (patch)
treee1d33da773a2e51e5b8042fb5e43a1e927013b76
parentAdd container models, which keeps the necessary informations about container ... (diff)
downloadmaster-sync-shared-76e1d65eea2b1a38fe423002039b100e0ccd602f.tar.gz
master-sync-shared-76e1d65eea2b1a38fe423002039b100e0ccd602f.tar.xz
master-sync-shared-76e1d65eea2b1a38fe423002039b100e0ccd602f.zip
Fix usage of Enum ContainerImageType
- enum provides name() and valueOf() to switch between sting and object representation
-rw-r--r--src/main/java/org/openslx/virtualization/configuration/container/ContainerMeta.java25
1 files changed, 9 insertions, 16 deletions
diff --git a/src/main/java/org/openslx/virtualization/configuration/container/ContainerMeta.java b/src/main/java/org/openslx/virtualization/configuration/container/ContainerMeta.java
index 5d18248..577a670 100644
--- a/src/main/java/org/openslx/virtualization/configuration/container/ContainerMeta.java
+++ b/src/main/java/org/openslx/virtualization/configuration/container/ContainerMeta.java
@@ -15,29 +15,20 @@ import java.util.Objects;
public class ContainerMeta {
public enum ContainerImageType implements org.apache.thrift.TEnum {
- LECTURE("lecture"), BATCH("batch"), DATA("data");
+ LECTURE("Lecture"), BATCH("Batch"), DATA("Data");
- private final String name;
+ private final String displayLable;
ContainerImageType(String name) {
- this.name = name;
+ this.displayLable = name;
}
public boolean equalNames(String other) {
- return name.equals(other);
- }
-
- public static ContainerImageType getByName(String name) {
- for (ContainerImageType item : ContainerImageType.values()) {
- if (item.name.equals(name))
- return item;
- }
- // name is not an enum, return lecture as default
- return LECTURE;
+ return displayLable.equals(other);
}
@Override public String toString() {
- return this.name;
+ return this.displayLable;
}
@Override public int getValue() {
@@ -139,11 +130,13 @@ public class ContainerMeta {
if (image_type == null || image_type.length() == 0)
return ContainerImageType.LECTURE;
- return ContainerImageType.getByName(image_type);
+ // turn string representation into enum-var 'LECTURE' -> ContainerImageType.LECTURE
+ return ContainerImageType.valueOf(image_type);
}
public void setImageType(ContainerImageType image_type) {
- this.image_type = image_type.toString();
+ // set constant representation of the enum-var e.g. ContainerImageType.LECTURE -> 'LECTURE'
+ this.image_type = image_type.name();
}
@Override public boolean equals(Object o) {