From a6816806d420251ee38e8d57dba2191c274c577a Mon Sep 17 00:00:00 2001 From: Matthias Kay Date: Sat, 14 May 2022 11:34:41 +0200 Subject: [PATCH] fix: use concrete classes for GSON deserializer (#24) --- .../analyzer/model/CommunicationModel.java | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/hlag/tools/commvis/analyzer/model/CommunicationModel.java b/src/main/java/com/hlag/tools/commvis/analyzer/model/CommunicationModel.java index cea9ff3..fab54c4 100644 --- a/src/main/java/com/hlag/tools/commvis/analyzer/model/CommunicationModel.java +++ b/src/main/java/com/hlag/tools/commvis/analyzer/model/CommunicationModel.java @@ -1,10 +1,7 @@ package com.hlag.tools.commvis.analyzer.model; import com.google.gson.annotations.SerializedName; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.RequiredArgsConstructor; -import lombok.ToString; +import lombok.*; import java.util.Collection; import java.util.HashSet; @@ -39,27 +36,34 @@ public class CommunicationModel { * All HTTP receiver endpoints. */ @SerializedName(value="http_consumers") - private Collection httpConsumers = new HashSet<>(); + private Collection httpConsumers = new HashSet<>(); /** * All HTTP producers. */ @SerializedName(value="http_producers") - private Collection httpProducers = new HashSet<>(); + private Collection httpProducers = new HashSet<>(); /** * All JMS receivers. */ @SerializedName(value="jms_consumers") - private Collection jmsConsumers = new HashSet<>(); + private Collection jmsConsumers = new HashSet<>(); + + private CommunicationModel() { + // for GSON deserialize + projectId = "not-set"; + projectName = "not-set"; + modelVersion = "not-set"; + } public void addSenderReceiver(T endpoint) { if (endpoint instanceof HttpConsumer) { - httpConsumers.add(endpoint); + httpConsumers.add((HttpConsumer) endpoint); } else if (endpoint instanceof HttpProducer) { - httpProducers.add(endpoint); + httpProducers.add((HttpProducer) endpoint); } else if (endpoint instanceof JmsReceiver) { - jmsConsumers.add(endpoint); + jmsConsumers.add((JmsReceiver) endpoint); } else { throw new IllegalStateException(String.format("We have no endpoints of type %s", endpoint.getClass().getCanonicalName())); }