implemented buld status update for times
This commit is contained in:
@@ -3,9 +3,10 @@ package de.srsoftware.umbrella.core.model;
|
||||
|
||||
import static de.srsoftware.umbrella.core.Constants.*;
|
||||
import static de.srsoftware.umbrella.core.Util.*;
|
||||
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.invalidFieldException;
|
||||
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.unprocessable;
|
||||
|
||||
import de.srsoftware.tools.Mappable;
|
||||
import de.srsoftware.umbrella.core.exceptions.UmbrellaException;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.time.LocalDateTime;
|
||||
@@ -126,7 +127,24 @@ public class Time implements Mappable{
|
||||
if (json.has(START_TIME) && json.get(START_TIME) instanceof Number st) start = st.longValue();
|
||||
if (json.has(END_TIME) && json.get(END_TIME) instanceof Number e) end = e.longValue();
|
||||
if (end == 0) end = null;
|
||||
if (end != null && end < start) throw UmbrellaException.invalidFieldException(END_TIME,"after start_time");
|
||||
if (end != null && end < start) throw invalidFieldException(END_TIME,"after start_time");
|
||||
if (json.has(STATE)) {
|
||||
var o = json.get(STATE);
|
||||
try {
|
||||
switch (o) {
|
||||
case String stateName:
|
||||
state = State.valueOf(stateName);
|
||||
break;
|
||||
case Number stateCode:
|
||||
state = State.of(stateCode.intValue());
|
||||
break;
|
||||
default:
|
||||
throw invalidFieldException(STATE, "state name or code");
|
||||
}
|
||||
} catch (Exception e){
|
||||
throw unprocessable("\"{0}\" is not a valid state name or code!",o);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user