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

io.codearte.accurest.dsl.internal.Multipart.groovy Maven / Gradle / Ivy

package io.codearte.accurest.dsl.internal

import groovy.transform.CompileStatic
import groovy.transform.EqualsAndHashCode
import groovy.transform.ToString

@ToString(includePackage = false, includeFields = true, includeNames = true)
@EqualsAndHashCode(includeFields = true)
@CompileStatic
class Multipart extends DslProperty {

    Multipart(Map multipart) {
        super(extractValue(multipart, { DslProperty p -> p.clientValue}), extractValue(multipart, {DslProperty p -> p.serverValue}))
    }

    private static Map extractValue(Map multipart, Closure valueProvider) {
        return multipart.collectEntries { Map.Entry entry ->
            [(entry.key): valueProvider(entry.value)]
        } as Map
    }

    Multipart(List multipartAsList) {
        super(multipartAsList.collect { DslProperty p -> p.clientValue }, multipartAsList.collect { DslProperty p -> p.serverValue })
    }

    Multipart(Object multipartAsValue) {
        this("${multipartAsValue}")
    }

    Multipart(GString multipartAsValue) {
        super(multipartAsValue, multipartAsValue)
    }

    Multipart(DslProperty multipartAsValue) {
        super(multipartAsValue.clientValue, multipartAsValue.serverValue)
    }

    Multipart(MatchingStrategy matchingStrategy) {
        super(matchingStrategy, matchingStrategy)
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy