Commit 2eee9b94 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

function returns list instead of modifying parameter

parent c2e88a2f
...@@ -152,8 +152,8 @@ public class ColorSchemaReader { ...@@ -152,8 +152,8 @@ public class ColorSchemaReader {
String[] columns = line.split("\t"); String[] columns = line.split("\t");
Map<ColorSchemaColumn, Integer> schemaColumns = new HashMap<>(); Map<ColorSchemaColumn, Integer> schemaColumns = new HashMap<>();
List<Pair<MiriamType, Integer>> customIdentifiers = new ArrayList<>(); List<Pair<MiriamType, Integer>> customIdentifiers = parseColumns(columns, schemaColumns,
parseColumns(columns, schemaColumns, customIdentifiers, ColorSchemaType.GENETIC_VARIANT); ColorSchemaType.GENETIC_VARIANT);
Integer colorColumn = schemaColumns.get(ColorSchemaColumn.COLOR); Integer colorColumn = schemaColumns.get(ColorSchemaColumn.COLOR);
Integer contigColumn = schemaColumns.get(ColorSchemaColumn.CONTIG); Integer contigColumn = schemaColumns.get(ColorSchemaColumn.CONTIG);
if (contigColumn == null) { if (contigColumn == null) {
...@@ -481,8 +481,7 @@ public class ColorSchemaReader { ...@@ -481,8 +481,7 @@ public class ColorSchemaReader {
String[] columns = line.split("\t"); String[] columns = line.split("\t");
Map<ColorSchemaColumn, Integer> schemaColumns = new HashMap<>(); Map<ColorSchemaColumn, Integer> schemaColumns = new HashMap<>();
List<Pair<MiriamType, Integer>> customIdentifiers = new ArrayList<>(); List<Pair<MiriamType, Integer>> customIdentifiers = parseColumns(columns, schemaColumns, ColorSchemaType.GENERIC);
parseColumns(columns, schemaColumns, customIdentifiers, ColorSchemaType.GENERIC);
Integer valueColumn = schemaColumns.get(ColorSchemaColumn.VALUE); Integer valueColumn = schemaColumns.get(ColorSchemaColumn.VALUE);
Integer colorColumn = schemaColumns.get(ColorSchemaColumn.COLOR); Integer colorColumn = schemaColumns.get(ColorSchemaColumn.COLOR);
...@@ -680,8 +679,9 @@ public class ColorSchemaReader { ...@@ -680,8 +679,9 @@ public class ColorSchemaReader {
* @throws InvalidColorSchemaException * @throws InvalidColorSchemaException
* thrown when the list of column headers contain invalid value * thrown when the list of column headers contain invalid value
*/ */
public void parseColumns(String[] columns, Map<ColorSchemaColumn, Integer> schemaColumns, public List<Pair<MiriamType, Integer>> parseColumns(String[] columns, Map<ColorSchemaColumn, Integer> schemaColumns,
List<Pair<MiriamType, Integer>> customIdentifiers, ColorSchemaType type) throws InvalidColorSchemaException { ColorSchemaType type) throws InvalidColorSchemaException {
List<Pair<MiriamType, Integer>> result = new ArrayList<>();
Map<String, MiriamType> acceptableIdentifiers = new HashMap<>(); Map<String, MiriamType> acceptableIdentifiers = new HashMap<>();
Map<String, MiriamType> deprecatedIdentifiers = new HashMap<>(); Map<String, MiriamType> deprecatedIdentifiers = new HashMap<>();
for (MiriamType miriamType : MiriamType.values()) { for (MiriamType miriamType : MiriamType.values()) {
...@@ -701,9 +701,9 @@ public class ColorSchemaReader { ...@@ -701,9 +701,9 @@ public class ColorSchemaReader {
} }
if (!found) { if (!found) {
if (acceptableIdentifiers.keySet().contains(columns[i].toLowerCase())) { if (acceptableIdentifiers.keySet().contains(columns[i].toLowerCase())) {
customIdentifiers.add(new Pair<>(acceptableIdentifiers.get(columns[i].toLowerCase()), i)); result.add(new Pair<>(acceptableIdentifiers.get(columns[i].toLowerCase()), i));
} else if (deprecatedIdentifiers.keySet().contains(columns[i].toLowerCase())) { } else if (deprecatedIdentifiers.keySet().contains(columns[i].toLowerCase())) {
customIdentifiers.add(new Pair<>(deprecatedIdentifiers.get(columns[i].toLowerCase()), i)); result.add(new Pair<>(deprecatedIdentifiers.get(columns[i].toLowerCase()), i));
} else { } else {
String columnNames = ""; String columnNames = "";
for (ColorSchemaColumn schemaColumn : ColorSchemaColumn.values()) { for (ColorSchemaColumn schemaColumn : ColorSchemaColumn.values()) {
...@@ -719,6 +719,7 @@ public class ColorSchemaReader { ...@@ -719,6 +719,7 @@ public class ColorSchemaReader {
} }
} }
} }
return result;
} }
/** /**
......
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