Class JacksonInverter

java.lang.Object
io.fluxcapacitor.common.search.JacksonInverter
All Implemented Interfaces:
Inverter<com.fasterxml.jackson.databind.JsonNode>, Converter<byte[],com.fasterxml.jackson.databind.JsonNode>

public class JacksonInverter extends Object implements Inverter<com.fasterxml.jackson.databind.JsonNode>
Implementation of Inverter that uses Jackson to invert an Object into a SerializedDocument and back into a JsonNode.
  • Field Details

    • searchIgnoreCache

      protected static Function<com.fasterxml.jackson.databind.introspect.AnnotatedMember,Boolean> searchIgnoreCache
  • Constructor Details

    • JacksonInverter

      public JacksonInverter()
    • JacksonInverter

      public JacksonInverter(com.fasterxml.jackson.databind.json.JsonMapper objectMapper)
  • Method Details

    • createSummarizer

      protected static ThrowingFunction<Object,String> createSummarizer(JacksonInverter inverter)
    • summarize

      public String summarize(Object value)
    • toDocument

      public SerializedDocument toDocument(Object value, String type, int revision, String id, String collection, Instant timestamp, Instant end, Metadata metadata)
      Description copied from interface: Inverter
      Converts the given object into a SerializedDocument, which is suitable for indexing or storage in a document store.
      Specified by:
      toDocument in interface Inverter<com.fasterxml.jackson.databind.JsonNode>
      Parameters:
      value - the original object to convert
      type - the simple type name of the object
      revision - the revision number of the object (e.g., as provided by Revision)
      id - the unique ID for this document within the given collection
      collection - the name of the collection the document belongs to
      timestamp - the optional starting timestamp for the document's validity
      end - the optional end timestamp of the document's validity
      metadata - optional metadata to associate with the document
      Returns:
      a fully constructed SerializedDocument
    • getFacets

      protected Set<FacetEntry> getFacets(Object value, Metadata metadata)
    • asFacets

      protected Stream<FacetEntry> asFacets(Metadata metadata)
    • getFacets

      protected Stream<FacetEntry> getFacets(Object value)
    • getFacets

      protected Stream<FacetEntry> getFacets(AccessibleObject holder, Object propertyValue)
    • getSortables

      protected Set<SortableEntry> getSortables(Object value)
    • getSortableEntries

      protected Stream<SortableEntry> getSortableEntries(Object value)
    • getSortableEntries

      protected Stream<SortableEntry> getSortableEntries(AccessibleObject holder, Object propertyValue)
    • invert

      protected Map<Document.Entry,List<Document.Path>> invert(byte[] json)
    • processToken

      protected com.fasterxml.jackson.core.JsonToken processToken(com.fasterxml.jackson.core.JsonToken token, Map<Document.Entry,List<Document.Path>> valueMap, String path, com.fasterxml.jackson.core.JsonParser parser)
    • getEntryType

      protected Document.EntryType getEntryType(com.fasterxml.jackson.core.JsonToken token)
    • registerValue

      protected void registerValue(Document.EntryType type, String value, String path, Map<Document.Entry,List<Document.Path>> valueMap)
    • parseObject

      protected void parseObject(com.fasterxml.jackson.core.JsonParser parser, Map<Document.Entry,List<Document.Path>> valueMap, String root)
    • getOutputType

      public Class<com.fasterxml.jackson.databind.JsonNode> getOutputType()
      Specified by:
      getOutputType in interface Converter<byte[],com.fasterxml.jackson.databind.JsonNode>
      Returns:
      the target output type this converter produces
    • convert

      public Data<com.fasterxml.jackson.databind.JsonNode> convert(Data<byte[]> data)
      Description copied from interface: Converter
      Converts the given Data from input type I to output type O.
      Specified by:
      convert in interface Converter<byte[],com.fasterxml.jackson.databind.JsonNode>
      Parameters:
      data - the input data
      Returns:
      the converted data
    • convertFormat

      public Data<?> convertFormat(Data<byte[]> data)
      Description copied from interface: Converter
      Optionally converts the structure or format (e.g.: application/json) of the input data without modifying its core content.

      This method is used in scenarios where only a format change is required (e.g., wrapping metadata differently), and may return the original input or a modified version depending on the implementation.

      Specified by:
      convertFormat in interface Converter<byte[],com.fasterxml.jackson.databind.JsonNode>
      Parameters:
      data - the input data
      Returns:
      the format-converted data, or the original input (default implementation)
    • fromData

      protected Data<com.fasterxml.jackson.databind.JsonNode> fromData(Data<byte[]> data, Supplier<Document> documentFunction)
    • toJsonData

      protected Data<com.fasterxml.jackson.databind.JsonNode> toJsonData(com.fasterxml.jackson.databind.JsonNode node, Data<byte[]> data)
    • toJsonNode

      protected com.fasterxml.jackson.databind.JsonNode toJsonNode(Object struct)
    • toJsonNode

      protected com.fasterxml.jackson.databind.JsonNode toJsonNode(Document.Entry entry)