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

com.sap.cds.reflect.impl.CdsAnnotableBuilder 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 com.sap.cds.reflect.CdsAnnotatable;
import com.sap.cds.reflect.CdsAnnotation;
import com.sap.cds.reflect.impl.reader.issuecollector.IssueCollector;
import com.sap.cds.reflect.impl.reader.issuecollector.IssueCollectorFactory;
import com.sap.cds.reflect.impl.reader.model.CdsConstants;

public abstract class CdsAnnotableBuilder {

	private static final IssueCollector issueCollector = IssueCollectorFactory
			.getIssueCollector(CdsAnnotableBuilder.class);

	private static final String IGNORE = CdsConstants.ANNOTATION_RUNTIME_IGNORE.substring(1);

	protected final List> annotations = new ArrayList<>();

	CdsAnnotableBuilder(List> annotations) {
		this.annotations.addAll(annotations);
	}

	public CdsAnnotableBuilder annotation(CdsAnnotation a) {
		annotations.add(a);
		return this;
	}

	boolean toBeIgnored(String path) {
		boolean toBeIgnored = annotations.stream()
				.anyMatch(a -> IGNORE.equals(a.getName()) && ((Boolean) a.getValue()).booleanValue());
		if (toBeIgnored) {
			issueCollector.warning(path,
					"The artifact '%s' is annotated with %s and is excluded from the CDS model. This could lead to an inconsistent model.",
					path, CdsConstants.ANNOTATION_RUNTIME_IGNORE);
		}

		return toBeIgnored;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy