Class ChartFunctionSerializer.Collector

java.lang.Object
com.vaadin.flow.component.charts.model.serializers.ChartFunctionSerializer.Collector
All Implemented Interfaces:
Serializable
Enclosing class:
ChartFunctionSerializer

public static final class ChartFunctionSerializer.Collector extends Object implements Serializable
Collects the functions of one serialization, and finds where they are in the resulting JSON.

The path of a function can not be taken while serializing: the generator that builds a JSON tree does not keep track of array indexes. So a placeholder is written instead, and found in the tree afterwards, in the same walk that looks for functions given as strings.

For internal use only. May be renamed or removed in a future release.

See Also:
  • Constructor Details

    • Collector

      public Collector()
  • Method Details

    • extract

      public void extract(tools.jackson.databind.JsonNode json, boolean findStringFunctions)
      Removes the placeholders from the given JSON, and records the path and the function of each. A placeholder in an object is removed with its property, and one in an array is replaced with null. In the same walk, optionally looks for a function given as a string, under a key that starts with _fn_.

      Does not walk the JSON when there are no placeholders and no string functions to look for.

      Parameters:
      json - the JSON written with this collector, not null
      findStringFunctions - whether to look for functions given as strings
    • getPaths

      public tools.jackson.databind.node.ArrayNode getPaths()
      Gets the paths of the functions found by extract(JsonNode, boolean), in the order of getFunctions(). Each path is an array of property names and array indexes.
      Returns:
      the paths, not null
    • getFunctions

      public List<ChartFunction> getFunctions()
      Gets the functions found by extract(JsonNode, boolean).
      Returns:
      the functions, not null
    • hasStringFunction

      public boolean hasStringFunction()
      Gets whether extract(JsonNode, boolean) found a function given as a string.
      Returns:
      true if the JSON has a function as a string