6 changed files with 42 additions and 48 deletions
@ -1,31 +1,22 @@
@@ -1,31 +1,22 @@
|
||||
/* © SRSoftware 2025 */ |
||||
package de.srsoftware.umbrella.core.model; |
||||
|
||||
public enum Status{ |
||||
OPEN(10), |
||||
STARTED(20), |
||||
PENDING(40), |
||||
COMPLETE(60), |
||||
CANCELLED(100); |
||||
public record Status(String name, int code){ |
||||
public static final Status OPEN = new Status("OPEN",10); |
||||
public static final Status STARTED = new Status("STARTED",20); |
||||
public static final Status PENDING = new Status("PENDING", 40); |
||||
public static final Status COMPLETE = new Status("COMPLETE",60); |
||||
public static final Status CANCELLED = new Status("CANCELLED", 100); |
||||
public static final Status[] PREDEFINED = {OPEN, STARTED, PENDING, COMPLETE, CANCELLED}; |
||||
|
||||
private int code; |
||||
|
||||
Status(int code){ |
||||
this.code = code; |
||||
} |
||||
|
||||
public int code(){ |
||||
return code; |
||||
} |
||||
|
||||
public static Status of(int code){ |
||||
return switch (code){ |
||||
case 10 -> OPEN; |
||||
case 20 -> STARTED; |
||||
case 40 -> PENDING; |
||||
case 60 -> COMPLETE; |
||||
case 100 -> CANCELLED; |
||||
default -> throw new IllegalArgumentException(); |
||||
}; |
||||
} |
||||
public static Status of(int code){ |
||||
return switch (code){ |
||||
case 10 -> OPEN; |
||||
case 20 -> STARTED; |
||||
case 40 -> PENDING; |
||||
case 60 -> COMPLETE; |
||||
case 100 -> CANCELLED; |
||||
default -> throw new IllegalArgumentException(); |
||||
}; |
||||
} |
||||
} |
||||
Loading…
Reference in new issue