Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Commit

Permalink
fix: use concrete classes for GSON deserializer (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
kayman-mk authored May 14, 2022
1 parent af79747 commit a681680
Showing 1 changed file with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -39,27 +36,34 @@ public class CommunicationModel {
* All HTTP receiver endpoints.
*/
@SerializedName(value="http_consumers")
private Collection<ISenderReceiverCommunication> httpConsumers = new HashSet<>();
private Collection<HttpConsumer> httpConsumers = new HashSet<>();

/**
* All HTTP producers.
*/
@SerializedName(value="http_producers")
private Collection<ISenderReceiverCommunication> httpProducers = new HashSet<>();
private Collection<HttpProducer> httpProducers = new HashSet<>();

/**
* All JMS receivers.
*/
@SerializedName(value="jms_consumers")
private Collection<ISenderReceiverCommunication> jmsConsumers = new HashSet<>();
private Collection<JmsReceiver> jmsConsumers = new HashSet<>();

private CommunicationModel() {
// for GSON deserialize
projectId = "not-set";
projectName = "not-set";
modelVersion = "not-set";
}

public <T extends ISenderReceiverCommunication> 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()));
}
Expand Down

0 comments on commit a681680

Please sign in to comment.