Class JacksonInverter
java.lang.Object
io.fluxzero.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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionJacksonInverter(com.fasterxml.jackson.databind.json.JsonMapper objectMapper) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddMetadataEntries(Map<Document.Entry, List<Document.Path>> valueMap, Metadata metadata) protected StringcombineSummary(String summary, String metadataSummary) Data<com.fasterxml.jackson.databind.JsonNode> Data<?> convertFormat(Data<byte[]> data) Optionally converts the structure or format (e.g.: application/json) of the input data without modifying its core content.protected static ThrowingFunction<Object, String> createSummarizer(JacksonInverter inverter) static MetadataextractMetadata(Map<Document.Entry, List<Document.Path>> entries) protected Data<com.fasterxml.jackson.databind.JsonNode> protected Document.EntryTypegetEntryType(com.fasterxml.jackson.core.JsonToken token) protected Set<FacetEntry> protected Stream<FacetEntry> getFacets(AccessibleObject holder, Object propertyValue) protected Stream<FacetEntry> getFacetsStream(Object value) Class<com.fasterxml.jackson.databind.JsonNode> protected Stream<SortableEntry> getSortableEntries(Object value) protected Stream<SortableEntry> getSortableEntries(AccessibleObject holder, Object propertyValue) protected Set<SortableEntry> getSortables(Object value) protected Map<Document.Entry, List<Document.Path>> invert(byte[] json) static booleanisMetadataPath(String path) static StringmetadataPath(String key) protected com.fasterxml.jackson.databind.JsonNodeparseMetadataValue(String value) protected voidparseObject(com.fasterxml.jackson.core.JsonParser parser, Map<Document.Entry, List<Document.Path>> valueMap, String root) protected com.fasterxml.jackson.core.JsonTokenprocessToken(com.fasterxml.jackson.core.JsonToken token, Map<Document.Entry, List<Document.Path>> valueMap, String path, com.fasterxml.jackson.core.JsonParser parser) protected voidregisterValue(Document.EntryType type, String value, String path, Map<Document.Entry, List<Document.Path>> valueMap) protected StringsummarizeMetadata(Metadata metadata) toDocument(Object value, String type, int revision, String id, String collection, Instant timestamp, Instant end, Metadata metadata) Converts the given object into aSerializedDocument, which is suitable for indexing or storage in a document store.protected Data<com.fasterxml.jackson.databind.JsonNode> toJsonData(com.fasterxml.jackson.databind.JsonNode node, Data<byte[]> data) protected com.fasterxml.jackson.databind.JsonNodetoJsonNodeInstance(Object struct)
-
Field Details
-
METADATA_PATH_PREFIX
- See Also:
-
searchIgnoreCache
-
-
Constructor Details
-
JacksonInverter
public JacksonInverter() -
JacksonInverter
public JacksonInverter(com.fasterxml.jackson.databind.json.JsonMapper objectMapper)
-
-
Method Details
-
createSummarizer
-
summarize
-
toDocument
public SerializedDocument toDocument(Object value, String type, int revision, String id, String collection, Instant timestamp, Instant end, Metadata metadata) Description copied from interface:InverterConverts the given object into aSerializedDocument, which is suitable for indexing or storage in a document store.- Specified by:
toDocumentin interfaceInverter<com.fasterxml.jackson.databind.JsonNode>- Parameters:
value- the original object to converttype- the simple type name of the objectrevision- the revision number of the object (e.g., as provided byRevision)id- the unique ID for this document within the given collectioncollection- the name of the collection the document belongs totimestamp- the optional starting timestamp for the document's validityend- the optional end timestamp of the document's validitymetadata- optional metadata to associate with the document- Returns:
- a fully constructed
SerializedDocument
-
getFacets
-
getFacetsStream
-
getFacets
-
addMetadataEntries
protected void addMetadataEntries(Map<Document.Entry, List<Document.Path>> valueMap, Metadata metadata) -
summarizeMetadata
-
combineSummary
-
parseMetadataValue
-
metadataPath
-
isMetadataPath
-
extractMetadata
-
getSortables
-
getSortableEntries
-
getSortableEntries
-
invert
-
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
-
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
- Specified by:
getOutputTypein interfaceConverter<byte[], com.fasterxml.jackson.databind.JsonNode>- Returns:
- the target output type this converter produces
-
convert
Description copied from interface:Converter -
convertFormat
Description copied from interface:ConverterOptionally 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:
convertFormatin interfaceConverter<byte[], com.fasterxml.jackson.databind.JsonNode>- Parameters:
data- the input data- Returns:
- the format-converted data, or the original input (default implementation)
-
fromData
-
toJsonData
-
toJsonNodeInstance
-