Package com.tngtech.archunit.core.domain
Class Formatters
java.lang.Object
com.tngtech.archunit.core.domain.Formatters
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringensureCanonicalArrayTypeName(String typeName) Returns the canonical array type name of any array type name passed in.static StringensureSimpleName(String name) static StringformatMethod(String ownerName, String methodName, List<String> parameters) static StringformatMethodParameterTypeNames(List<String> typeNames) static StringformatMethodSimple(String ownerName, String methodName, List<String> parameters) formatNamesOf(Class<?>... paramTypes) formatNamesOf(Iterable<? extends Class<?>> paramTypes) static StringformatThrowsDeclarationTypeNames(List<String> typeNames) static StringjoinSingleQuoted(Iterable<String> strings) static StringjoinSingleQuoted(String... strings)
-
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 methodparameters- 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 declaredmethodName- Name of the methodparameters- 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
- See Also:
-
formatNamesOf
-
ensureSimpleName
- 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
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 tojava.lang.String[]or[Iwill be reformatted toint[], whilejava.lang.Stringwould 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
- See Also:
-
joinSingleQuoted
- 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'"
-