Skip to content

Commit d9df9e6

Browse files
committed
Change result from list to map
1 parent 9b209f5 commit d9df9e6

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/main/java/com/nordstrom/common/file/VolumeInfo.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import java.io.File;
55
import java.io.IOException;
66
import java.io.InputStreamReader;
7-
import java.util.ArrayList;
8-
import java.util.List;
7+
import java.util.HashMap;
8+
import java.util.Map;
99
import java.util.regex.Matcher;
1010
import java.util.regex.Pattern;
1111

@@ -19,8 +19,8 @@ private VolumeInfo() {
1919
throw new AssertionError("VolumeInfo is a static utility class that cannot be instantiated");
2020
}
2121

22-
public static List<VolumeProps> getVolumeProps() throws IOException {
23-
List<VolumeProps> propsList = new ArrayList<>();
22+
public static Map<String, VolumeProps> getVolumeProps() throws IOException {
23+
Map<String, VolumeProps> propsList = new HashMap<>();
2424
Pattern template = Pattern.compile("(.+) on (.+) type (.+) \\((.+)\\)");
2525

2626
Process mountProcess;
@@ -43,7 +43,7 @@ public static List<VolumeProps> getVolumeProps() throws IOException {
4343
String[] opts = matcher.group(4).split(",");
4444
VolumeProps props = new VolumeProps(spec, file, type, opts);
4545
if (props.size > 0L) {
46-
propsList.add(props);
46+
propsList.put(spec, props);
4747
}
4848
}
4949
}

src/test/java/com/nordstrom/common/file/VolumeInfoTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.nordstrom.common.file;
22

33
import java.io.IOException;
4-
import java.util.List;
4+
import java.util.Map;
55

66
import org.testng.annotations.Test;
77

@@ -11,8 +11,8 @@ public class VolumeInfoTest {
1111

1212
@Test
1313
public void test() throws IOException {
14-
List<VolumeProps> propsList = VolumeInfo.getVolumeProps();
15-
for (VolumeProps thisProps : propsList) {
14+
Map<String, VolumeProps> propsList = VolumeInfo.getVolumeProps();
15+
for (VolumeProps thisProps : propsList.values()) {
1616
System.out.println("spec: " + thisProps.getSpec());
1717
System.out.println("file: " + thisProps.getFile());
1818
System.out.println("type: " + thisProps.getType());

0 commit comments

Comments
 (0)