Skip to content

Commit

Permalink
make code java 8 compliant
Browse files Browse the repository at this point in the history
  • Loading branch information
chDame committed Jun 23, 2022
1 parent 73e67e0 commit 2d0b84f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/main/java/io/camunda/operate/CamundaOperateConstants.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package io.camunda.operate;

import java.util.AbstractMap;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import io.camunda.operate.dto.FlownodeInstance;
import io.camunda.operate.dto.Incident;
Expand All @@ -10,10 +13,18 @@

public class CamundaOperateConstants {

public static Map<Class<?>, String> OBJECT_APIS = Map.of(ProcessDefinition.class, "/v1/process-definitions",
public static Map<Class<?>, String> OBJECT_APIS = toMap(ProcessDefinition.class, "/v1/process-definitions",
ProcessInstance.class, "/v1/process-instances",
FlownodeInstance.class, "/v1/flownode-instances",
Incident.class, "/v1/incidents",
Variable.class, "/v1/variables");

private static Map<Class<?>, String> toMap(Object... array) {
AbstractMap.SimpleEntry<Class<?>, String>[] entryArray = new AbstractMap.SimpleEntry[array.length/2];
for(int i=0;i<entryArray.length;i++) {
entryArray[i]= new AbstractMap.SimpleEntry<Class<?>, String>((Class<?>)array[i*2], (String) array[i*2+1]);
}
return Stream.of(entryArray)
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
}
}

0 comments on commit 2d0b84f

Please sign in to comment.