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

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

The newest version!
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 Body extends DslProperty {

	Body(Map body) {
		super(extractValue(body, { DslProperty p -> p.clientValue}), extractValue(body, {DslProperty p -> p.serverValue}))
	}

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

	Body(List bodyAsList) {
		super(bodyAsList.collect { DslProperty p -> p.clientValue }, bodyAsList.collect { DslProperty p -> p.serverValue })
	}

	Body(Object bodyAsValue) {
		this("${bodyAsValue}")
	}

	Body(GString bodyAsValue) {
		super(bodyAsValue, bodyAsValue)
	}

	Body(DslProperty bodyAsValue) {
		super(bodyAsValue.clientValue, bodyAsValue.serverValue)
	}

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


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy