1 | |
package org.jbehave.core.model; |
2 | |
|
3 | |
import java.util.ArrayList; |
4 | |
import java.util.LinkedHashMap; |
5 | |
import java.util.List; |
6 | |
import java.util.Map; |
7 | |
|
8 | |
import org.apache.commons.lang.builder.ToStringBuilder; |
9 | |
import org.apache.commons.lang.builder.ToStringStyle; |
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
public class StoryMaps { |
15 | |
|
16 | 3 | private Map<String, StoryMap> indexed = new LinkedHashMap<String, StoryMap>(); |
17 | |
|
18 | 3 | public StoryMaps(List<StoryMap> maps) { |
19 | 3 | index(maps); |
20 | 3 | } |
21 | |
|
22 | |
private void index(List<StoryMap> storyMaps) { |
23 | 3 | for (StoryMap storyMap : storyMaps) { |
24 | 3 | indexed.put(storyMap.getMetaFilter(), storyMap); |
25 | |
} |
26 | 3 | } |
27 | |
|
28 | |
public List<String> getMetaFilters() { |
29 | 4 | return new ArrayList<String>(indexed.keySet()); |
30 | |
} |
31 | |
|
32 | |
public StoryMap getMap(String metaFilter) { |
33 | 9 | return indexed.get(metaFilter); |
34 | |
} |
35 | |
|
36 | |
public List<StoryMap> getMaps() { |
37 | 5 | return new ArrayList<StoryMap>(indexed.values()); |
38 | |
} |
39 | |
|
40 | |
@Override |
41 | |
public String toString() { |
42 | 2 | return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("metaFilters", indexed.keySet()).toString(); |
43 | |
} |
44 | |
|
45 | |
} |