Package org.elasticsearch.common
Class ParseField
java.lang.Object
org.elasticsearch.common.ParseField
public class ParseField
extends java.lang.Object
Holds a field that can be found in a request while parsing and its different
variants, which may be deprecated.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classParseField.CommonFields -
Constructor Summary
Constructors Constructor Description ParseField(java.lang.String name, java.lang.String... deprecatedNames) -
Method Summary
Modifier and Type Method Description java.lang.String[]getAllNamesIncludedDeprecated()java.lang.StringgetAllReplacedWith()java.lang.String[]getDeprecatedNames()java.lang.StringgetPreferredName()booleanmatch(java.lang.String parserName, java.util.function.Supplier<XContentLocation> location, java.lang.String fieldName, DeprecationHandler deprecationHandler)DoesfieldNamematch this field?booleanmatch(java.lang.String fieldName, DeprecationHandler deprecationHandler)DoesfieldNamematch this field?java.lang.StringtoString()ParseFieldwithAllDeprecated()Return a new ParseField where all field names are deprecated with no replacementParseFieldwithAllDeprecated(java.lang.String allReplacedWith)Return a new ParseField where all field names are deprecated and replaced withallReplacedWith.ParseFieldwithDeprecation(java.lang.String... deprecatedNames)Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Constructor Details
-
ParseField
public ParseField(java.lang.String name, java.lang.String... deprecatedNames)- Parameters:
name- the primary name for this field. This will be returned bygetPreferredName()deprecatedNames- names for this field which are deprecated and will not be accepted when strict matching is used.
-
-
Method Details
-
getPreferredName
public java.lang.String getPreferredName()- Returns:
- the preferred name used for this field
-
getAllNamesIncludedDeprecated
public java.lang.String[] getAllNamesIncludedDeprecated()- Returns:
- All names for this field regardless of whether they are deprecated
-
withDeprecation
- Parameters:
deprecatedNames- deprecated names to include with the returnedParseField- Returns:
- a new
ParseFieldusing the preferred name from this one but with the specified deprecated names
-
withAllDeprecated
Return a new ParseField where all field names are deprecated and replaced withallReplacedWith. -
withAllDeprecated
Return a new ParseField where all field names are deprecated with no replacement -
match
DoesfieldNamematch this field?- Parameters:
fieldName- the field name to match against thisParseFielddeprecationHandler- called iffieldNameis deprecated- Returns:
- true if
fieldNamematches any of the acceptable names for thisParseField.
-
match
public boolean match(java.lang.String parserName, java.util.function.Supplier<XContentLocation> location, java.lang.String fieldName, DeprecationHandler deprecationHandler)DoesfieldNamematch this field?- Parameters:
parserName- the name of the parent object holding this fieldlocation- the XContentLocation of the fieldfieldName- the field name to match against thisParseFielddeprecationHandler- called iffieldNameis deprecated- Returns:
- true if
fieldNamematches any of the acceptable names for thisParseField.
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-
getAllReplacedWith
public java.lang.String getAllReplacedWith()- Returns:
- the message to use if this
ParseFieldhas been entirely deprecated in favor of something else. This method will returnnullif the ParseField has not been completely deprecated.
-
getDeprecatedNames
public java.lang.String[] getDeprecatedNames()- Returns:
- an array of the names for the
ParseFieldwhich are deprecated.
-