Add EndpointObjectMapper supported types method

Issue: 45876
This commit is contained in:
Phillip Webb
2025-06-10 14:13:48 -07:00
parent 3de1e27b64
commit dec8093e75
4 changed files with 42 additions and 10 deletions

View File

@@ -16,13 +16,15 @@
package org.springframework.boot.actuate.endpoint.jackson;
import java.util.Set;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.boot.actuate.endpoint.OperationResponseBody;
/**
* Interface used to supply the {@link ObjectMapper} that should be used when serializing
* {@link OperationResponseBody} endpoint results.
* endpoint results.
*
* @author Phillip Webb
* @since 3.0.0
@@ -30,6 +32,11 @@ import org.springframework.boot.actuate.endpoint.OperationResponseBody;
*/
public interface EndpointObjectMapper {
/**
* The default supported types.
*/
Set<Class<?>> DEFAULT_SUPPORTED_TYPES = Set.of(OperationResponseBody.class);
/**
* Return the {@link ObjectMapper} that should be used to serialize
* {@link OperationResponseBody} endpoint results.
@@ -37,4 +44,13 @@ public interface EndpointObjectMapper {
*/
ObjectMapper get();
/**
* Return the types that this endpoint mapper supports.
* @return the supported types
* @since 4.0.0
*/
default Set<Class<?>> getSupportedTypes() {
return DEFAULT_SUPPORTED_TYPES;
}
}