com.sap.cds.adapter.odata.v4.serializer.json.Complex2Json Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cds-adapter-odata-v4 Show documentation
Show all versions of cds-adapter-odata-v4 Show documentation
OData V4 adapter for CDS Services Java
/**************************************************************************
* (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();
}
}