Interface Filter

  • All Known Implementing Classes:
    ExclusionFilter, InclusionFilter

    public interface Filter
    A filter interface for processing JSON elements by either including or excluding specified nodes.

    Implementations of this interface define how filtering is applied to a given JSON structure based on a set of rules provided in a string format.

    The filtering rules are specified as a comma-separated string where nested fields can be defined using parentheses. Implementations may use this structure to determine whether elements should be retained or removed from the resulting JSON.

    Example

    • "a,b(c,d)" - Includes/excludes top-level element a and the sub-elements c and d inside b.
    • "x(y)" - Includes/excludes only x.y, keeping other elements in x.

    Implementing classes may vary in behavior, such as including only specified elements (inclusion filtering) or removing specified elements (exclusion filtering).

    Author:
    Hideki Ikeda
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      com.google.gson.JsonElement apply​(com.google.gson.JsonElement source, String nodes)
      Applies the filtering strategy to the target source based on the given nodes.
    • Method Detail

      • apply

        com.google.gson.JsonElement apply​(com.google.gson.JsonElement source,
                                          String nodes)
        Applies the filtering strategy to the target source based on the given nodes.
        Parameters:
        source - The source JSON element to filter.
        nodes - A comma-separated string defining allowed JSON nodes to include. Each node can specify nested fields using parentheses.
        Returns:
        A new JsonElement instance built by filtering the source object based on the given nodes string.