java.lang.Object
uk.autores.naming.Namer
- Direct Known Subclasses:
IdiomaticNamer
Base type for naming classes, methods and fields.
Does the bare minimum to create viable identifiers by replacing invalid codepoints with underscores.
Extend this type to provide alternative behaviour and specify using Processing.namer()
.
Implementations MUST:
- Be public
- Have a public no-args constructor
- Be available as compiled types on the compiler classpath
Example of how this type is used in Handler
implementations:
Namer namer = new Namer(); String simple = namer.simplifyResourceName("/META-INF/foo/bar.baz.txt"); // "foo.bar" String className = namer.nameClass(simple); // "bar_baz"
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
Tests for valid identifiers - class, method or field names.static boolean
isPackage
(CharSequence pkg) Tests for valid package names.nameConstant
(String src) Name a public static final field.nameMember
(String src) Name a method/field/etc.Name a class/interface/etc.simplifyResourceName
(String resource) Reduces a resource name to a simpler form.
-
Constructor Details
-
Namer
public Namer()Public no-args constructor as per contract.
-
-
Method Details
-
isIdentifier
Tests for valid identifiers - class, method or field names.- Parameters:
cs
- sequence to test- Returns:
- true if valid identifier
-
isPackage
Tests for valid package names. Returns false for the empty string.- Parameters:
pkg
- package name- Returns:
- true if valid package name
-
nameType
Name a class/interface/etc.- Parameters:
src
- source string- Returns:
- source string as a class name
-
nameConstant
Name a public static final field.- Parameters:
src
- source string- Returns:
- source string as a field name if possible
-
nameMember
Name a method/field/etc.- Parameters:
src
- source string- Returns:
- source string as a member name
-
simplifyResourceName
Reduces a resource name to a simpler form.- Parameters:
resource
- resource name- Returns:
- name stripped of path and extension
-