diff --git a/co-simulation/lib/mosaic-interactions/src/main/java/org/eclipse/mosaic/interactions/sensor/DetectionType.java b/co-simulation/lib/mosaic-interactions/src/main/java/org/eclipse/mosaic/interactions/sensor/DetectionType.java index f9b58818..723f604a 100644 --- a/co-simulation/lib/mosaic-interactions/src/main/java/org/eclipse/mosaic/interactions/sensor/DetectionType.java +++ b/co-simulation/lib/mosaic-interactions/src/main/java/org/eclipse/mosaic/interactions/sensor/DetectionType.java @@ -45,7 +45,7 @@ public enum DetectionType { */ public static DetectionType fromName(String name) { for (DetectionType type: DetectionType.values()) { - if (type.label == name) { + if (type.label.equals(name)) { return type; } } diff --git a/co-simulation/lib/mosaic-interactions/src/main/java/org/eclipse/mosaic/interactions/sensor/Sensor.java b/co-simulation/lib/mosaic-interactions/src/main/java/org/eclipse/mosaic/interactions/sensor/Sensor.java index 510d5dda..feacbc8a 100644 --- a/co-simulation/lib/mosaic-interactions/src/main/java/org/eclipse/mosaic/interactions/sensor/Sensor.java +++ b/co-simulation/lib/mosaic-interactions/src/main/java/org/eclipse/mosaic/interactions/sensor/Sensor.java @@ -15,9 +15,13 @@ */ package org.eclipse.mosaic.interactions.sensor; +import java.io.Serializable; + import org.eclipse.mosaic.lib.geo.CartesianPoint; -public class Sensor { +public class Sensor implements Serializable { + private static final long serialVersionUID = 1L; + private String sensorId; private SensorType type; private Orientation orientation; diff --git a/co-simulation/lib/mosaic-interactions/src/main/java/org/eclipse/mosaic/interactions/sensor/SensorRegistration.java b/co-simulation/lib/mosaic-interactions/src/main/java/org/eclipse/mosaic/interactions/sensor/SensorRegistration.java index 609cf857..9c5169b0 100644 --- a/co-simulation/lib/mosaic-interactions/src/main/java/org/eclipse/mosaic/interactions/sensor/SensorRegistration.java +++ b/co-simulation/lib/mosaic-interactions/src/main/java/org/eclipse/mosaic/interactions/sensor/SensorRegistration.java @@ -31,5 +31,29 @@ public Sensor getSensor() { public void setSensor(Sensor sensor) { this.sensor = sensor; } + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((sensor == null) ? 0 : sensor.hashCode()); + return result; + } + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + SensorRegistration other = (SensorRegistration) obj; + if (sensor == null) { + if (other.sensor != null) + return false; + } else if (!sensor.equals(other.sensor)) + return false; + return true; + } + } diff --git a/co-simulation/lib/mosaic-interactions/src/main/java/org/eclipse/mosaic/interactions/sensor/gson/SensorTypeAdapter.java b/co-simulation/lib/mosaic-interactions/src/main/java/org/eclipse/mosaic/interactions/sensor/gson/SensorTypeAdapter.java index 850408b4..26baf8ed 100644 --- a/co-simulation/lib/mosaic-interactions/src/main/java/org/eclipse/mosaic/interactions/sensor/gson/SensorTypeAdapter.java +++ b/co-simulation/lib/mosaic-interactions/src/main/java/org/eclipse/mosaic/interactions/sensor/gson/SensorTypeAdapter.java @@ -31,7 +31,6 @@ public class SensorTypeAdapter implements JsonSerializer, JsonDeseri @Override public SensorType deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { - String value = json.getAsString(); return SensorType.fromName(json.getAsString()); }