Skip to content

Commit d18f408

Browse files
committed
ConversionUtils: clean up naming and javadoc
It was copy/pasted from Prefs, and was also out of date in some places from when the service was still called ConversionService.
1 parent 44ccacd commit d18f408

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

src/main/java/org/scijava/util/ConversionUtils.java

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import org.scijava.convert.ConvertService;
3838
import org.scijava.convert.Converter;
3939
import org.scijava.convert.DefaultConverter;
40-
import org.scijava.prefs.DefaultPrefService;
4140

4241
/**
4342
* Useful methods for converting and casting between classes and types.
@@ -50,9 +49,9 @@
5049
*/
5150
public class ConversionUtils {
5251

53-
private static ConvertService conversionService;
52+
private static ConvertService convertService;
5453

55-
private static Converter conversionHandlerNoContext;
54+
private static Converter converterNoContext;
5655

5756
private static double servicePriority = 0.0;
5857

@@ -172,18 +171,18 @@ public static <T> T getNullValue(final Class<T> type) {
172171
return result;
173172
}
174173

175-
// -- PrefService setter --
174+
// -- ConvertService setter --
176175

177176
/**
178-
* Sets the {@link ConvertService}
177+
* Sets the {@link ConvertService} to use for handling conversion requests.
179178
*/
180-
public static void setDelegateService(final ConvertService conversionService,
179+
public static void setDelegateService(final ConvertService convertService,
181180
final double priority)
182181
{
183-
if (ConversionUtils.conversionService == null ||
182+
if (ConversionUtils.convertService == null ||
184183
Double.compare(priority, servicePriority) > 0)
185184
{
186-
ConversionUtils.conversionService = conversionService;
185+
ConversionUtils.convertService = convertService;
187186
servicePriority = priority;
188187
}
189188
}
@@ -265,18 +264,17 @@ public static Class<?> getComponentClass(final Type type) {
265264
//-- Helper methods --
266265

267266
/**
268-
* Gets the delegate {@link ConvertService} to use for preference operations.
269-
* If this service has not been explicitly set, then a
270-
* {@link DefaultPrefService} will be used.
267+
* Gets the {@link Converter} to use for the given conversion request. If the
268+
* delegate {@link ConvertService} has not been explicitly set, then a
269+
* {@link DefaultConverter} will be used.
271270
*
272-
* @return The current {@link ConvertService} to use for delegation.
271+
* @return The {@link Converter} to use for handling the given request.
273272
*/
274273
private static Converter handler(final ConversionRequest data) {
275-
if (conversionService != null) return conversionService.getHandler(data);
274+
if (convertService != null) return convertService.getHandler(data);
276275

277-
if (conversionHandlerNoContext == null) conversionHandlerNoContext =
278-
new DefaultConverter();
276+
if (converterNoContext == null) converterNoContext = new DefaultConverter();
279277

280-
return conversionHandlerNoContext;
278+
return converterNoContext;
281279
}
282280
}

0 commit comments

Comments
 (0)