4646import org .scijava .plugin .Parameter ;
4747import org .scijava .util .ConversionUtils ;
4848import org .scijava .util .GenericUtils ;
49- import org .scijava .util .NumberUtils ;
5049
5150/**
5251 * {@link ModuleItem} implementation describing an input or output of a command.
@@ -136,20 +135,17 @@ public String getWidgetStyle() {
136135
137136 @ Override
138137 public T getMinimumValue () {
139- final Class <T > saneType = ConversionUtils .getNonprimitiveType (getType ());
140- return ConversionUtils .convert (getParameter ().min (), saneType );
138+ return tValue (getParameter ().min ());
141139 }
142140
143141 @ Override
144142 public T getMaximumValue () {
145- final Class <T > saneType = ConversionUtils .getNonprimitiveType (getType ());
146- return ConversionUtils .convert (getParameter ().max (), saneType );
143+ return tValue (getParameter ().max ());
147144 }
148145
149146 @ Override
150147 public Number getStepSize () {
151- final Class <T > saneType = ConversionUtils .getNonprimitiveType (getType ());
152- return NumberUtils .toNumber (getParameter ().stepSize (), saneType );
148+ return tValue (getParameter ().stepSize (), Number .class );
153149 }
154150
155151 @ Override
@@ -161,7 +157,7 @@ public int getColumnCount() {
161157 public List <T > getChoices () {
162158 final ArrayList <T > choices = new ArrayList <T >();
163159 for (final String choice : getParameter ().choices ()) {
164- choices .add (ConversionUtils . convert (choice , getType () ));
160+ choices .add (tValue (choice ));
165161 }
166162 return choices ;
167163 }
@@ -201,4 +197,15 @@ public String getName() {
201197 return field .getName ();
202198 }
203199
200+ // -- Helper methods --
201+
202+ private T tValue (final String value ) {
203+ return tValue (value , getType ());
204+ }
205+
206+ private <D > D tValue (final String value , final Class <D > type ) {
207+ final Class <D > saneType = ConversionUtils .getNonprimitiveType (type );
208+ return ConversionUtils .convert (value , saneType );
209+ }
210+
204211}
0 commit comments