diff --git a/api/src/main/java/com/technophobia/substeps/model/Configuration.java b/api/src/main/java/com/technophobia/substeps/model/Configuration.java index 2b364af5..89b968f7 100644 --- a/api/src/main/java/com/technophobia/substeps/model/Configuration.java +++ b/api/src/main/java/com/technophobia/substeps/model/Configuration.java @@ -37,9 +37,11 @@ public enum Configuration { private final Config config; - private Configuration() { + Configuration() { logger = LoggerFactory.getLogger(Configuration.class); final String resourceBundleName = resourceBundleName(); + + config = ConfigFactory.load(resourceBundleName); } @@ -80,7 +82,10 @@ private String resourceBundleName() { ext = ".conf"; } - return System.getProperty("environment", "localhost") + ext; + String resourceBundle = System.getProperty("environment", "localhost") + ext; + + System.out.println("loading config from resource bundle: " + resourceBundle); + return resourceBundle; } diff --git a/core/src/main/java/com/technophobia/substeps/glossary/StepDescriptor.java b/core/src/main/java/com/technophobia/substeps/glossary/StepDescriptor.java index e7698f54..9ef64871 100644 --- a/core/src/main/java/com/technophobia/substeps/glossary/StepDescriptor.java +++ b/core/src/main/java/com/technophobia/substeps/glossary/StepDescriptor.java @@ -18,19 +18,21 @@ */ package com.technophobia.substeps.glossary; +import java.util.Arrays; + /** * @author ian */ public class StepDescriptor { private String expression; - + private String regex; private String example; private String section; private String description; + private String[] parameterNames; + private String[] parameterClassNames; - // TODO - add parameter information. - /** * @return the example */ @@ -95,45 +97,50 @@ public void setExpression(final String expression) { } - /* - * (non-Javadoc) - * - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((expression == null) ? 0 : expression.hashCode()); - return result; + public String getRegex() { + return regex; } + public void setRegex(String regex) { + this.regex = regex; + } + + public String[] getParameterClassNames() { + return parameterClassNames; + } + + public void setParameterClassNames(String[] parameterClassNames) { + this.parameterClassNames = parameterClassNames; + } + public String[] getParameterNames() { + return parameterNames; + } + + public void setParameterNames(String[] parameterNames) { + this.parameterNames = parameterNames; + } - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final StepDescriptor other = (StepDescriptor) obj; - if (expression == null) { - if (other.expression != null) { - return false; - } - } else if (!expression.equals(other.expression)) { - return false; - } - return true; + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + StepDescriptor that = (StepDescriptor) o; + + if (expression != null ? !expression.equals(that.expression) : that.expression != null) return false; + if (regex != null ? !regex.equals(that.regex) : that.regex != null) return false; + // Probably incorrect - comparing Object[] arrays with Arrays.equals + if (!Arrays.equals(parameterNames, that.parameterNames)) return false; + // Probably incorrect - comparing Object[] arrays with Arrays.equals + return Arrays.equals(parameterClassNames, that.parameterClassNames); } + @Override + public int hashCode() { + int result = expression != null ? expression.hashCode() : 0; + result = 31 * result + (regex != null ? regex.hashCode() : 0); + result = 31 * result + Arrays.hashCode(parameterNames); + result = 31 * result + Arrays.hashCode(parameterClassNames); + return result; + } } diff --git a/glossary/src/main/java/com/technophobia/substeps/glossary/CustomDoclet.java b/glossary/src/main/java/com/technophobia/substeps/glossary/CustomDoclet.java index 0cbe988a..0d75171c 100644 --- a/glossary/src/main/java/com/technophobia/substeps/glossary/CustomDoclet.java +++ b/glossary/src/main/java/com/technophobia/substeps/glossary/CustomDoclet.java @@ -88,20 +88,32 @@ public static boolean start(final RootDoc root) { expression.setSection(getSingleJavadocTagValue(md, "section")); String line = annotation.value(); + expression.setRegex(line); final Parameter[] parameters = md.parameters(); if (parameters != null && parameters.length > 0) { + + String[] paramNames = new String[parameters.length]; + String[] paramTypes = new String[parameters.length]; + + int i = 0; for (final Parameter p : parameters) { // replace any captures with line = line.replaceFirst("\\([^\\)]*\\)", "<" + p.name() + ">"); - p.typeName(); + paramNames[i] = p.name(); + paramTypes[i] = p.typeName(); + i++; } + + expression.setParameterClassNames(paramTypes); + expression.setParameterNames(paramNames); } line = line.replaceAll("\\?", ""); line = line.replaceAll("\\\\", ""); expression.setExpression(line); + } } }