Class JacksonParser

java.lang.Object
io.github.qubitpi.athena.web.graphql.JacksonParser
All Implemented Interfaces:
JsonDocumentParser

public class JacksonParser extends Object implements JsonDocumentParser
JacksonParser parses GraphQL query using Jackson internally.
  • Constructor Details

    • JacksonParser

      public JacksonParser()
  • Method Details

    • getInstance

      @NotNull public static @NotNull JsonDocumentParser getInstance()
      Returns a fully initialized JsonDocumentParser of this implementation.
      Returns:
      the same instance all the time
    • getFileId

      public String getFileId(String graphQLDocument)
      Description copied from interface: JsonDocumentParser
      Given the JSON document wrapping a GraphQL query string, this method extracts the query argument, which is a file ID.

      For example, if the document is

       
       {
           "query":"{\n  metaData(fileId:\"2\") {\n    fileName\nfileType  }\n}"
       }
       
       
      then this method returns "2", which means the requested metadata is for a file whose file ID is 2.
      Specified by:
      getFileId in interface JsonDocumentParser
      Parameters:
      graphQLDocument - The provided JSON document
      Returns:
      an ordered list of requested metadata fields
    • getFields

      public List<String> getFields(String graphQLDocument)
      Description copied from interface: JsonDocumentParser
      Given the JSON document wrapping a GraphQL query string, this method extracts the query field and then the requested metadata field(s) in an ordered list.

      For example, if the document is

       
       {
           "query":"{\n  metaData(fileId:\"2\") {\n    fileName\nfileType  }\n}",
       }
       
       
      then this method returns a list of ["fileName", "fileType"].

      The order of the metadata fields also influences the element order in the returned list. For instance, if the document above changes to

       
       {
           "query":"{\n  metaData(fileId:\"2\") {\n    fileType\nfileName  }\n}",
       }
       
       
      then the returned list becomes ["fileType", "fileNAME"]

      If no fields are found, this method returns an empty list

      Specified by:
      getFields in interface JsonDocumentParser
      Parameters:
      graphQLDocument - The provided JSON document which cannot be null, otherwise the behavior of this method is undefined
      Returns:
      an ordered list of requested metadata fields