Package com.sap.cds.generator.util
Class NamesUtils
java.lang.Object
com.sap.cds.generator.util.NamesUtils
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringargumentName(Configuration configuration, com.sap.cds.reflect.CdsElement element) Returns argument name that is derived from element namestatic StringargumentName(Configuration configuration, com.sap.cds.reflect.CdsParameter parameter) Returns argument name that is derived from parameter namestatic com.palantir.javapoet.ClassNameclassName(Configuration configuration, com.palantir.javapoet.ClassName parent, com.sap.cds.reflect.CdsElement element) Returns Java class name for given CDS element as a nested class to some other class.static com.palantir.javapoet.ClassNameclassName(Configuration configuration, com.palantir.javapoet.ClassName parent, com.sap.cds.reflect.CdsParameter parameter) Returns Java class name for given CDS parameter as a nested class to some other class.static com.palantir.javapoet.ClassNameclassName(Configuration configuration, com.sap.cds.reflect.CdsType type) Returns Java class name for given CDS type.static StringconstantName(Configuration configuration, com.sap.cds.reflect.CdsDefinition definition) Generates constant representing this definition without renaming supportstatic StringconstantName(com.sap.cds.reflect.CdsElement element) static com.palantir.javapoet.ClassNameeventContextClassName(Configuration configuration, com.sap.cds.reflect.CdsEntity boundEntity, com.sap.cds.reflect.CdsDefinition def) Returns qualified event context class name for the given CDS definition.static StringgetOnHandlerMethodName(Configuration configuration, com.sap.cds.reflect.CdsOperation operation) Returns name for default on-handler method for operationsstatic StringgetResolvedWrapperName(String qualifiedBuilderName, String classNameSuffix) static StringgetterName(Configuration configuration, com.sap.cds.reflect.CdsElement element) Returns classic getter name for an elementstatic StringgetterName(Configuration configuration, com.sap.cds.reflect.CdsParameter parameter) Returns classic getter name for a parameterbooleanisExcluded(String qualifiedName) static booleanisValidTechnicalEntity(Configuration configuration, com.sap.cds.reflect.CdsModel model, com.sap.cds.reflect.CdsEntity entity) static StringmethodName(Configuration configuration, com.sap.cds.reflect.CdsElement element) Returns method name that is derived from element namestatic StringmethodName(Configuration configuration, com.sap.cds.reflect.CdsOperation operation) Returns method name that is derived from element name, should be used only in fluent modestatic StringmethodName(Configuration configuration, com.sap.cds.reflect.CdsParameter parameter) Returns method name that is derived from parameter name, should be used only in fluent modestatic StringnormalizedConstantName(com.sap.cds.reflect.CdsEnumType.Enumeral<?> enumeral) static StringpackageName(com.sap.cds.reflect.CdsDefinition definition, String basePackage) Returns the effective package name of the givendefinition.static StringpackageName(com.sap.cds.reflect.CdsService service, String basePackage) Returns the effective package name of the givenservicedefinition.static StringqualifiedContextName(String qualifiedName, String name) static StringqualifiedWrapperBuilderName(Configuration configuration, com.sap.cds.reflect.CdsDefinition def, String classNameSuffix, boolean isWrapper) static StringrawName(com.sap.cds.reflect.CdsElement element) Returns class name that is derived from element name.static StringsetterName(Configuration configuration, com.sap.cds.reflect.CdsElement element) Returns classic setter name for an elementstatic StringsetterName(Configuration configuration, com.sap.cds.reflect.CdsParameter parameter) Returns classic setter name for a parameterstatic com.palantir.javapoet.ClassNamesuffixedClassName(Configuration configuration, com.palantir.javapoet.ClassName parent, com.sap.cds.reflect.CdsElement element) Returns suffixed class name that is nested within the parent class for a given element.static com.palantir.javapoet.ClassNamesuffixedClassName(Configuration configuration, com.sap.cds.reflect.CdsType type) Returns Java class name for given CDS type with a suffix.static com.palantir.javapoet.ClassNametemplateEventHandlerClassName(Configuration configuration, com.sap.cds.reflect.CdsEntity entity, com.sap.cds.reflect.CdsOperation operation) Returns the name of the template handler class for an action or functions.static com.palantir.javapoet.ClassNametemplateEventHandlerClassName(Configuration configuration, com.sap.cds.reflect.CdsOperation operation) Returns the name of the template handler class for an action or functions.static com.palantir.javapoet.ClassNametypedServiceBuilderName(Configuration configuration, com.sap.cds.reflect.CdsService service) Returns qualified typed service class name for the givenservicedefinition.static com.palantir.javapoet.ClassNametypedServiceClassName(Configuration configuration, com.sap.cds.reflect.CdsService service) Returns qualified typed service class name for the givenservicedefinition.static StringunqualifiedName(String qualifiedName) static voidwarnOnJavaKeywords(String qualifiedName)
-
Field Details
-
ITEM_TYPE_NAME
- See Also:
-
OPTIONAL_ARGS_TYPE_NAME
- See Also:
-
OPTIONAL_ARGS_PARAMETER_NAME
- See Also:
-
-
Constructor Details
-
NamesUtils
-
-
Method Details
-
qualifiedWrapperBuilderName
public static String qualifiedWrapperBuilderName(Configuration configuration, com.sap.cds.reflect.CdsDefinition def, String classNameSuffix, boolean isWrapper) -
qualifiedContextName
-
unqualifiedName
-
warnOnJavaKeywords
-
isValidTechnicalEntity
public static boolean isValidTechnicalEntity(Configuration configuration, com.sap.cds.reflect.CdsModel model, com.sap.cds.reflect.CdsEntity entity) -
getResolvedWrapperName
-
constantName
public static String constantName(Configuration configuration, com.sap.cds.reflect.CdsDefinition definition) Generates constant representing this definition without renaming support- Parameters:
configuration- the generatorConfigurationdefinition-CdsDefinitionto be represented- Returns:
- constant name generated "as-is"
-
packageName
Returns the effective package name of the givendefinition.- Parameters:
definition- theCdsDefinitionbasePackage- the base package- Returns:
- the effective package name
-
packageName
Returns the effective package name of the givenservicedefinition.- Parameters:
service- theCdsServicebasePackage- the base package- Returns:
- the effective package name
-
className
public static com.palantir.javapoet.ClassName className(Configuration configuration, com.sap.cds.reflect.CdsType type) Returns Java class name for given CDS type. The name is always qualified with the package derived from the namespace of the type and a base package. Uses @cds.java.this.name as override mechanism.- Parameters:
configuration- the instance ofConfigurationtype- the instance ofCdsType- Returns:
- instance of the
ClassNamerepresenting the Java class name
-
className
public static com.palantir.javapoet.ClassName className(Configuration configuration, com.palantir.javapoet.ClassName parent, com.sap.cds.reflect.CdsElement element) Returns Java class name for given CDS element as a nested class to some other class. This is useful only for classes that represent nested types.- Parameters:
configuration- the generatorConfigurationparent-ClassNameof the parent classelement- aCdsElementthat is nested within the parent class- Returns:
- instance of the
ClassNamerepresenting the Java class name
-
className
public static com.palantir.javapoet.ClassName className(Configuration configuration, com.palantir.javapoet.ClassName parent, com.sap.cds.reflect.CdsParameter parameter) Returns Java class name for given CDS parameter as a nested class to some other class. This is useful only for classes that represent nested _anonymous_ types that never renamed.- Parameters:
configuration- the generatorConfigurationparent-ClassNameof the parent classparameter- aCdsParameterthat is nested within the parent class- Returns:
- instance of the
ClassNamerepresenting the Java class name
-
suffixedClassName
public static com.palantir.javapoet.ClassName suffixedClassName(Configuration configuration, com.sap.cds.reflect.CdsType type) Returns Java class name for given CDS type with a suffix. Suffix is defined by the configuration, but is never configurable by the customer.- Parameters:
configuration- the instance ofConfigurationtype- the instance ofCdsTypethat should be suffixed- Returns:
- instance of the
ClassNamerepresenting the Java class name
-
suffixedClassName
public static com.palantir.javapoet.ClassName suffixedClassName(Configuration configuration, com.palantir.javapoet.ClassName parent, com.sap.cds.reflect.CdsElement element) Returns suffixed class name that is nested within the parent class for a given element. E.g. Entity.ReturnType.- Parameters:
configuration- the instance ofConfigurationparent- parent class name asClassNameelement- the element that should be nested within the parent class- Returns:
- instance of the
ClassNamerepresenting the Java class name
-
typedServiceClassName
public static com.palantir.javapoet.ClassName typedServiceClassName(Configuration configuration, com.sap.cds.reflect.CdsService service) Returns qualified typed service class name for the givenservicedefinition. NB: This is exception from standard rule- Parameters:
configuration- the generatorConfigurationservice- theservicedefinition- Returns:
- the full qualified typed service
ClassName
-
typedServiceBuilderName
public static com.palantir.javapoet.ClassName typedServiceBuilderName(Configuration configuration, com.sap.cds.reflect.CdsService service) Returns qualified typed service class name for the givenservicedefinition.- Parameters:
configuration- the generatorConfigurationservice- theservicedefinition- Returns:
- the full qualified typed service
String
-
templateEventHandlerClassName
public static com.palantir.javapoet.ClassName templateEventHandlerClassName(Configuration configuration, com.sap.cds.reflect.CdsOperation operation) Returns the name of the template handler class for an action or functions. Variant for unbound operation. Uses @cds.java.name as override mechanism.- Parameters:
configuration- the instance ofConfigurationoperation- the @CdsOperation- Returns:
- instance of the
ClassNamerepresenting the Java class name
-
templateEventHandlerClassName
public static com.palantir.javapoet.ClassName templateEventHandlerClassName(Configuration configuration, com.sap.cds.reflect.CdsEntity entity, com.sap.cds.reflect.CdsOperation operation) Returns the name of the template handler class for an action or functions. Variant for bound operation. Uses @cds.java.name as override mechanism.- Parameters:
configuration- the instance ofConfigurationentity- the bound @CdsEntityoperation- the @CdsOperation- Returns:
- instance of the
ClassNamerepresenting the Java class name
-
getOnHandlerMethodName
public static String getOnHandlerMethodName(Configuration configuration, com.sap.cds.reflect.CdsOperation operation) Returns name for default on-handler method for operations- Parameters:
configuration- the instance ofConfigurationoperation- the instance of @CdsOperation- Returns:
- name
-
eventContextClassName
public static com.palantir.javapoet.ClassName eventContextClassName(Configuration configuration, com.sap.cds.reflect.CdsEntity boundEntity, com.sap.cds.reflect.CdsDefinition def) Returns qualified event context class name for the given CDS definition.- Parameters:
configuration- the generatorConfigurationboundEntity- an optionally boundentitydef- theCdsType- Returns:
- the full qualified event context
ClassName
-
methodName
public static String methodName(Configuration configuration, com.sap.cds.reflect.CdsElement element) Returns method name that is derived from element name- Parameters:
configuration- the generatorConfigurationelement- the @CdsElement- Returns:
- the name
-
rawName
Returns class name that is derived from element name. This exists for compatibility reasons and does not apply transformation- Parameters:
element- the @CdsElement- Returns:
- the name
-
methodName
public static String methodName(Configuration configuration, com.sap.cds.reflect.CdsParameter parameter) Returns method name that is derived from parameter name, should be used only in fluent mode- Parameters:
configuration- the generatorConfigurationparameter- the @CdsParameter- Returns:
- the name
-
methodName
public static String methodName(Configuration configuration, com.sap.cds.reflect.CdsOperation operation) Returns method name that is derived from element name, should be used only in fluent mode- Parameters:
configuration- the generatorConfigurationoperation- the @CdsOperation- Returns:
- the name
-
setterName
public static String setterName(Configuration configuration, com.sap.cds.reflect.CdsElement element) Returns classic setter name for an element- Parameters:
configuration- the generatorConfigurationelement- theCdsElement- Returns:
- name
-
getterName
public static String getterName(Configuration configuration, com.sap.cds.reflect.CdsElement element) Returns classic getter name for an element- Parameters:
configuration- the generatorConfigurationelement- theCdsElement- Returns:
- name
-
setterName
public static String setterName(Configuration configuration, com.sap.cds.reflect.CdsParameter parameter) Returns classic setter name for a parameter- Parameters:
configuration- the generatorConfigurationparameter- theCdsParameter- Returns:
- name
-
getterName
public static String getterName(Configuration configuration, com.sap.cds.reflect.CdsParameter parameter) Returns classic getter name for a parameter- Parameters:
configuration- the generatorConfigurationparameter- theCdsParameter- Returns:
- name
-
argumentName
public static String argumentName(Configuration configuration, com.sap.cds.reflect.CdsElement element) Returns argument name that is derived from element name- Parameters:
element- the @CdsElement- Returns:
- the name
-
argumentName
public static String argumentName(Configuration configuration, com.sap.cds.reflect.CdsParameter parameter) Returns argument name that is derived from parameter name- Parameters:
parameter- the @CdsElement- Returns:
- the name
-
constantName
-
normalizedConstantName
-
isExcluded
-