Enhancement on Task #10070

Updated enum list


git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/Common/workspace-task-executor-library@167367 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2018-05-08 13:31:17 +00:00
parent db36261b56
commit 7d7933c41b
3 changed files with 12 additions and 10 deletions

View File

@ -24,7 +24,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<distroDirectory>distro</distroDirectory>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencyManagement>

View File

@ -325,10 +325,10 @@ public class WorkspaceDataMinerTaskExecutor implements ExecutableTask<TaskConfig
* @return the parameter types
*/
public List<TaskParameterType> getParameterTypes(){
String[] typeNames = Converter.convertEnumNamesToArraString(ParameterType.class);
List<ParameterType> typeNames = Converter.getEnumList(ParameterType.class);
List<TaskParameterType> types = new ArrayList<TaskParameterType>();
for (String string : typeNames) {
types.add(new TaskParameterType(string));
for (ParameterType parameterType : typeNames) {
types.add(new TaskParameterType(parameterType.name()));
}
return types;

View File

@ -3,7 +3,9 @@
*/
package org.gcube.common.workspacetaskexecutor.util;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskComputation;
import org.gcube.data.analysis.dataminermanagercl.shared.data.computations.ComputationId;
@ -48,14 +50,14 @@ public class Converter {
}
/**
* Convert enum names to arra string.
* Gets the enum list.
*
* @param e the e
* @return the string[]
* @param <E> the element type
* @param enumClass the enum class
* @return the enum list
*/
public static String[] convertEnumNamesToArraString(Class<? extends Enum<?>> e){
return Arrays.stream(e.getEnumConstants()).map(Enum::name).toArray(String[]::new);
public static <E extends Enum<E>> List<E> getEnumList(Class<E> enumClass) {
return new ArrayList<E>(Arrays.asList(enumClass.getEnumConstants()));
}
}