StepPattern.java

  1. package org.jbehave.core.model;

  2. import org.apache.commons.lang3.builder.ToStringBuilder;
  3. import org.apache.commons.lang3.builder.ToStringStyle;
  4. import org.jbehave.core.parsers.RegexStepMatcher;
  5. import org.jbehave.core.parsers.StepMatcher;
  6. import org.jbehave.core.steps.StepType;

  7. /**
  8.  * <p>
  9.  * Represents a step pattern, as provided in the method annotations.  
  10.  * This pattern will in turn be resolved by the chosen {@link StepMatcher},
  11.  * e.g. a regex pattern if using the {@link RegexStepMatcher}
  12.  * </p>
  13.  */
  14. public class StepPattern {

  15.     private StepType stepType;
  16.     private final String annotated;
  17.     private final String resolved;
  18.    
  19.     public StepPattern(StepType stepType, String annotated, String resolved) {
  20.         this.stepType = stepType;
  21.         this.annotated = annotated;
  22.         this.resolved = resolved;
  23.     }

  24.     /**
  25.      * Returns the step pattern as provided in the method annotation
  26.      * @return The String representing the annotated pattern
  27.      */
  28.     public String annotated() {
  29.         return annotated;        
  30.     }
  31.    
  32.     /**
  33.      * Return the step pattern as resolved by the step matcher
  34.      * @return The String representing the resolved pattern
  35.      */
  36.     public String resolved() {
  37.         return resolved;
  38.     }

  39.     /**
  40.      * Return the step type
  41.      * @return The enum for the StepType
  42.      */
  43.     public StepType type() {
  44.         return stepType;
  45.     }

  46.     @Override
  47.     public String toString() {
  48.         return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
  49.     }
  50.    
  51. }