java.lang.Object
org.springframework.boot.buildpack.platform.json.MappedObject
Direct Known Subclasses:
BlobReference, ContainerStatus, Image, ImageArchiveIndex, ImageArchiveManifest, ImageArchiveManifest.ManifestEntry, ImageConfig, Manifest, ManifestList

public class MappedObject extends Object
Base class for mapped JSON objects.
Since:
2.3.0
Author:
Phillip Webb
  • Constructor Details

    • MappedObject

      protected MappedObject(com.fasterxml.jackson.databind.JsonNode node, MethodHandles.Lookup lookup)
      Create a new MappedObject instance.
      Parameters:
      node - the source node
      lookup - method handle lookup
  • Method Details

    • getNode

      protected final com.fasterxml.jackson.databind.JsonNode getNode()
      Return the source node of the mapped object.
      Returns:
      the source node
    • valueAt

      protected <T> T valueAt(String expression, Class<T> type)
      Get the value at the given JSON path expression as a specific type.
      Type Parameters:
      T - the data type
      Parameters:
      expression - the JSON path expression
      type - the desired type. May be a simple JSON type or an interface
      Returns:
      the value
    • childrenAt

      protected <T> List<T> childrenAt(String expression, Function<com.fasterxml.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 expression
      factory - factory used to create the child
      Returns:
      a list of children
      Since:
      3.2.6
    • getRoot

      protected static <T extends MappedObject> T getRoot(Object proxy)
    • valueAt

      protected static <T> T valueAt(Object proxy, String expression, Class<T> type)
    • of

      protected static <T extends MappedObject> T of(String content, Function<com.fasterxml.jackson.databind.JsonNode,T> factory) throws IOException
      Factory method to create a new MappedObject instance.
      Type Parameters:
      T - the mapped object type
      Parameters:
      content - the JSON content for the object
      factory - a factory to create the mapped object from a JsonNode
      Returns:
      the mapped object
      Throws:
      IOException - on IO error
    • of

      protected static <T extends MappedObject> T of(InputStream content, Function<com.fasterxml.jackson.databind.JsonNode,T> factory) throws IOException
      Factory method to create a new MappedObject instance.
      Type Parameters:
      T - the mapped object type
      Parameters:
      content - the JSON content for the object
      factory - a factory to create the mapped object from a JsonNode
      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<com.fasterxml.jackson.databind.JsonNode,T> factory) throws IOException
      Factory method to create a new MappedObject instance.
      Type Parameters:
      T - the mapped object type
      C - the content type
      Parameters:
      content - the JSON content for the object
      reader - the content reader
      factory - a factory to create the mapped object from a JsonNode
      Returns:
      the mapped object
      Throws:
      IOException - on IO error