io.dekorate.halkyon.adapter.CapabilityConfigAdapter Maven / Gradle / Ivy
package io.dekorate.halkyon.adapter;
import java.nio.file.Path;
import java.util.stream.Collectors;
import io.dekorate.halkyon.config.CapabilityConfig;
import java.lang.String;
import java.util.Comparator;
import io.dekorate.project.Project;
import io.dekorate.halkyon.config.CapabilityConfigBuilder;
import io.dekorate.project.BuildInfo;
import io.dekorate.halkyon.config.Parameter;
import io.dekorate.project.ScmInfo;
import java.util.Arrays;
import io.dekorate.halkyon.annotation.HalkyonCapability;
import java.util.Map;
public class CapabilityConfigAdapter{
public static CapabilityConfig adapt(HalkyonCapability instance){
return newBuilder(instance).build();
}
public static CapabilityConfigBuilder newBuilder(HalkyonCapability instance){
return new CapabilityConfigBuilder(new io.dekorate.halkyon.config.CapabilityConfig(null,
null,
instance.category(),
instance.type(),
instance.name(),
instance.version(),
Arrays.asList(instance.parameters()).stream().map(i ->new io.dekorate.halkyon.config.Parameter(i.name(),
i.value())).collect(Collectors.toList()).toArray(new io.dekorate.halkyon.config.Parameter[0])));
}
public static CapabilityConfig adapt(Map map){
return new io.dekorate.halkyon.config.CapabilityConfig(
null,
null,
(String)(map instanceof Map ? ((Map)map).getOrDefault("category", null) : null),
(String)(map instanceof Map ? ((Map)map).getOrDefault("type", null) : null),
(String)(map instanceof Map ? ((Map)map).getOrDefault("name", null) : null),
(String)(map instanceof Map ? ((Map)map).getOrDefault("version", "") : ""),
Arrays.stream((Map[])(map instanceof Map ? ((Map)map).getOrDefault("parameters" , new Map[0]) : new Map[0])).map(i ->new io.dekorate.halkyon.config.Parameter(
(String)(i instanceof Map ? ((Map)i).getOrDefault("name", null) : null),
(String)(i instanceof Map ? ((Map)i).getOrDefault("value", null) : null))).toArray(size-> new io.dekorate.halkyon.config.Parameter[size]));
}
public static CapabilityConfigBuilder newBuilder(Map map){
return new CapabilityConfigBuilder(new io.dekorate.halkyon.config.CapabilityConfig(
null,
null,
(String)(map instanceof Map ? ((Map)map).getOrDefault("category", null) : null),
(String)(map instanceof Map ? ((Map)map).getOrDefault("type", null) : null),
(String)(map instanceof Map ? ((Map)map).getOrDefault("name", null) : null),
(String)(map instanceof Map ? ((Map)map).getOrDefault("version", "") : ""),
Arrays.stream((Map[])(map instanceof Map ? ((Map)map).getOrDefault("parameters" , new Map[0]) : new Map[0])).map(i ->new io.dekorate.halkyon.config.Parameter(
(String)(i instanceof Map ? ((Map)i).getOrDefault("name", null) : null),
(String)(i instanceof Map ? ((Map)i).getOrDefault("value", null) : null))).toArray(size-> new io.dekorate.halkyon.config.Parameter[size])));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy