diff --git a/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/addressing/AdHocMessageRoutingBuilder.java b/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/addressing/AdHocMessageRoutingBuilder.java index 953bb6c7..9589f1ff 100644 --- a/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/addressing/AdHocMessageRoutingBuilder.java +++ b/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/addressing/AdHocMessageRoutingBuilder.java @@ -150,7 +150,7 @@ public AdHocMessageRoutingBuilder broadcast() { } /** - * Configures the message to use a topologically scoped routing strategy. + * Configures the message to use a topologically-scoped routing strategy. * @return this builder. */ public AdHocMessageRoutingBuilder topological() { @@ -161,7 +161,7 @@ public AdHocMessageRoutingBuilder topological() { } /** - * Configures the message to use a topologically scoped routing strategy. + * Configures the message to use a geographically-scoped routing strategy. * @param area the area which the message will be transmitted to. * @return this builder. */ diff --git a/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/addressing/CellMessageRoutingBuilder.java b/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/addressing/CellMessageRoutingBuilder.java index 736b275b..4ae95b57 100644 --- a/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/addressing/CellMessageRoutingBuilder.java +++ b/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/addressing/CellMessageRoutingBuilder.java @@ -71,6 +71,10 @@ public CellMessageRoutingBuilder(String hostName, GeoPoint sourcePosition) { ); } + /** + * Creates the MessageRouting based on the methods called on this builder before. + * @return MessageRouting - The desired routing for a message. + */ public MessageRouting build() { checkNecessaryValues(); return this.build(new DestinationAddressContainer( @@ -78,14 +82,6 @@ public MessageRouting build() { ); } - private MessageRouting build(DestinationAddressContainer dac) { - if (streamDuration < 0) { - return new MessageRouting(dac, sourceAddressContainer); - } else { - return new MessageStreamRouting(dac, sourceAddressContainer, streamDuration, streamBandwidthInBitPs); - } - } - /** * Defines stream properties for the message to send. * @@ -137,22 +133,45 @@ public CellMessageRoutingBuilder destination(NetworkAddress networkAddress) { return this; } + /** + * Sets the destination of the message being built. + * @param receiverName The string name of the receiving entity. + * @return this builder. + */ public CellMessageRoutingBuilder destination(String receiverName) { return destination(IpResolver.getSingleton().nameToIp(receiverName).getAddress()); } + /** + * Sets the destination of the message being built. + * @param ipAddress The IP address of the target destination as an {@link Inet4Address}. + * @return this builder. + */ public CellMessageRoutingBuilder destination(Inet4Address ipAddress) { return destination(new NetworkAddress(ipAddress)); } - public CellMessageRoutingBuilder destination(byte[] ipv4Address) { - return destination(new NetworkAddress(ipv4Address)); + /** + * Sets the destination of the message being built. + * @param ipAddress The IP address of the target destination as an array of bytes. + * @return this builder. + */ + public CellMessageRoutingBuilder destination(byte[] ipAddress) { + return destination(new NetworkAddress(ipAddress)); } + /** + * A convenience method that sets the destination IP address to the broadcast address. + * @return this builder. + */ public CellMessageRoutingBuilder broadcast() { return destination(new NetworkAddress(NetworkAddress.BROADCAST_ADDRESS)); } + /** + * Configures the message to use a Multicast/Broadcast Service for transmission. + * @return this builder. + */ public CellMessageRoutingBuilder mbs() { Validate.isTrue(!mbsChanged, "MBS was already chosen!"); Validate.isTrue(!(routing == DestinationType.CELL_TOPOCAST), "MBS can not be enabled for topological routing!"); @@ -161,6 +180,10 @@ public CellMessageRoutingBuilder mbs() { return this; } + /** + * Configures the message to use a topologically-scoped routing strategy. + * @return this builder. + */ public CellMessageRoutingBuilder topological() { Validate.isTrue(!routingChanged, "Routing was already set!"); Validate.isTrue(!mbsChanged, "MBS can not be enabled for topological routing!"); @@ -169,6 +192,11 @@ public CellMessageRoutingBuilder topological() { return this; } + /** + * Configures the message to use a geographically-scoped routing strategy. + * @param area the area which the message will be transmitted to. + * @return this builder. + */ public CellMessageRoutingBuilder geographical(GeoArea area) { Validate.isTrue(!routingChanged, "Routing was already set!"); if (!mbsChanged) { @@ -205,4 +233,11 @@ private void checkArea() { } } } + private MessageRouting build(DestinationAddressContainer dac) { + if (streamDuration < 0) { + return new MessageRouting(dac, sourceAddressContainer); + } else { + return new MessageStreamRouting(dac, sourceAddressContainer, streamDuration, streamBandwidthInBitPs); + } + } }