Skip to content

Commit

Permalink
Addressed final sonar code smell issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbourelly999 committed Jul 27, 2023
1 parent a5d58ec commit 364fcae
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public class SensorTypeAdapter implements JsonSerializer<SensorType>, JsonDeseri
@Override
public SensorType deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
throws JsonParseException {
String value = json.getAsString();
return SensorType.fromName(json.getAsString());
}

Expand Down

0 comments on commit 364fcae

Please sign in to comment.