StoryMap.java

  1. package org.jbehave.core.model;

  2. import java.util.ArrayList;
  3. import java.util.List;
  4. import java.util.Set;

  5. import org.apache.commons.lang3.builder.ToStringBuilder;
  6. import org.apache.commons.lang3.builder.ToStringStyle;

  7. /**
  8.  *  Groups a set of {@link Story}s by meta filter.
  9.  */
  10. public class StoryMap {

  11.     private final String metaFilter;
  12.     private final Set<Story> stories;
  13.    
  14.     public StoryMap(String metaFilter, Set<Story> stories) {
  15.         this.metaFilter = metaFilter;
  16.         this.stories = stories;        
  17.     }

  18.     public String getMetaFilter() {
  19.         return metaFilter;
  20.     }
  21.    
  22.     public List<Story> getStories() {
  23.         return new ArrayList<>(stories);
  24.     }
  25.    
  26.     public List<String> getStoryPaths() {
  27.         List<String> paths = new ArrayList<>();
  28.         for (Story story : stories) {
  29.             paths.add(story.getPath());
  30.         }
  31.         return paths;
  32.     }

  33.     @Override
  34.     public String toString() {
  35.         return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append(metaFilter).append(getStoryPaths())
  36.                 .toString();
  37.     }

  38. }