com.yhzdys.myosotis.serialize.JsonSerializer Maven / Gradle / Ivy
package com.yhzdys.myosotis.serialize;
import com.fasterxml.jackson.core.type.TypeReference;
import com.yhzdys.myosotis.entity.MyosotisConfig;
import com.yhzdys.myosotis.entity.MyosotisEvent;
import com.yhzdys.myosotis.entity.PollingData;
import com.yhzdys.myosotis.misc.JsonUtil;
import java.util.List;
public final class JsonSerializer implements Serializer {
private final TypeReference> polling_list_tr;
private final TypeReference> events_tr;
private final TypeReference> configs_tr;
public JsonSerializer() {
polling_list_tr = new TypeReference>() {
};
events_tr = new TypeReference>() {
};
configs_tr = new TypeReference>() {
};
}
@Override
public byte[] serializePollingData(List list) {
return JsonUtil.toBytes(list);
}
@Override
public List deserializePollingData(byte[] data) {
return JsonUtil.toList(data, polling_list_tr);
}
@Override
public byte[] serializeEvents(List list) {
return JsonUtil.toBytes(list);
}
@Override
public List deserializeEvents(byte[] data) {
return JsonUtil.toList(data, events_tr);
}
@Override
public byte[] serializeConfigs(List list) {
return JsonUtil.toBytes(list);
}
@Override
public List deserializeConfigs(byte[] data) {
return JsonUtil.toList(data, configs_tr);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy