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

Commit

Permalink
refactor: use one method to add endpoints only (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
kayman-mk committed May 12, 2022
1 parent dd4d399 commit 1cc1cb8
Showing 1 changed file with 10 additions and 10 deletions.
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

0 comments on commit 1cc1cb8

Please sign in to comment.