Commit 0117e14f authored by Stefan Schuhbaeck's avatar Stefan Schuhbaeck
Browse files

#78 Test for null and replace with -1 and log this as warning

parent c8667eba
......@@ -38,6 +38,14 @@ public class TimestepPedestrianIdKey implements DataKey<TimestepPedestrianIdKey>
return new String[] { TimestepKey.getHeader(), PedestrianIdKey.getHeader() };
}
@Override
public String toString() {
return "TimestepPedestrianIdKey{" +
"timestep=" + timestep +
", pedestrianId=" + pedestrianId +
'}';
}
@Override
public int hashCode() {
final int prime = 31;
......
package org.vadere.simulator.projects.dataprocessing.processor;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.vadere.annotation.factories.dataprocessors.DataProcessorClass;
import org.vadere.simulator.control.SimulationState;
import org.vadere.simulator.models.MainModel;
......@@ -9,10 +11,13 @@ import org.vadere.simulator.projects.dataprocessing.ProcessorManager;
import org.vadere.simulator.projects.dataprocessing.datakey.TimestepPedestrianIdKey;
import java.util.Optional;
import java.util.Random;
@DataProcessorClass
public class PedestrianGroupIDProcessor extends DataProcessor<TimestepPedestrianIdKey, Integer>{
private static Logger logger = LogManager.getLogger(PedestrianGroupIDProcessor.class);
public PedestrianGroupIDProcessor(){
super("groupId");
}
......@@ -42,6 +47,12 @@ public class PedestrianGroupIDProcessor extends DataProcessor<TimestepPedestrian
public String[] toStrings(TimestepPedestrianIdKey key){
Integer i = this.getValue(key);
if (i == null) {
logger.warn(String.format("PedestrianGroupIDProcessor does not has Data for Key: %s",
key.toString()));
i = -1;
}
return new String[]{Integer.toString(i)};
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment