Class NamesUtils

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

public class NamesUtils extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    argumentName(com.sap.cds.reflect.CdsElement element)
    Returns argument name that is derived from element name
    static String
    argumentName(com.sap.cds.reflect.CdsParameter parameter)
    Returns argument name that is derived from parameter name
    static com.squareup.javapoet.ClassName
    className(Configuration configuration, com.sap.cds.reflect.CdsType type)
    Returns Java class name for given CDS type.
    static com.squareup.javapoet.ClassName
    className(com.squareup.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.squareup.javapoet.ClassName
    className(com.squareup.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 String
    constantName(com.sap.cds.reflect.CdsDefinition definition)
    Generates constant representing this definition without renaming support
    static String
    constantName(com.sap.cds.reflect.CdsElement element)
     
    static com.squareup.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.
    static String
    getOnHandlerMethodName(com.sap.cds.reflect.CdsOperation operation)
    Returns name for default on-handler method for operations
    static String
    getResolvedWrapperName(String qualifiedBuilderName, String classNameSuffix)
     
    static String
    getterName(com.sap.cds.reflect.CdsElement element)
    Returns classic getter name for an element
    static String
    getterName(com.sap.cds.reflect.CdsParameter parameter)
    Returns classic getter name for a parameter
    boolean
    isExcluded(String qualifiedName)
     
    static boolean
    isValidTechnicalEntity(Configuration configuration, com.sap.cds.reflect.CdsModel model, com.sap.cds.reflect.CdsEntity entity)
     
    static String
    methodName(com.sap.cds.reflect.CdsElement element)
    Returns method name that is derived from element name
    static String
    methodName(com.sap.cds.reflect.CdsOperation operation)
    Returns method name that is derived from element name, should be used only in fluent mode
    static String
    methodName(com.sap.cds.reflect.CdsParameter parameter)
    Returns method name that is derived from parameter name, should be used only in fluent mode
    static String
    normalizedConstantName(com.sap.cds.reflect.CdsEnumType.Enumeral<?> enumeral)
     
    static String
    packageName(com.sap.cds.reflect.CdsDefinition definition, String basePackage)
    Returns the effective package name of the given definition.
    static String
    packageName(com.sap.cds.reflect.CdsService service, String basePackage)
    Returns the effective package name of the given service definition.
    static String
    qualifiedContextName(String qualifiedName, String name)
     
    static String
    qualifiedWrapperBuilderName(com.sap.cds.reflect.CdsDefinition def, String classNameSuffix, boolean isWrapper)
     
    static String
    rawName(com.sap.cds.reflect.CdsElement element)
    Returns class name that is derived from element name.
    static String
    setterName(com.sap.cds.reflect.CdsElement element)
    Returns classic setter name for an element
    static String
    setterName(com.sap.cds.reflect.CdsParameter parameter)
    Returns classic setter name for a parameter
    static com.squareup.javapoet.ClassName
    suffixedClassName(Configuration configuration, com.sap.cds.reflect.CdsType type)
    Returns Java class name for given CDS type with a suffix.
    static com.squareup.javapoet.ClassName
    suffixedClassName(Configuration configuration, com.squareup.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.squareup.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.
    static com.squareup.javapoet.ClassName
    templateEventHandlerClassName(Configuration configuration, com.sap.cds.reflect.CdsOperation operation)
    Returns the name of the template handler class for an action or functions.
    static com.squareup.javapoet.ClassName
    typedServiceBuilderName(Configuration configuration, com.sap.cds.reflect.CdsService service)
    Returns qualified typed service class name for the given service definition.
    static com.squareup.javapoet.ClassName
    typedServiceClassName(Configuration configuration, com.sap.cds.reflect.CdsService service)
    Returns qualified typed service class name for the given service definition.
    static String
    unqualifiedName(String qualifiedName)
     
    static void
    warnOnJavaKeywords(String qualifiedName)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • qualifiedWrapperBuilderName

      public static String qualifiedWrapperBuilderName(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(com.sap.cds.reflect.CdsDefinition definition)
      Generates constant representing this definition without renaming support
      Parameters:
      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.squareup.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.squareup.javapoet.ClassName className(com.squareup.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:
      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.squareup.javapoet.ClassName className(com.squareup.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:
      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.squareup.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.squareup.javapoet.ClassName suffixedClassName(Configuration configuration, com.squareup.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.squareup.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.squareup.javapoet.ClassName typedServiceBuilderName(Configuration configuration, com.sap.cds.reflect.CdsService service)
      Returns qualified typed service class name for the given service definition.
      Parameters:
      service - the service definition
      Returns:
      the full qualified typed service String
    • templateEventHandlerClassName

      public static com.squareup.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.squareup.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(com.sap.cds.reflect.CdsOperation operation)
      Returns name for default on-handler method for operations
      Parameters:
      operation - the instance of @CdsOperation
      Returns:
      name
    • eventContextClassName

      public static com.squareup.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(com.sap.cds.reflect.CdsElement element)
      Returns method name that is derived from element name
      Parameters:
      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(com.sap.cds.reflect.CdsParameter parameter)
      Returns method name that is derived from parameter name, should be used only in fluent mode
      Parameters:
      parameter - the @CdsParameter
      Returns:
      the name
    • methodName

      public static String methodName(com.sap.cds.reflect.CdsOperation operation)
      Returns method name that is derived from element name, should be used only in fluent mode
      Parameters:
      operation - the @CdsOperation
      Returns:
      the name
    • setterName

      public static String setterName(com.sap.cds.reflect.CdsElement element)
      Returns classic setter name for an element
      Parameters:
      element - the CdsElement
      Returns:
      name
    • getterName

      public static String getterName(com.sap.cds.reflect.CdsElement element)
      Returns classic getter name for an element
      Parameters:
      element - the CdsElement
      Returns:
      name
    • setterName

      public static String setterName(com.sap.cds.reflect.CdsParameter parameter)
      Returns classic setter name for a parameter
      Parameters:
      parameter - the CdsParameter
      Returns:
      name
    • getterName

      public static String getterName(com.sap.cds.reflect.CdsParameter parameter)
      Returns classic getter name for a parameter
      Parameters:
      parameter - the CdsParameter
      Returns:
      name
    • argumentName

      public static String argumentName(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(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)