1 | |
package org.jbehave.core.model; |
2 | |
|
3 | |
import java.util.ArrayList; |
4 | |
import java.util.HashMap; |
5 | |
import java.util.List; |
6 | |
import java.util.Map; |
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
public class StoryLanes { |
13 | |
|
14 | 0 | private Map<String, StoryMap> indexed = new HashMap<String, StoryMap>(); |
15 | |
|
16 | 0 | public StoryLanes(List<StoryMap> storyMaps) { |
17 | 0 | index(storyMaps); |
18 | 0 | } |
19 | |
|
20 | |
private void index(List<StoryMap> storyMaps) { |
21 | 0 | for (StoryMap storyMap : storyMaps) { |
22 | 0 | indexed.put(storyMap.getMetaFilter(), storyMap); |
23 | |
} |
24 | 0 | } |
25 | |
|
26 | |
public List<Story> getStories() { |
27 | 0 | return laneStories(""); |
28 | |
} |
29 | |
|
30 | |
public List<String> getLanes() { |
31 | 0 | List<String> lanes = new ArrayList<String>(indexed.keySet()); |
32 | 0 | lanes.remove(""); |
33 | 0 | return lanes; |
34 | |
} |
35 | |
|
36 | |
public boolean inLane(String lane, Story story) { |
37 | 0 | for (Story laneStory : laneStories(lane)) { |
38 | 0 | if (laneStory.getPath().equals(story.getPath())) { |
39 | 0 | return true; |
40 | |
} |
41 | |
} |
42 | 0 | return false; |
43 | |
} |
44 | |
|
45 | |
private List<Story> laneStories(String lane) { |
46 | 0 | StoryMap storyMap = indexed.get(lane); |
47 | 0 | if (storyMap == null) { |
48 | 0 | return new ArrayList<Story>(); |
49 | |
} |
50 | 0 | return storyMap.getStories(); |
51 | |
} |
52 | |
|
53 | |
} |