类 ClassNameGenerator

java.lang.Object
cn.taketoday.aot.generate.ClassNameGenerator

public final class ClassNameGenerator extends Object
Generate unique class names based on a target ClassName and a feature name.

This class is stateful, so the same instance should be used for all name generation.

从以下版本开始:
4.0
作者:
Phillip Webb, Stephane Nicoll
  • 字段详细资料

    • SEPARATOR

      private static final String SEPARATOR
      另请参阅:
    • AOT_FEATURE

      private static final String AOT_FEATURE
      另请参阅:
    • defaultTarget

      private final cn.taketoday.javapoet.ClassName defaultTarget
    • featureNamePrefix

      private final String featureNamePrefix
    • sequenceGenerator

      private final Map<String,AtomicInteger> sequenceGenerator
  • 构造器详细资料

    • ClassNameGenerator

      public ClassNameGenerator(cn.taketoday.javapoet.ClassName defaultTarget)
      Create a new instance using the specified defaultTarget and no feature name prefix.
      参数:
      defaultTarget - the default target class to use
    • ClassNameGenerator

      public ClassNameGenerator(cn.taketoday.javapoet.ClassName defaultTarget, String featureNamePrefix)
      Create a new instance using the specified defaultTarget and feature name prefix.
      参数:
      defaultTarget - the default target class to use
      featureNamePrefix - the prefix to use to qualify feature names
    • ClassNameGenerator

      private ClassNameGenerator(cn.taketoday.javapoet.ClassName defaultTarget, String featureNamePrefix, Map<String,AtomicInteger> sequenceGenerator)
  • 方法详细资料

    • getFeatureNamePrefix

      String getFeatureNamePrefix()
    • generateClassName

      public cn.taketoday.javapoet.ClassName generateClassName(String featureName, @Nullable cn.taketoday.javapoet.ClassName target)
      Generate a unique ClassName based on the specified featureName and target. If the target is null, the configured main target of this instance is used.

      The class name is a suffixed version of the target. For instance, a com.example.Demo target with an Initializer feature name leads to a com.example.Demo__Initializer generated class name. The feature name is qualified by the configured feature name prefix, if any.

      Generated class names are unique. If such a feature was already requested for this target, a counter is used to ensure uniqueness.

      参数:
      featureName - the name of the feature that the generated class supports
      target - the class the newly generated class relates to, or null to use the main target
      返回:
      a unique generated class name
    • getRootName

      private String getRootName(String featureName, @Nullable cn.taketoday.javapoet.ClassName target)
    • clean

      private String clean(String name)
    • generateSequencedClassName

      private cn.taketoday.javapoet.ClassName generateSequencedClassName(String name)
    • withFeatureNamePrefix

      ClassNameGenerator withFeatureNamePrefix(String featureNamePrefix)
      Create a new ClassNameGenerator instance for the specified feature name prefix, keeping track of all the class names generated by this instance.
      参数:
      featureNamePrefix - the feature name prefix to use
      返回:
      a new instance for the specified feature name prefix
    • toName

      private static String toName(cn.taketoday.javapoet.ClassName className)