All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.dekorate.application.adapter.ApplicationConfigAdapter Maven / Gradle / Ivy

There is a newer version: 2.0.0.beta8
Show newest version
package io.dekorate.application.adapter;

import io.dekorate.application.config.ApplicationConfigBuilder;
import java.nio.file.Path;
import java.util.stream.Collectors;
import io.dekorate.application.annotation.EnableApplicationResource;
import java.lang.String;
import io.dekorate.application.config.Info;
import io.dekorate.application.config.Contact;
import java.util.Comparator;
import io.dekorate.project.Project;
import io.dekorate.application.config.ApplicationConfig;
import io.dekorate.project.BuildInfo;
import io.dekorate.application.config.Icon;
import io.dekorate.project.ScmInfo;
import java.util.Arrays;
import java.util.Map;
import io.dekorate.application.config.Link;

public class ApplicationConfigAdapter{



    public static ApplicationConfig adapt(EnableApplicationResource instance){
            return newBuilder(instance).build();
    }

    public static ApplicationConfigBuilder newBuilder(EnableApplicationResource instance){
            return new ApplicationConfigBuilder(new io.dekorate.application.config.ApplicationConfig(null,
            null,
            instance.group(),
            instance.name(),
            instance.version(),
            Arrays.asList(instance.owners()).stream().map(i ->new io.dekorate.application.config.Contact(i.name(),
            i.email(),
            i.url())).collect(Collectors.toList()).toArray(new io.dekorate.application.config.Contact[0]),
            Arrays.asList(instance.maintainers()).stream().map(i ->new io.dekorate.application.config.Contact(i.name(),
            i.email(),
            i.url())).collect(Collectors.toList()).toArray(new io.dekorate.application.config.Contact[0]),
            Arrays.asList(instance.info()).stream().map(i ->new io.dekorate.application.config.Info(i.name(),
            i.value(),
            i.type(),
            i.valueFrom())).collect(Collectors.toList()).toArray(new io.dekorate.application.config.Info[0]),
            Arrays.asList(instance.icons()).stream().map(i ->new io.dekorate.application.config.Icon(i.type(),
            i.src(),
            i.size())).collect(Collectors.toList()).toArray(new io.dekorate.application.config.Icon[0]),
            Arrays.asList(instance.links()).stream().map(i ->new io.dekorate.application.config.Link(i.description(),
            i.url())).collect(Collectors.toList()).toArray(new io.dekorate.application.config.Link[0]),
            instance.notes(),
            instance.keywords()));
    }

    public static ApplicationConfig adapt(Map map){
            return new io.dekorate.application.config.ApplicationConfig(
null,
null,
               (String)(map instanceof Map ? ((Map)map).getOrDefault("group", "") : ""),
               (String)(map instanceof Map ? ((Map)map).getOrDefault("name", "") : ""),
               (String)(map instanceof Map ? ((Map)map).getOrDefault("version", "") : ""),
               Arrays.stream((Map[])(map instanceof Map ? ((Map)map).getOrDefault("owners" , new Map[0]) : new Map[0])).map(i ->new io.dekorate.application.config.Contact(
               (String)(i instanceof Map ? ((Map)i).getOrDefault("name", null) : null),
               (String)(i instanceof Map ? ((Map)i).getOrDefault("email", null) : null),
               (String)(i instanceof Map ? ((Map)i).getOrDefault("url", null) : null))).toArray(size-> new io.dekorate.application.config.Contact[size]),
               Arrays.stream((Map[])(map instanceof Map ? ((Map)map).getOrDefault("maintainers" , new Map[0]) : new Map[0])).map(i ->new io.dekorate.application.config.Contact(
               (String)(i instanceof Map ? ((Map)i).getOrDefault("name", null) : null),
               (String)(i instanceof Map ? ((Map)i).getOrDefault("email", null) : null),
               (String)(i instanceof Map ? ((Map)i).getOrDefault("url", null) : null))).toArray(size-> new io.dekorate.application.config.Contact[size]),
               Arrays.stream((Map[])(map instanceof Map ? ((Map)map).getOrDefault("info" , new Map[0]) : new Map[0])).map(i ->new io.dekorate.application.config.Info(
               (String)(i instanceof Map ? ((Map)i).getOrDefault("name", null) : null),
               (String)(i instanceof Map ? ((Map)i).getOrDefault("value", "") : ""),
               (String)(i instanceof Map ? ((Map)i).getOrDefault("type", "") : ""),
               (String)(i instanceof Map ? ((Map)i).getOrDefault("valueFrom", "") : ""))).toArray(size-> new io.dekorate.application.config.Info[size]),
               Arrays.stream((Map[])(map instanceof Map ? ((Map)map).getOrDefault("icons" , new Map[0]) : new Map[0])).map(i ->new io.dekorate.application.config.Icon(
               (String)(i instanceof Map ? ((Map)i).getOrDefault("type", null) : null),
               (String)(i instanceof Map ? ((Map)i).getOrDefault("src", null) : null),
               (String)(i instanceof Map ? ((Map)i).getOrDefault("size", null) : null))).toArray(size-> new io.dekorate.application.config.Icon[size]),
               Arrays.stream((Map[])(map instanceof Map ? ((Map)map).getOrDefault("links" , new Map[0]) : new Map[0])).map(i ->new io.dekorate.application.config.Link(
               (String)(i instanceof Map ? ((Map)i).getOrDefault("description", null) : null),
               (String)(i instanceof Map ? ((Map)i).getOrDefault("url", null) : null))).toArray(size-> new io.dekorate.application.config.Link[size]),
               (String)(map instanceof Map ? ((Map)map).getOrDefault("notes", "") : ""),
               (String[])(map instanceof Map ? ((Map)map).getOrDefault("keywords", new java.lang.String[0]) : new java.lang.String[0]));
    }

