java.lang.Object
io.github.projectunified.craftcommand.processor.Naming

public final class Naming extends Object
Pure naming utilities for generated fields, methods, and identifiers.

Centralizes the naming conventions used across the code generator so that the same logical concept always maps to the same generated name, and so generated members read as if they had been written by hand. All methods are static and side-effect free.

  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    executeHelper(com.palantir.javapoet.ClassName nestedClass)
    Gets the execution helper method name for a nested subcommand class.
    static String
    Sanitizes a string into a valid Java identifier.
    static String
    simpleName(com.palantir.javapoet.TypeName typeName)
    Gets the simple name of a type name.
    static String
    subcommandField(com.palantir.javapoet.ClassName nestedClass)
    Gets the field name holding a nested subcommand class instance.
    static String
    suggestHelper(com.palantir.javapoet.ClassName nestedClass)
    Gets the suggestion routing helper method name for a nested subcommand class.
    static String
    suggestMethod(com.palantir.javapoet.ClassName commandClass, String methodOrDefault, int paramIndex)
    Gets the helper method name for a parameter's suggestions.

    Methods inherited from class java.lang.Object

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

    • simpleName

      public static String simpleName(com.palantir.javapoet.TypeName typeName)
      Gets the simple name of a type name.
      Parameters:
      typeName - the type name
      Returns:
      the simple name of a TypeName (text after the last dot).
    • subcommandField

      public static String subcommandField(com.palantir.javapoet.ClassName nestedClass)
      Gets the field name holding a nested subcommand class instance.
      Parameters:
      nestedClass - the class name of the nested command
      Returns:
      the field name, for example subInstanceOuterInner for class Outer.Inner
    • suggestMethod

      public static String suggestMethod(com.palantir.javapoet.ClassName commandClass, String methodOrDefault, int paramIndex)
      Gets the helper method name for a parameter's suggestions.
      Parameters:
      commandClass - the command class being generated
      methodOrDefault - the subcommand name, or "default" for the default action
      paramIndex - the zero-based parameter index
      Returns:
      the helper method name, for example suggestCalculatorAdd_0
    • executeHelper

      public static String executeHelper(com.palantir.javapoet.ClassName nestedClass)
      Gets the execution helper method name for a nested subcommand class.
      Parameters:
      nestedClass - the nested class name
      Returns:
      the helper that executes the nested command, for example executeOuterInner
    • suggestHelper

      public static String suggestHelper(com.palantir.javapoet.ClassName nestedClass)
      Gets the suggestion routing helper method name for a nested subcommand class.
      Parameters:
      nestedClass - the nested class name
      Returns:
      the helper that routes tab completion into the nested command, for example suggestOuterInner
    • sanitizeIdentifier

      public static String sanitizeIdentifier(String name)
      Sanitizes a string into a valid Java identifier.
      Parameters:
      name - the input name
      Returns:
      a valid Java identifier derived from an arbitrary command name (replaces - and spaces with _).