/*
 * Copyright 2006-2021 The MZmine Development Team
 *
 * This file is part of MZmine.
 *
 * MZmine is free software; you can redistribute it and/or modify it under the terms of the GNU
 * General Public License as published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * MZmine is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with MZmine; if not,
 * write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 */

package io.github.mzmine.datamodel.features.types;

import io.github.mzmine.datamodel.IMSRawDataFile;
import io.github.mzmine.datamodel.ImsMsMsInfo;
import io.github.mzmine.datamodel.RawDataFile;
import io.github.mzmine.datamodel.features.ModularFeature;
import io.github.mzmine.datamodel.features.ModularFeatureList;
import io.github.mzmine.datamodel.features.ModularFeatureListRow;
import io.github.mzmine.datamodel.features.types.numbers.abstr.ListDataType;
import io.github.mzmine.datamodel.msms.MsMsInfo;
import io.github.mzmine.modules.io.projectload.version_3_0.CONST;
import java.util.List;
import javafx.beans.property.ListProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class MsMsInfoType extends ListDataType<MsMsInfo> {

  @NotNull
  @Override
  public final String getUniqueID() {
    // Never change the ID for compatibility during saving/loading of type
    return "msms_info";
  }

  @NotNull
  @Override
  public String getHeaderString() {
    return "MsMsInfo";
  }

  @NotNull
  @Override
  public @NotNull String getFormattedString(List<MsMsInfo> list) {
    return list != null ? String.valueOf(list.size()) : "0";
  }

  @Override
  public void saveToXML(@NotNull XMLStreamWriter writer, @Nullable Object value,
      @NotNull ModularFeatureList flist, @NotNull ModularFeatureListRow row,
      @Nullable ModularFeature feature, @Nullable RawDataFile file) throws XMLStreamException {
    if (value == null) {
      return;
    }
    if (!(value instanceof List list)) {
      throw new IllegalArgumentException(
          "Wrong value type for data type: " + this.getClass().getName() + " value class: " + value.getClass());
    }

    for (Object o : list) {
      if (o instanceof MsMsInfo info) {
        info.writeToXML(writer);
      }
    }

  }

  @Override
  public Object loadFromXML(@NotNull XMLStreamReader reader, @NotNull ModularFeatureList flist,
      @NotNull ModularFeatureListRow row, @Nullable ModularFeature feature,
      @Nullable RawDataFile file) throws XMLStreamException {

    ObservableList<MsMsInfo> infos = FXCollections.observableArrayList();

    while (reader.hasNext()) {
      reader.next();
      if (reader.isEndElement() && reader.getLocalName().equals(CONST.XML_DATA_TYPE_ELEMENT)) {
        break;
      }
      if (!reader.isStartElement()) {
        continue;
      }

      if (reader.getLocalName().equals(MsMsInfo.XML_ELEMENT)) {
        infos.add(MsMsInfo.loadFromXML(reader, file));
      }
    }
    return infos.isEmpty() ? null : infos;
  }
}

@@ -17,17 +17,17 @@
 2006-202
-1
+0
  The MZm
@@ -518,35 +518,32 @@
  See the GNU
-%0A *
  General
  Public Lice
@@ -522,32 +522,35 @@
  the GNU General
+%0A *
  Public License 
@@ -768,20 +768,16 @@
 1301 USA
-.%0A *
 %0A */%0A%0Apa
@@ -830,105 +830,8 @@
 s;%0A%0A
-import io.github.mzmine.datamodel.IMSRawDataFile;%0Aimport io.github.mzmine.datamodel.ImsMsMsInfo;%0A
 impo
@@ -1280,51 +1280,8 @@
 st;%0A
-import javafx.beans.property.ListProperty;%0A
 impo
@@ -1792,34 +1792,24 @@
 info%22;%0A  %7D%0A%0A
-  @NotNull
 %0A  @Override
@@ -1818,16 +1818,25 @@
  public 
+@NotNull 
 String g
@@ -1882,27 +1882,16 @@
 %22;%0A  %7D%0A%0A
-  @NotNull%0A
   @Overr
@@ -2520,16 +2520,31 @@
  + value
+%0A              
 .getClas

Fix merge conflict