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

com.sap.cds.reflect.impl.CdsBoundActionAndFunctionReader Maven / Gradle / Ivy

There is a newer version: 3.8.0
Show newest version
/*******************************************************************
 * © 2020 SAP SE or an SAP affiliate company. All rights reserved. *
 *******************************************************************/
package com.sap.cds.reflect.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.fasterxml.jackson.databind.JsonNode;
import com.sap.cds.reflect.impl.reader.model.CdsConstants;

public class CdsBoundActionAndFunctionReader {
	List actionList = new ArrayList<>();
	List functionList = new ArrayList<>();

	public CdsBoundActionAndFunctionReader(JsonNode csn) {
		if (csn.has(CdsConstants.ACTIONS)) {
			JsonNode jsonNode = csn.get(CdsConstants.ACTIONS);
			jsonNode.fields().forEachRemaining(e -> addToList(e));
		}
	}

	private void addToList(Map.Entry actionEntry) {
		String elementName = actionEntry.getKey();
		JsonNode elementCsn = actionEntry.getValue();
		JsonNode kind = elementCsn.get(CdsConstants.KIND);
		if (kind != null) {
			if (kind.asText().equals(CdsConstants.ACTION)) {
				CdsActionBuilder action = CdsUnboundActionAndFunctionReader.readAction(elementName, elementCsn);
				actionList.add(action);
			}
			if (kind.asText().equals(CdsConstants.FUNCTION)) {
				CdsFunctionBuilder function = CdsUnboundActionAndFunctionReader.readFunction(elementName, elementCsn);
				functionList.add(function);
			}
		}
	}

	public List getActions() {
		return actionList;
	}

	public List getFunctions() {
		return functionList;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy