Class Formatters


  • public final class Formatters
    extends java.lang.Object
    • Method Detail

      • formatMethod

        @PublicAPI(usage=ACCESS)
        public static java.lang.String formatMethod​(java.lang.String ownerName,
                                                    java.lang.String methodName,
                                                    JavaClassList parameters)
        Parameters:
        ownerName - Class name where the method is declared
        methodName - Name of the method
        parameters - Parameters of the method
        Returns:
        Arguments formatted as "ownerName.methodName(fqn.param1, fqn.param2, ...)"
      • formatMethodSimple

        @PublicAPI(usage=ACCESS)
        public static java.lang.String formatMethodSimple​(java.lang.String ownerName,
                                                          java.lang.String methodName,
                                                          java.util.List<java.lang.String> parameters)
        Parameters:
        ownerName - Class name where the method is declared (may be simple or fqn)
        methodName - Name of the method
        parameters - Names of parameter types (may be simple or fqn)
        Returns:
        Arguments formatted as "simple(ownerName).methodName(simple(param1), simple(param2), ...)", where simple(..) ensures the simple type name (compare ensureSimpleName(String))
      • formatMethod

        @PublicAPI(usage=ACCESS)
        public static java.lang.String formatMethod​(java.lang.String ownerName,
                                                    java.lang.String methodName,
                                                    java.util.List<java.lang.String> parameters)
        Parameters:
        ownerName - Class name where the method is declared
        methodName - Name of the method
        parameters - Names of parameter types
        Returns:
        Arguments formatted (as passed) as "ownerName.methodName(param1, param2, ...)"
      • formatMethodParameterTypeNames

        @PublicAPI(usage=ACCESS)
        public static java.lang.String formatMethodParameterTypeNames​(java.util.List<java.lang.String> typeNames)
        Parameters:
        typeNames - List of method parameter type names
        Returns:
        Arguments formatted as "param1, param2, ..."
      • formatThrowsDeclarationTypeNames

        @PublicAPI(usage=ACCESS)
        public static java.lang.String formatThrowsDeclarationTypeNames​(java.util.List<java.lang.String> typeNames)
        Parameters:
        typeNames - List of throws declaration type names
        Returns:
        Arguments formatted as "param1, param2, ..."
      • ensureSimpleName

        @PublicAPI(usage=ACCESS)
        public static java.lang.String ensureSimpleName​(java.lang.String name)
        Parameters:
        name - A possibly fully qualified class name
        Returns:
        A best guess of the simple name, i.e. prefixes like 'a.b.c.' cut off, 'Some$' of 'Some$Inner' as well. Returns an empty String, if the name belongs to an anonymous class (e.g. some.Type$1).
      • formatLocation

        @Deprecated
        @PublicAPI(usage=ACCESS)
        public static java.lang.String formatLocation​(JavaClass clazz,
                                                      int lineNumber)
        Deprecated.
        Parameters:
        clazz - Class determining the location
        lineNumber - Line number of the location
        Returns:
        Arguments formatted as "(${clazz.getSimpleName()}.java:${lineNumber})". This format is (at least by IntelliJ Idea) recognized as location, if it's the end of a failure line, thus enabling IDE support to jump to a violation.
        See Also:
        SourceCodeLocation