completed user-defined states
This commit is contained in:
@@ -1,10 +1,18 @@
|
||||
/* © SRSoftware 2025 */
|
||||
package de.srsoftware.umbrella.core.model;
|
||||
|
||||
import de.srsoftware.tools.Mappable;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public record Status(String name, int code){
|
||||
import static de.srsoftware.umbrella.core.Constants.CODE;
|
||||
import static de.srsoftware.umbrella.core.Constants.NAME;
|
||||
|
||||
public record Status(String name, int code) implements Mappable {
|
||||
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);
|
||||
@@ -22,4 +30,13 @@ public record Status(String name, int code){
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
|
||||
public static Status of(ResultSet rs) throws SQLException {
|
||||
return new Status(rs.getString(NAME),rs.getInt(CODE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap() {
|
||||
return Map.of(NAME,name,CODE,code);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user