Home / Class/ OnRepositoryTypeCondition Class — spring-boot Architecture

OnRepositoryTypeCondition Class — spring-boot Architecture

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

Entity Profile

Relationship Graph

Source Code

core/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/OnRepositoryTypeCondition.java lines 38–65

class OnRepositoryTypeCondition extends SpringBootCondition {

	@Override
	public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
		Map<String, @Nullable Object> attributes = metadata
			.getAnnotationAttributes(ConditionalOnRepositoryType.class.getName(), true);
		Assert.state(attributes != null, "'attributes' must not be null");
		String store = (String) attributes.get("store");
		Assert.state(store != null, "'store' must not be null");
		RepositoryType configuredType = getTypeProperty(context.getEnvironment(), store);
		RepositoryType requiredType = (RepositoryType) attributes.get("type");
		Assert.state(requiredType != null, "'requiredType' must not be null");
		ConditionMessage.Builder message = ConditionMessage.forCondition(ConditionalOnRepositoryType.class);
		if (configuredType == requiredType || configuredType == RepositoryType.AUTO) {
			return ConditionOutcome
				.match(message.because("configured type of '" + configuredType.name() + "' matched required type"));
		}
		return ConditionOutcome.noMatch(message.because("configured type (" + configuredType.name()
				+ ") did not match required type (" + requiredType.name() + ")"));
	}

	private RepositoryType getTypeProperty(Environment environment, String store) {
		return RepositoryType
			.valueOf(environment.getProperty(String.format("spring.data.%s.repositories.type", store), "auto")
				.toUpperCase(Locale.ENGLISH));
	}

}

Domain

Analyze Your Own Codebase

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

Try Supermodel Free