Class NamesUtils

java.lang.Object
com.sap.cds.generator.util.NamesUtils

public class NamesUtils extends Object
  • Field Details

  • Constructor Details

  • Method Details

    • qualifiedWrapperBuilderName

      public static String qualifiedWrapperBuilderName(Configuration configuration, com.sap.cds.reflect.CdsDefinition def, String classNameSuffix, boolean isWrapper)
    • qualifiedContextName

      public static String qualifiedContextName(String qualifiedName, String name)
    • unqualifiedName

      public static String unqualifiedName(String qualifiedName)
    • warnOnJavaKeywords

      public static void warnOnJavaKeywords(String qualifiedName)
    • isValidTechnicalEntity

      public static boolean isValidTechnicalEntity(Configuration configuration, com.sap.cds.reflect.CdsModel model, com.sap.cds.reflect.CdsEntity entity)
    • getResolvedWrapperName

      public static String getResolvedWrapperName(String qualifiedBuilderName, String classNameSuffix)
    • constantName

      public static String constantName(Configuration configuration, com.sap.cds.reflect.CdsDefinition definition)
      Generates constant representing this definition without renaming support
      Parameters:
      configuration - the generator Configuration
      definition - CdsDefinition to be represented
      Returns:
      constant name generated "as-is"
    • packageName

      public static String packageName(com.sap.cds.reflect.CdsDefinition definition, String basePackage)
      Returns the effective package name of the given definition.
      Parameters:
      definition - the CdsDefinition
      basePackage - the base package
      Returns:
      the effective package name
    • packageName

      public static String packageName(com.sap.cds.reflect.CdsService service, String basePackage)
      Returns the effective package name of the given service definition.
      Parameters:
      service - the CdsService
      basePackage - 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 of Configuration
      type - the instance of CdsType
      Returns:
      instance of the ClassName representing 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 generator Configuration
      parent - ClassName of the parent class
      element - a CdsElement that is nested within the parent class
      Returns:
      instance of the ClassName representing 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 generator Configuration
      parent - ClassName of the parent class
      parameter - a CdsParameter that is nested within the parent class
      Returns:
      instance of the ClassName representing 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 of Configuration
      type - the instance of CdsType that should be suffixed
      Returns:
      instance of the ClassName representing 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 of Configuration
      parent - parent class name as ClassName
      element - the element that should be nested within the parent class
      Returns:
      instance of the ClassName representing 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 given service definition. NB: This is exception from standard rule
      Parameters:
      configuration - the generator Configuration
      service - the service definition
      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 given service definition.
      Parameters:
      configuration - the generator Configuration
      service - the service definition
      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 of Configuration
      operation - the @CdsOperation
      Returns:
      instance of the ClassName representing 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 of Configuration
      entity - the bound @CdsEntity
      operation - the @CdsOperation
      Returns:
      instance of the ClassName representing 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 of Configuration
      operation - 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 generator Configuration
      boundEntity - an optionally bound entity
      def - the CdsType
      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 generator Configuration
      element - the @CdsElement
      Returns:
      the name
    • rawName

      public static String rawName(com.sap.cds.reflect.CdsElement element)
      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 generator Configuration
      parameter - 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 generator Configuration
      operation - 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 generator Configuration
      element - the CdsElement
      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 generator Configuration
      element - the CdsElement
      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 generator Configuration
      parameter - the CdsParameter
      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 generator Configuration
      parameter - the CdsParameter
      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

      public static String constantName(com.sap.cds.reflect.CdsElement element)
    • normalizedConstantName

      public static String normalizedConstantName(com.sap.cds.reflect.CdsEnumType.Enumeral<?> enumeral)
    • isExcluded

      public boolean isExcluded(String qualifiedName)