From 2d0b84fb0f6856701aca6a13fdc42490c1c17f0a Mon Sep 17 00:00:00 2001 From: Christophe Dame Date: Thu, 23 Jun 2022 09:59:23 +0200 Subject: [PATCH] make code java 8 compliant --- .../io/camunda/operate/CamundaOperateConstants.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/camunda/operate/CamundaOperateConstants.java b/src/main/java/io/camunda/operate/CamundaOperateConstants.java index 026597d..1553d96 100644 --- a/src/main/java/io/camunda/operate/CamundaOperateConstants.java +++ b/src/main/java/io/camunda/operate/CamundaOperateConstants.java @@ -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; @@ -10,10 +13,18 @@ public class CamundaOperateConstants { - public static Map, String> OBJECT_APIS = Map.of(ProcessDefinition.class, "/v1/process-definitions", + public static Map, 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, String> toMap(Object... array) { + AbstractMap.SimpleEntry, String>[] entryArray = new AbstractMap.SimpleEntry[array.length/2]; + for(int i=0;i, String>((Class)array[i*2], (String) array[i*2+1]); + } + return Stream.of(entryArray) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + } }