Home / Class/ ConventionUtils Class — spring-boot Architecture

ConventionUtils Class — spring-boot Architecture

Architecture documentation for the ConventionUtils class in ConventionUtils.java from the spring-boot codebase.

Entity Profile

Relationship Graph

Source Code

configuration-metadata/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/support/ConventionUtils.java lines 32–67

public abstract class ConventionUtils {

	private static final Set<Character> SEPARATORS;

	static {
		List<Character> chars = Arrays.asList('-', '_');
		SEPARATORS = Collections.unmodifiableSet(new HashSet<>(chars));
	}

	/**
	 * Return the idiomatic metadata format for the given {@code value}.
	 * @param value a value
	 * @return the idiomatic format for the value, or the value itself if it already
	 * complies with the idiomatic metadata format.
	 */
	public static String toDashedCase(String value) {
		StringBuilder dashed = new StringBuilder();
		Character previous = null;
		for (int i = 0; i < value.length(); i++) {
			char current = value.charAt(i);
			if (SEPARATORS.contains(current)) {
				dashed.append("-");
			}
			else if (Character.isUpperCase(current) && previous != null && !SEPARATORS.contains(previous)) {
				dashed.append("-").append(current);
			}
			else {
				dashed.append(current);
			}
			previous = current;

		}
		return dashed.toString().toLowerCase(Locale.ENGLISH);
	}

}

Domain

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free