Class Naming
java.lang.Object
io.github.projectunified.craftcommand.processor.Naming
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. All methods are static and side-effect free.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringclassPath(com.palantir.javapoet.ClassName className) Gets the class path prefix for a class name.static StringexecuteHelper(com.palantir.javapoet.ClassName nestedClass) Gets the execution helper method name for a nested subcommand class.static StringsanitizeIdentifier(String name) Sanitizes a string into a valid Java identifier.static StringsimpleName(com.palantir.javapoet.TypeName typeName) Gets the simple name of a type name.static StringsubcommandField(com.palantir.javapoet.ClassName nestedClass) Gets the field name for a nested subcommand class instance.static StringsuggestHelper(com.palantir.javapoet.ClassName nestedClass) Gets the suggestion routing helper method name for a nested subcommand class.static StringsuggestMethod(String classModelPath, String methodOrDefault, int paramIndex) Gets the helper method name for a parameter suggestion provider.
-
Method Details
-
simpleName
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
Gets the field name for a nested subcommand class instance.- Parameters:
nestedClass- the class name of the nested command- Returns:
- the field name for a nested subcommand class instance, e.g.
subInstance_outer_innerfor classOuter.Inner.
-
suggestMethod
Gets the helper method name for a parameter suggestion provider.- Parameters:
classModelPath- the lowercased dot-joined class simple-namesmethodOrDefault- the subcommand name, or"default"for the default actionparamIndex- the zero-based parameter index- Returns:
- the helper method name for a parameter's suggestion provider.
-
classPath
Gets the class path prefix for a class name.- Parameters:
className- the class name- Returns:
- the lowercased dot-joined simple-names of a class, used as a disambiguating prefix for generated identifiers.
-
executeHelper
Gets the execution helper method name for a nested subcommand class.- Parameters:
nestedClass- the nested class name- Returns:
"execute_" + lowercased class path— the routing helper for a nested subcommand class.
-
suggestHelper
Gets the suggestion routing helper method name for a nested subcommand class.- Parameters:
nestedClass- the nested class name- Returns:
"suggest_" + lowercased class path— the suggestion routing helper for a nested subcommand class.
-
sanitizeIdentifier
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_).
-