Skip to content

Commit 98f696f

Browse files
committed
Merge pull request #209 from scijava/fix-ignore-step-size
Fix ignore step size
2 parents ff4bee7 + fdf7494 commit 98f696f

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/main/java/org/scijava/command/CommandModuleItem.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,14 @@ public T getMaximumValue() {
145145

146146
@Override
147147
public Number getStepSize() {
148-
return tValue(getParameter().stepSize(), Number.class);
148+
final String value = getParameter().stepSize();
149+
try {
150+
final double stepSize = Double.parseDouble(value);
151+
return stepSize;
152+
}
153+
catch (final NumberFormatException exc) {
154+
return tValue(value, Number.class);
155+
}
149156
}
150157

151158
@Override

src/test/java/org/scijava/command/InvalidCommandTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ public void testValid() {
7171
final List<ValidityProblem> problems = info.getProblems();
7272
assertNotNull(problems);
7373
assertEquals(0, problems.size());
74+
75+
final Number stepSize = info.getInput("x").getStepSize();
76+
assertNotNull(stepSize);
77+
assertEquals(10, stepSize.intValue());
7478
}
7579

7680
@Test
@@ -101,7 +105,7 @@ public void testInvalid() {
101105
@Plugin(type = Command.class)
102106
public static class ValidCommand implements Command {
103107

104-
@Parameter
108+
@Parameter(stepSize = "10")
105109
private double x;
106110

107111
@Parameter(type = ItemIO.OUTPUT)

0 commit comments

Comments
 (0)