    public static ApplicationConfigBuilder newBuilder(Map map){
            return new ApplicationConfigBuilder(new io.dekorate.application.config.ApplicationConfig(
null,
null,
               (String)(map instanceof Map ? ((Map)map).getOrDefault("group", "") : ""),
               (String)(map instanceof Map ? ((Map)map).getOrDefault("name", "") : ""),
               (String)(map instanceof Map ? ((Map)map).getOrDefault("version", "") : ""),
               Arrays.stream((Map[])(map instanceof Map ? ((Map)map).getOrDefault("owners" , new Map[0]) : new Map[0])).map(i ->new io.dekorate.application.config.Contact(
               (String)(i instanceof Map ? ((Map)i).getOrDefault("name", null) : null),
               (String)(i instanceof Map ? ((Map)i).getOrDefault("email", null) : null),
               (String)(i instanceof Map ? ((Map)i).getOrDefault("url", null) : null))).toArray(size-> new io.dekorate.application.config.Contact[size]),
               Arrays.stream((Map[])(map instanceof Map ? ((Map)map).getOrDefault("maintainers" , new Map[0]) : new Map[0])).map(i ->new io.dekorate.application.config.Contact(
               (String)(i instanceof Map ? ((Map)i).getOrDefault("name", null) : null),
               (String)(i instanceof Map ? ((Map)i).getOrDefault("email", null) : null),
               (String)(i instanceof Map ? ((Map)i).getOrDefault("url", null) : null))).toArray(size-> new io.dekorate.application.config.Contact[size]),
               Arrays.stream((Map[])(map instanceof Map ? ((Map)map).getOrDefault("info" , new Map[0]) : new Map[0])).map(i ->new io.dekorate.application.config.Info(
               (String)(i instanceof Map ? ((Map)i).getOrDefault("name", null) : null),
               (String)(i instanceof Map ? ((Map)i).getOrDefault("value", "") : ""),
               (String)(i instanceof Map ? ((Map)i).getOrDefault("type", "") : ""),
               (String)(i instanceof Map ? ((Map)i).getOrDefault("valueFrom", "") : ""))).toArray(size-> new io.dekorate.application.config.Info[size]),
               Arrays.stream((Map[])(map instanceof Map ? ((Map)map).getOrDefault("icons" , new Map[0]) : new Map[0])).map(i ->new io.dekorate.application.config.Icon(
               (String)(i instanceof Map ? ((Map)i).getOrDefault("type", null) : null),
               (String)(i instanceof Map ? ((Map)i).getOrDefault("src", null) : null),
               (String)(i instanceof Map ? ((Map)i).getOrDefault("size", null) : null))).toArray(size-> new io.dekorate.application.config.Icon[size]),
               Arrays.stream((Map[])(map instanceof Map ? ((Map)map).getOrDefault("links" , new Map[0]) : new Map[0])).map(i ->new io.dekorate.application.config.Link(
               (String)(i instanceof Map ? ((Map)i).getOrDefault("description", null) : null),
               (String)(i instanceof Map ? ((Map)i).getOrDefault("url", null) : null))).toArray(size-> new io.dekorate.application.config.Link[size]),
               (String)(map instanceof Map ? ((Map)map).getOrDefault("notes", "") : ""),
               (String[])(map instanceof Map ? ((Map)map).getOrDefault("keywords", new java.lang.String[0]) : new java.lang.String[0])));
    }




}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy