| 1 | |
package org.jbehave.core.steps; |
| 2 | |
|
| 3 | |
import java.lang.reflect.Method; |
| 4 | |
|
| 5 | |
import org.apache.commons.lang.builder.CompareToBuilder; |
| 6 | |
import org.apache.commons.lang.builder.ToStringBuilder; |
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
|
| 18 | |
|
| 19 | 2 | public class Stepdoc implements Comparable<Stepdoc> { |
| 20 | |
|
| 21 | |
private StepType stepType; |
| 22 | |
private String startingWord; |
| 23 | |
private String pattern; |
| 24 | |
private Method method; |
| 25 | |
private Object stepsInstance; |
| 26 | |
|
| 27 | 7 | public Stepdoc(StepCandidate candidate) { |
| 28 | 7 | this.method = candidate.getMethod(); |
| 29 | 7 | this.stepType = candidate.getStepType(); |
| 30 | 7 | this.startingWord = candidate.getStartingWord(); |
| 31 | 7 | this.pattern = candidate.getPatternAsString(); |
| 32 | 7 | this.stepsInstance = candidate.getStepsInstance(); |
| 33 | 7 | } |
| 34 | |
|
| 35 | |
public StepType getStepType() { |
| 36 | 3 | return stepType; |
| 37 | |
} |
| 38 | |
|
| 39 | |
public String getStartingWord() { |
| 40 | 7 | return startingWord; |
| 41 | |
} |
| 42 | |
|
| 43 | |
public String getPattern() { |
| 44 | 7 | return pattern; |
| 45 | |
} |
| 46 | |
|
| 47 | |
public Method getMethod() { |
| 48 | 3 | return method; |
| 49 | |
} |
| 50 | |
|
| 51 | |
public Object getStepsInstance() { |
| 52 | 3 | return stepsInstance; |
| 53 | |
} |
| 54 | |
|
| 55 | |
|
| 56 | |
|
| 57 | |
|
| 58 | |
|
| 59 | |
|
| 60 | |
public String getMethodSignature() { |
| 61 | 7 | String methodSignature = method.toString(); |
| 62 | 7 | return methodSignature.replaceFirst("public void ", ""); |
| 63 | |
} |
| 64 | |
|
| 65 | |
@Override |
| 66 | |
public String toString() { |
| 67 | 15 | return ToStringBuilder.reflectionToString(this).toString(); |
| 68 | |
} |
| 69 | |
|
| 70 | |
public int compareTo(Stepdoc that) { |
| 71 | 2 | return CompareToBuilder.reflectionCompare(this, that); |
| 72 | |
} |
| 73 | |
|
| 74 | |
} |