diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/config/GsonConfig.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/config/GsonConfig.java index 4b69a07..d3c0c50 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/config/GsonConfig.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/config/GsonConfig.java @@ -1,6 +1,7 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.config; import ch.usi.inf.sa4.sanmarinoes.smarthut.dto.AutomationFastUpdateRequest; +import ch.usi.inf.sa4.sanmarinoes.smarthut.models.Condition; import ch.usi.inf.sa4.sanmarinoes.smarthut.models.DimmableState; import ch.usi.inf.sa4.sanmarinoes.smarthut.models.State; import ch.usi.inf.sa4.sanmarinoes.smarthut.models.SwitchableState; @@ -43,12 +44,32 @@ public class GsonConfig { .registerSubtype( AutomationFastUpdateRequest.RangeTriggerDTO.class, "rangeTrigger"); + + RuntimeTypeAdapterFactory + runtimeTypeAdapterFactoryIII = + RuntimeTypeAdapterFactory.of( + AutomationFastUpdateRequest.ConditionDTO.class, "kind") + .registerSubtype( + AutomationFastUpdateRequest.BooleanConditionDTO.class, + "booleanCondition") + .registerSubtype( + AutomationFastUpdateRequest.RangeConditionDTO.class, + "rangeCondition") + .registerSubtype( + AutomationFastUpdateRequest.ThermostatConditionDTO.class, + "thermostatCondition"); + builder.registerTypeAdapterFactory(runtimeTypeAdapterFactory); builder.registerTypeAdapterFactory(runtimeTypeAdapterFactoryII); + builder.registerTypeAdapterFactory(runtimeTypeAdapterFactoryIII); builder.registerTypeAdapter( Trigger.class, (JsonSerializer>) (src, typeOfSrc, context) -> context.serialize((Object) src)); + builder.registerTypeAdapter( + Condition.class, + (JsonSerializer>) + (src, typeOfSrc, context) -> context.serialize((Object) src)); return builder; }