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

com.sap.cds.util.NameResolver Maven / Gradle / Ivy

There is a newer version: 3.6.1
Show newest version
package com.sap.cds.util;

import java.util.Set;

public class NameResolver {

	private static final String DOT = ".";
	private final Set qualifiedDefinitionNames;
	private final Set qualifiedServiceNames;

	public NameResolver(Set qualifiedDefinitionNames, Set qualifiedServiceNames) {
		this.qualifiedDefinitionNames = qualifiedDefinitionNames;
		this.qualifiedServiceNames = qualifiedServiceNames;
	}

	public String getDefinitionName(String qualifiedName) {
		int start = -1;
		int end;

		while ((end = qualifiedName.indexOf(DOT, start + 1)) != -1) {
			String substring = qualifiedName.substring(0, end);
			if (qualifiedDefinitionNames.contains(substring)) {
				break; // NOSONAR
			}
			start = end;
			if (qualifiedServiceNames.contains(substring)) {
				break; // NOSONAR
			}
		}

		return qualifiedName.substring(start + 1, qualifiedName.length());
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy