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

com.sap.cds.adapter.odata.v2.utils.ExpandItemTreeBuilder Maven / Gradle / Ivy

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

import java.util.List;
import java.util.function.Function;

import com.sap.cds.adapter.odata.v2.query.expand.ExpandItem;

public class ExpandItemTreeBuilder {

	public static  ExpandItem buildTree(List> paths, Function stringifier) {
		ExpandItem root = new ExpandItem();
		for (List path : paths) {
			ExpandItem currentExpandItem = root;
			for (T segment : path) {
				String pathSegmentName = stringifier.apply(segment);
				currentExpandItem = currentExpandItem.computeIfAbsent(pathSegmentName, k -> new ExpandItem());
			}
		}
		return root;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy