Skip to content

Commit 71e1053

Browse files
committed
Add getPreferredDataType(Class) to KNIMEConverterService
Signed-off-by: Squareys <squareys@googlemail.com>
1 parent 6ea385c commit 71e1053

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

org.knime.scijava.commands/src/org/knime/scijava/commands/converter/DefaultKNIMEConverterService.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,4 +200,10 @@ public Collection<JavaToDataCellConverterFactory<?>> getMatchingFactories(
200200
ClassUtil.ensureObjectType(javaType));
201201
}
202202

203+
@Override
204+
public Optional<DataType> getPreferredDataType(final Class<?> type) {
205+
return m_outRegistry.getFactoriesForSourceType(type).stream()
206+
.findFirst().map(fac -> fac.getDestinationType());
207+
}
208+
203209
}

org.knime.scijava.commands/src/org/knime/scijava/commands/converter/KNIMEConverterService.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,13 @@ DataCell convertToKnime(Object in, Class<?> inType, DataType type,
9999
*/
100100
Collection<JavaToDataCellConverterFactory<?>> getMatchingFactories(
101101
Class<?> javaType);
102+
103+
/**
104+
* Get the preferred {@link DataType} to convert a certain Java type into.
105+
*
106+
* @param type
107+
* the Java type
108+
* @return an optional DataType which the java type can be converted into.
109+
*/
110+
Optional<DataType> getPreferredDataType(final Class<?> type);
102111
}

0 commit comments

Comments
 (0)