Class ParseField

java.lang.Object
org.elasticsearch.xcontent.ParseField

public class ParseField extends Object
Holds a field that can be found in a request while parsing and its different variants, which may be deprecated.
  • Constructor Details

    • ParseField

      public ParseField(String name, String... deprecatedNames)
      Parameters:
      name - the primary name for this field. This will be returned by getPreferredName()
      deprecatedNames - names for this field which are deprecated and will not be accepted when strict matching is used.
  • Method Details

    • getPreferredName

      public String getPreferredName()
      Returns:
      the preferred name used for this field
    • getAllNamesIncludedDeprecated

      public String[] getAllNamesIncludedDeprecated()
      Returns:
      All names for this field regardless of whether they are deprecated
    • withDeprecation

      public ParseField withDeprecation(String... deprecatedNamesOverride)
      Parameters:
      deprecatedNamesOverride - deprecated names to include with the returned ParseField
      Returns:
      a new ParseField using the preferred name from this one but with the specified deprecated names
    • withAllDeprecated

      public ParseField withAllDeprecated(String allReplacedWithOverride)
      Return a new ParseField where all field names are deprecated and replaced with allReplacedWith.
    • withAllDeprecated

      public ParseField withAllDeprecated()
      Return a new ParseField where all field names are deprecated with no replacement
    • match

      public boolean match(String fieldName, DeprecationHandler deprecationHandler)
      Does fieldName match this field?
      Parameters:
      fieldName - the field name to match against this ParseField
      deprecationHandler - called if fieldName is deprecated
      Returns:
      true if fieldName matches any of the acceptable names for this ParseField.
    • match

      public boolean match(String parserName, Supplier<XContentLocation> location, String fieldName, DeprecationHandler deprecationHandler)
      Does fieldName match this field?
      Parameters:
      parserName - the name of the parent object holding this field
      location - the XContentLocation of the field
      fieldName - the field name to match against this ParseField
      deprecationHandler - called if fieldName is deprecated
      Returns:
      true if fieldName matches any of the acceptable names for this ParseField.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getAllReplacedWith

      public String getAllReplacedWith()
      Returns:
      the message to use if this ParseField has been entirely deprecated in favor of something else. This method will return null if the ParseField has not been completely deprecated.
    • getDeprecatedNames

      public String[] getDeprecatedNames()
      Returns:
      an array of the names for the ParseField which are deprecated.