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

macros.marshaller.json.MapMemberMacro.ftl Maven / Gradle / Ivy

Go to download

The AWS SDK for Java - Code Generator module holds the classes and templates required to generate the AWS Java SDK clients for AWS services.

There is a newer version: 1.11.8
Show newest version
<#macro content member getterFunction>
<#if member.mapModel.valueSimple>
    jsonGenerator.writeValue(${getterFunction});
<#elseif member.mapModel.valueModel??>
    <#local mapValueMember = member.mapModel.valueModel/>

    <#if mapValueMember.list>
        <#local loopVariable = member.name?uncap_first +"MapValueList"/>
        jsonGenerator.writeStartArray();
        for (${mapValueMember.listModel.memberType} ${loopVariable} : ${getterFunction}) {
            if (${loopVariable} != null) {
                <#if mapValueMember.simple>
                    jsonGenerator.writeValue(${loopVariable});
                <#elseif mapValueMember.map>
                    TODO Handle map inside a list
                <#elseif mapValueMember.list>
                    <@ListMemberMacro.content mapValueMember loopVariable/>
                <#else>
                    ${mapValueMember.variable.variableType}JsonMarshaller.getInstance().marshall(${loopVariable}, jsonGenerator);
                
            }
        }
        jsonGenerator.writeEndArray();
    <#elseif mapValueMember.map>
        <#local loopVariable = member.name?uncap_first +"MapValueNestedMap"/>
        <#local mapModel = mapValueMember.mapModel />
        <#local mapVariable = mapValueMember + "Map"/>
        jsonGenerator.writeStartObject();
        for(Map.Entry<${mapModel.keyType},${mapModel.valueType}> ${loopVariable} : ${getterFunction}.entrySet()) {
              if (${loopVariable}.getValue() != null) {
                  jsonGenerator.writeFieldName(${loopVariable}.getKey());

                  <@MapMemberMacro.content mapValueMember loopVariable+".getValue()"/>
              }
        }
        jsonGenerator.writeEndObject();
    <#else>
        ${member.mapModel.valueType}JsonMarshaller.getInstance().marshall(${getterFunction}, jsonGenerator);
    





© 2015 - 2025 Weber Informatics LLC | Privacy Policy