Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

introduced duplicatable V2XMessage functionality #390

Merged
merged 4 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@
* Contact: [email protected]
*/

package org.eclipse.mosaic.lib.objects;

import org.eclipse.mosaic.lib.objects.v2x.MessageRouting;
package org.eclipse.mosaic.lib.objects.v2x;

/**
* Creates a copy of the message
* @param <MessageT>
* A message that can duplicate itself.
* @param <T> a class that extends {@link org.eclipse.mosaic.lib.objects.v2x.V2xMessage}
iwillitried marked this conversation as resolved.
Show resolved Hide resolved
*/
public interface DuplicatableMessage<T extends DuplicatableMessage<T>> {
public interface DuplicatableMessage<T extends V2xMessage> {

/**
* Creates a copy of the V2xMessage.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

package org.eclipse.mosaic.lib.objects.v2x;

import org.eclipse.mosaic.lib.objects.DuplicatableMessage;
import org.eclipse.mosaic.lib.objects.ToDataOutput;
import org.eclipse.mosaic.lib.util.ClassUtils;

Expand All @@ -24,7 +23,7 @@
/**
* This {@link V2xMessage} implementation can be used for simple message exchange between entities.
*/
public final class GenericV2xMessage extends V2xMessage implements DuplicatableMessage {
public final class GenericV2xMessage extends V2xMessage implements DuplicatableMessage<GenericV2xMessage> {

private static final long serialVersionUID = 1L;

Expand Down Expand Up @@ -64,12 +63,6 @@ public GenericV2xMessage(MessageRouting routing, ToDataOutput messagePayload, lo
this.payload = new EncodedPayload(messagePayload, minimalMessageSize);
}

public GenericV2xMessage(GenericV2xMessage message) {
super(message.getRouting());
this.messageType = message.getMessageType();
this.payload = message.getPayload();
}


@Override
@Nonnull
Expand All @@ -89,6 +82,7 @@ public String toString() {
+ ", encodedPayload=" + payload + '}';
}

@Override
public GenericV2xMessage duplicate(MessageRouting routing) {
schwepmo marked this conversation as resolved.
Show resolved Hide resolved
return new GenericV2xMessage(routing, messageType, payload.getEffectiveLength());
}
Expand Down
Loading