Class ClassName

    • Field Detail

      • OBJECT

        public static final ClassName OBJECT
    • Method Detail

      • packageName

        public String packageName()
        Returns the package name, like "java.util" for Map.Entry.
      • enclosingClassName

        public ClassName enclosingClassName()
        Returns the enclosing class, like Map for Map.Entry. Returns null if this class is not nested in another class.
      • topLevelClassName

        public ClassName topLevelClassName()
        Returns the top class in this nesting group. Equivalent to chained calls to enclosingClassName() until the result's enclosing class is null.
      • nestedClass

        public ClassName nestedClass​(String name)
        Returns a new ClassName instance for the specified name as nested inside this class.
      • peerClass

        public ClassName peerClass​(String name)
        Returns a class that shares the same enclosing package or class. If this class is enclosed by another class, this is equivalent to enclosingClassName().nestedClass(name). Otherwise it is equivalent to get(packageName(), name).
      • simpleName

        public String simpleName()
        Returns the simple name of this class, like "Entry" for Map.Entry.
      • bestGuess

        public static ClassName bestGuess​(String classNameString)
        Returns a new ClassName instance for the given fully-qualified class name string. This method assumes that the input is ASCII and follows typical Java style (lowercase package names, UpperCamelCase class names) and may produce incorrect results or throw IllegalArgumentException otherwise. For that reason, get(Class) and get(Class) should be preferred as they can correctly create ClassName instances without such restrictions.
      • get

        public static ClassName get​(String packageName,
                                    String simpleName,
                                    String... simpleNames)
        Returns a class name created from the given parts. For example, calling this with package name "java.util" and simple names "Map", "Entry" yields Map.Entry.