Origin Type — spring-boot Architecture
Architecture documentation for the Origin type/interface in Origin.java from the spring-boot codebase.
Entity Profile
Source Code
core/spring-boot/src/main/java/org/springframework/boot/origin/Origin.java lines 42–99
public interface Origin {
/**
* Return the parent origin for this instance if there is one. The parent origin
* provides the origin of the item that created this one.
* @return the parent origin or {@code null}
* @since 2.4.0
* @see Origin#parentsFrom(Object)
*/
default @Nullable Origin getParent() {
return null;
}
/**
* Find the {@link Origin} that an object originated from. Checks if the source object
* is an {@link Origin} or {@link OriginProvider} and also searches exception stacks.
* @param source the source object or {@code null}
* @return an {@link Origin} or {@code null}
*/
static @Nullable Origin from(@Nullable Object source) {
if (source instanceof Origin origin) {
return origin;
}
Origin origin = null;
if (source instanceof OriginProvider originProvider) {
origin = originProvider.getOrigin();
}
if (origin == null && source instanceof Throwable throwable) {
return from(throwable.getCause());
}
return origin;
}
/**
* Find the parents of the {@link Origin} that an object originated from. Checks if
* the source object is an {@link Origin} or {@link OriginProvider} and also searches
* exception stacks. Provides a list of all parents up to root {@link Origin},
* starting with the most immediate parent.
* @param source the source object or {@code null}
* @return a list of parents or an empty list if the source is {@code null}, has no
* origin, or no parent
* @since 2.4.0
*/
static List<Origin> parentsFrom(@Nullable Object source) {
Origin origin = from(source);
if (origin == null) {
return Collections.emptyList();
}
Set<Origin> parents = new LinkedHashSet<>();
origin = origin.getParent();
while (origin != null && !parents.contains(origin)) {
parents.add(origin);
origin = origin.getParent();
}
return Collections.unmodifiableList(new ArrayList<>(parents));
}
}
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free