@Override public Object entityMessage(final Object message) { final Object entity; if (message instanceof JsonObject) { // message was sent from another cluster node and therefor is serialized as json final ShardedMessageEnvelope shardedMessageEnvelope = ShardedMessageEnvelope.fromJson((JsonObject) message); entity = createJsonifiableFrom(shardedMessageEnvelope); } else if (message instanceof ShardedMessageEnvelope) { // message was sent from the same cluster node entity = createJsonifiableFrom((ShardedMessageEnvelope) message); } else { entity = message; } return entity; }
@Override public Object entityMessage(final Object message) { final Object entity; if (message instanceof JsonObject) { // message was sent from another cluster node and therefor is serialized as json final ShardedMessageEnvelope shardedMessageEnvelope = ShardedMessageEnvelope.fromJson((JsonObject) message); entity = createJsonifiableFrom(shardedMessageEnvelope); } else if (message instanceof ShardedMessageEnvelope) { // message was sent from the same cluster node entity = createJsonifiableFrom((ShardedMessageEnvelope) message); } else { entity = message; } return entity; }
/** * Returns a new instance of {@code MappingStrategiesBuilder}. * * @return the instance. */ public static MappingStrategiesBuilder newInstance() { final MappingStrategiesBuilder builder = new MappingStrategiesBuilder(); // add the commonly known types: builder.add(DittoHeaders.class, jsonObject -> DittoHeaders.newBuilder(jsonObject).build()); builder.add(ShardedMessageEnvelope.class, jsonObject -> ShardedMessageEnvelope.fromJson(jsonObject)); // do not replace with lambda! builder.add(SimpleCommand.class, jsonObject -> SimpleCommand.fromJson(jsonObject)); // do not replace with lambda! builder.add(SimpleCommandResponse.class, jsonObject -> SimpleCommandResponse.fromJson(jsonObject)); // do not replace with lambda! builder.add(StatusInfo.class, jsonObject -> StatusInfo.fromJson(jsonObject)); // do not replace with lambda! builder.add(StreamAck.class, StreamAck::fromJson); return builder; }
/** * Returns a new instance of {@code MappingStrategiesBuilder}. * * @return the instance. */ public static MappingStrategiesBuilder newInstance() { final MappingStrategiesBuilder builder = new MappingStrategiesBuilder(); // add the commonly known types: builder.add(DittoHeaders.class, jsonObject -> DittoHeaders.newBuilder(jsonObject).build()); builder.add(ShardedMessageEnvelope.class, jsonObject -> ShardedMessageEnvelope.fromJson(jsonObject)); // do not replace with lambda! builder.add(SimpleCommand.class, jsonObject -> SimpleCommand.fromJson(jsonObject)); // do not replace with lambda! builder.add(SimpleCommandResponse.class, jsonObject -> SimpleCommandResponse.fromJson(jsonObject)); // do not replace with lambda! builder.add(StatusInfo.class, jsonObject -> StatusInfo.fromJson(jsonObject)); // do not replace with lambda! builder.add(StreamAck.class, StreamAck::fromJson); return builder; }