Class Formatters

java.lang.Object
com.tngtech.archunit.core.domain.Formatters

public final class Formatters extends Object
  • Method Details

    • formatMethodSimple

      @PublicAPI(usage=ACCESS) public static String formatMethodSimple(String ownerName, String methodName, List<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 String formatMethod(String ownerName, String methodName, List<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 String formatMethodParameterTypeNames(List<String> typeNames)
      Parameters:
      typeNames - List of method parameter type names
      Returns:
      Arguments formatted as "param1, param2, ..."
    • formatThrowsDeclarationTypeNames

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

      @PublicAPI(usage=ACCESS) public static List<String> formatNamesOf(Class<?>... paramTypes)
      See Also:
    • formatNamesOf

      @PublicAPI(usage=ACCESS) public static List<String> formatNamesOf(Iterable<? extends Class<?>> paramTypes)
      Parameters:
      paramTypes - an iterable of Class objects
      Returns:
      A List of fully qualified class names of the passed Class objects
    • ensureSimpleName

      @PublicAPI(usage=ACCESS) public static String ensureSimpleName(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).
    • ensureCanonicalArrayTypeName

      @PublicAPI(usage=ACCESS) public static String ensureCanonicalArrayTypeName(String typeName)
      Returns the canonical array type name of any array type name passed in. Otherwise returns the passed type name as is. For example [Ljava.lang.String; will be reformatted to java.lang.String[] or [I will be reformatted to int[], while java.lang.String would simply be returned as is.
      Parameters:
      typeName - A Java type name
      Returns:
      the passed type name, but for array type names the canonical array type name
    • joinSingleQuoted

      @PublicAPI(usage=ACCESS) public static String joinSingleQuoted(String... strings)
      See Also:
    • joinSingleQuoted

      @PublicAPI(usage=ACCESS) public static String joinSingleQuoted(Iterable<String> strings)
      Parameters:
      strings - Any number of strings
      Returns:
      The strings concatenated on ',' and each wrapped in single quotes. E.g. ["a", "b", "c"] -> "'a', 'b', 'c'"