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

com.sap.cds.adapter.odata.v4.serializer.json.Complex2Json Maven / Gradle / Ivy

There is a newer version: 3.2.0
Show newest version
/**************************************************************************
 * (C) 2019-2024 SAP SE or an SAP affiliate company. All rights reserved. *
 **************************************************************************/
package com.sap.cds.adapter.odata.v4.serializer.json;

import java.io.IOException;
import java.util.Map;

import com.fasterxml.jackson.core.JsonGenerator;
import com.sap.cds.adapter.odata.v4.serializer.json.primitive.String2Json;

public class Complex2Json extends Struct2Json {

	Complex2Json() {
	}

	public String2Json getContext() {
		return context;
	}

	public String2Json getMetadataEtag() {
		return metadataEtag;
	}

	@Override
	public void toJson(Map row, JsonGenerator json) throws IOException {
		if (row == null) {
			json.writeNull();
			return;
		}

		json.writeStartObject();

		if (isRootLevel) {
			if (context != null) {
				context.toJson(null, json);
			}
			if (metadataEtag != null) {
				metadataEtag.toJson(null, json);
			}
		}
		if (etag != null) {
			etag.toJson(row, json);
		}
		// No id
		if (type != null) {
			type.toJson(null, json);
		}
		writeProperties(row, json);
		json.writeEndObject();
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy