AvailabilityChangeEvent Class — spring-boot Architecture
Architecture documentation for the AvailabilityChangeEvent class in AvailabilityChangeEvent.java from the spring-boot codebase.
Entity Profile
Relationship Graph
Source Code
core/spring-boot/src/main/java/org/springframework/boot/availability/AvailabilityChangeEvent.java lines 37–95
public class AvailabilityChangeEvent<S extends AvailabilityState> extends PayloadApplicationEvent<S> {
/**
* Create a new {@link AvailabilityChangeEvent} instance.
* @param source the source of the event
* @param state the availability state (never {@code null})
*/
public AvailabilityChangeEvent(Object source, S state) {
super(source, state);
}
/**
* Return the changed availability state.
* @return the availability state
*/
public S getState() {
return getPayload();
}
@Override
public ResolvableType getResolvableType() {
return ResolvableType.forClassWithGenerics(getClass(), getStateType());
}
private Class<?> getStateType() {
S state = getState();
if (state instanceof Enum<?> enumState) {
return enumState.getDeclaringClass();
}
return state.getClass();
}
/**
* Convenience method that can be used to publish an {@link AvailabilityChangeEvent}
* to the given application context.
* @param <S> the availability state type
* @param context the context used to publish the event
* @param state the changed availability state
*/
public static <S extends AvailabilityState> void publish(ApplicationContext context, S state) {
Assert.notNull(context, "'context' must not be null");
publish(context, context, state);
}
/**
* Convenience method that can be used to publish an {@link AvailabilityChangeEvent}
* to the given application context.
* @param <S> the availability state type
* @param publisher the publisher used to publish the event
* @param source the source of the event
* @param state the changed availability state
*/
public static <S extends AvailabilityState> void publish(ApplicationEventPublisher publisher, Object source,
S state) {
Assert.notNull(publisher, "'publisher' must not be null");
publisher.publishEvent(new AvailabilityChangeEvent<>(source, state));
}
}
Domain
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free