Skip to content

Commit 31d0d72

Browse files
committed
Add abstract delegate converter class
1 parent cf53740 commit 31d0d72

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
package org.scijava.convert;
3+
4+
import org.scijava.plugin.Parameter;
5+
6+
/**
7+
* Abstract superclass for {@link Converter} plugins that delegate to other
8+
* converters to chain two conversion steps together.
9+
*
10+
* @author Jan Eglinger
11+
* @param <I> the input type
12+
* @param <D> the delegate type
13+
* @param <O> the output type
14+
*/
15+
public abstract class AbstractDelegateConverter<I, D, O> extends
16+
AbstractConverter<I, O>
17+
{
18+
19+
@Parameter
20+
private ConvertService convertService;
21+
22+
@Override
23+
public <T> T convert(Object src, Class<T> dest) {
24+
D delegate = convertService.convert(src, getDelegateType());
25+
return convertService.convert(delegate, dest);
26+
}
27+
28+
protected abstract Class<D> getDelegateType();
29+
}

0 commit comments

Comments
 (0)