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

refactor: use one method to add endpoints only #17

Merged
merged 4 commits into from May 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -51,16 +51,16 @@ public class CommunicationModel {
@SerializedName(value="jms_consumers")
private Collection<ISenderReceiverCommunication> jmsConsumers = new HashSet<>();

public void addHttpConsumer(ISenderReceiverCommunication consumer) {
httpConsumers.add(consumer);
}

public void addHttpProducer(ISenderReceiverCommunication producer) {
httpProducers.add(producer);
}

public void addJmsConsumer(ISenderReceiverCommunication consumer) {
jmsConsumers.add(consumer);
public <T extends ISenderReceiverCommunication> void addSenderReceiver(T endpoint) {
if (endpoint instanceof HttpConsumer) {
httpConsumers.add(endpoint);
} else if (endpoint instanceof HttpProducer) {
httpProducers.add(endpoint);
} else if (endpoint instanceof JmsReceiver) {
jmsConsumers.add(endpoint);
} else {
throw new IllegalStateException(String.format("We have no endpoints of type %s", endpoint.getClass().getCanonicalName()));
}
}

public void visit(AbstractCommunicationModelVisitor visitor) {
Expand Down