Home / Class/ SpringProfileModelHandler Class — spring-boot Architecture

SpringProfileModelHandler Class — spring-boot Architecture

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

Entity Profile

Source Code

core/spring-boot/src/main/java/org/springframework/boot/logging/logback/SpringProfileModelHandler.java lines 41–84

class SpringProfileModelHandler extends ModelHandlerBase {

	private final @Nullable Environment environment;

	SpringProfileModelHandler(Context context, @Nullable Environment environment) {
		super(context);
		this.environment = environment;
	}

	@Override
	public void handle(ModelInterpretationContext intercon, Model model) throws ModelHandlerException {
		SpringProfileModel profileModel = (SpringProfileModel) model;
		if (!acceptsProfiles(intercon, profileModel)) {
			model.deepMarkAsSkipped();
		}
	}

	private boolean acceptsProfiles(ModelInterpretationContext ic, SpringProfileModel model) {
		if (this.environment == null) {
			return false;
		}
		String[] profileNames = trimArrayElements(StringUtils.commaDelimitedListToStringArray(model.getName()));
		if (profileNames.length == 0) {
			return false;
		}
		for (int i = 0; i < profileNames.length; i++) {
			try {
				profileNames[i] = OptionHelper.substVars(profileNames[i], ic, this.context);
			}
			catch (ScanException ex) {
				throw new RuntimeException(ex);
			}
		}
		return this.environment.acceptsProfiles(Profiles.of(profileNames));
	}

	// The array has no nulls in it, but StringUtils.trimArrayElements return
	// @Nullable String[]
	@SuppressWarnings("NullAway")
	private String[] trimArrayElements(String[] array) {
		return StringUtils.trimArrayElements(array);
	}

}

Analyze Your Own Codebase

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

Try Supermodel Free