Class MappedObject
java.lang.Object
org.springframework.boot.buildpack.platform.json.MappedObject
- Direct Known Subclasses:
BlobReference, ContainerStatus, Image, ImageArchiveIndex, ImageArchiveManifest, ImageArchiveManifest.ManifestEntry, ImageConfig, Manifest, ManifestList
Base class for mapped JSON objects.
- Since:
- 2.3.0
- Author:
- Phillip Webb, Dmytro Nosan
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static interfaceStrategy used to read JSON content. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedMappedObject(tools.jackson.databind.JsonNode node, MethodHandles.Lookup lookup) Create a newMappedObjectinstance. -
Method Summary
Modifier and TypeMethodDescriptionprotected <T> List<T> childrenAt(@Nullable String expression, Function<tools.jackson.databind.JsonNode, T> factory) Get children at the given JSON path expression by constructing them using the given factory.protected final tools.jackson.databind.JsonNodegetNode()Return the source node of the mapped object.protected static <T extends MappedObject>
TGet aMapat the given JSON path expression with a value mapped from a relatedJsonNode.protected static <T extends MappedObject, C>
Tof(C content, MappedObject.ContentReader<C> reader, Function<tools.jackson.databind.JsonNode, T> factory) Factory method to create a newMappedObjectinstance.protected static <T extends MappedObject>
Tof(InputStream content, Function<tools.jackson.databind.JsonNode, T> factory) Factory method to create a newMappedObjectinstance.protected static <T extends MappedObject>
TFactory method to create a newMappedObjectinstance.protected static <T> @Nullable Tprotected <T> @Nullable TGet the value at the given JSON path expression as a specific type.
-
Constructor Details
-
MappedObject
Create a newMappedObjectinstance.- Parameters:
node- the source nodelookup- method handle lookup
-
-
Method Details
-
getNode
protected final tools.jackson.databind.JsonNode getNode()Return the source node of the mapped object.- Returns:
- the source node
-
valueAt
Get the value at the given JSON path expression as a specific type.- Type Parameters:
T- the data type- Parameters:
expression- the JSON path expressiontype- the desired type. May be a simple JSON type or an interface- Returns:
- the value
-
mapAt
protected <V> Map<String,V> mapAt(String expression, Function<tools.jackson.databind.JsonNode, V> valueMapper) Get aMapat the given JSON path expression with a value mapped from a relatedJsonNode.- Type Parameters:
V- the value type- Parameters:
expression- the JSON path expressionvalueMapper- function to map the value from theJsonNode- Returns:
- the map
- Since:
- 3.5.0
-
childrenAt
protected <T> List<T> childrenAt(@Nullable String expression, Function<tools.jackson.databind.JsonNode, T> factory) Get children at the given JSON path expression by constructing them using the given factory.- Type Parameters:
T- the child type- Parameters:
expression- the JSON path expressionfactory- factory used to create the child- Returns:
- a list of children
- Since:
- 3.2.6
-
getRoot
-
valueAt
-
of
protected static <T extends MappedObject> T of(String content, Function<tools.jackson.databind.JsonNode, T> factory) throws IOException Factory method to create a newMappedObjectinstance.- Type Parameters:
T- the mapped object type- Parameters:
content- the JSON content for the objectfactory- a factory to create the mapped object from aJsonNode- Returns:
- the mapped object
- Throws:
IOException- on IO error
-
of
protected static <T extends MappedObject> T of(InputStream content, Function<tools.jackson.databind.JsonNode, T> factory) throws IOException Factory method to create a newMappedObjectinstance.- Type Parameters:
T- the mapped object type- Parameters:
content- the JSON content for the objectfactory- a factory to create the mapped object from aJsonNode- Returns:
- the mapped object
- Throws:
IOException- on IO error
-
of
protected static <T extends MappedObject, C> T of(C content, MappedObject.ContentReader<C> reader, Function<tools.jackson.databind.JsonNode, T> factory) throws IOException Factory method to create a newMappedObjectinstance.- Type Parameters:
T- the mapped object typeC- the content type- Parameters:
content- the JSON content for the objectreader- the content readerfactory- a factory to create the mapped object from aJsonNode- Returns:
- the mapped object
- Throws:
IOException- on IO error
-