ItemsBuilder Class — spring-boot Architecture
Architecture documentation for the ItemsBuilder class in ConditionMessage.java from the spring-boot codebase.
Entity Profile
Relationship Graph
Source Code
core/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionMessage.java lines 314–400
public final class ItemsBuilder {
private final Builder condition;
private final String reason;
private final String singular;
private final String plural;
private ItemsBuilder(Builder condition, String reason, String singular, String plural) {
this.condition = condition;
this.reason = reason;
this.singular = singular;
this.plural = plural;
}
/**
* Used when no items are available. For example
* {@code didNotFind("any beans").atAll()} results in the message "did not find
* any beans".
* @return a built {@link ConditionMessage}
*/
public ConditionMessage atAll() {
return items(Collections.emptyList());
}
/**
* Indicate the items. For example
* {@code didNotFind("bean", "beans").items("x", "y")} results in the message "did
* not find beans x, y".
* @param items the items (may be {@code null})
* @return a built {@link ConditionMessage}
*/
public ConditionMessage items(Object @Nullable ... items) {
return items(Style.NORMAL, items);
}
/**
* Indicate the items. For example
* {@code didNotFind("bean", "beans").items("x", "y")} results in the message "did
* not find beans x, y".
* @param style the render style
* @param items the items (may be {@code null})
* @return a built {@link ConditionMessage}
*/
public ConditionMessage items(Style style, Object @Nullable ... items) {
return items(style, (items != null) ? Arrays.asList(items) : null);
}
/**
* Indicate the items. For example
* {@code didNotFind("bean", "beans").items(Collections.singleton("x")} results in
* the message "did not find bean x".
* @param items the source of the items (may be {@code null})
* @return a built {@link ConditionMessage}
*/
public ConditionMessage items(@Nullable Collection<?> items) {
return items(Style.NORMAL, items);
}
/**
* Indicate the items with a {@link Style}. For example
* {@code didNotFind("bean", "beans").items(Style.QUOTE, Collections.singleton("x")}
* results in the message "did not find bean 'x'".
* @param style the render style
* @param items the source of the items (may be {@code null})
* @return a built {@link ConditionMessage}
*/
public ConditionMessage items(Style style, @Nullable Collection<?> items) {
Assert.notNull(style, "'style' must not be null");
StringBuilder message = new StringBuilder(this.reason);
items = style.applyTo(items);
if ((this.condition == null || items == null || items.size() <= 1)
&& StringUtils.hasLength(this.singular)) {
message.append(" ").append(this.singular);
}
else if (StringUtils.hasLength(this.plural)) {
message.append(" ").append(this.plural);
}
if (!CollectionUtils.isEmpty(items)) {
message.append(" ").append(StringUtils.collectionToDelimitedString(items, ", "));
}
return this.condition.because(message.toString());
}
}
Domain
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free