/** * Wraps a geo beacon message into a blaubot message * * @param message the message * @return the blaubot message */ public static BlaubotMessage geoBeaconMessageToBlaubotMessage(GeoBeaconMessage message) { GeoBeaconMessageDTO dto = new GeoBeaconMessageDTO(message); byte[] jsonBytes = gson.toJson(dto).getBytes(BlaubotConstants.STRING_CHARSET); // wrap it and send BlaubotMessage msg = new BlaubotMessage(); msg.setPayload(jsonBytes); return msg; }
public static GeoBeaconMessage blaubotMessageToGeoBeaconMessage(BlaubotMessage msg) { final byte[] payload = msg.getPayload(); final String jsonData = new String(payload, BlaubotConstants.STRING_CHARSET); final GeoBeaconMessageDTO geoBeaconMessageDTO = gson.fromJson(jsonData, GeoBeaconMessageDTO.class); final GeoBeaconMessage geoBeaconMessage = new GeoBeaconMessage(geoBeaconMessageDTO); return geoBeaconMessage; }