package de.dhbwstuttgart.parser;

import de.dhbwstuttgart.server.packet.dataContainers.ISerializableData;
import de.dhbwstuttgart.server.packet.dataContainers.KeyStorage;
import de.dhbwstuttgart.server.packet.dataContainers.serialized.SerialMap;

public record SourceLoc(String file, int line) implements ISerializableData {


  @Override
  public SerialMap toSerial(KeyStorage keyStorage) {
    var serialized = new SerialMap();
    serialized.put("file", file);
    serialized.put("line", line);
    return serialized;
  }

  public static SourceLoc fromSerial(SerialMap data) {
    return new SourceLoc(
      data.getValue("file").getOf(String.class),
      data.getValue("line").getOf(Integer.class)
    );
  }

}
