@@ -117,7 +117,8 @@ public static class Fields {
117117 public static class TypeParser implements Mapper .TypeParser {
118118
119119 @ Override
120- public Mapper .Builder <?, ?> parse (String name , Map <String , Object > node , ParserContext parserContext ) throws MapperParsingException {
120+ public Mapper .Builder <?, ?> parse (String name , Map <String , Object > node , ParserContext parserContext )
121+ throws MapperParsingException {
121122 CompletionFieldMapper .Builder builder = new CompletionFieldMapper .Builder (name );
122123 NamedAnalyzer indexAnalyzer = null ;
123124 NamedAnalyzer searchAnalyzer = null ;
@@ -368,7 +369,8 @@ public Builder(String name) {
368369 */
369370 public Builder maxInputLength (int maxInputLength ) {
370371 if (maxInputLength <= 0 ) {
371- throw new IllegalArgumentException (Fields .MAX_INPUT_LENGTH .getPreferredName () + " must be > 0 but was [" + maxInputLength + "]" );
372+ throw new IllegalArgumentException (Fields .MAX_INPUT_LENGTH .getPreferredName ()
373+ + " must be > 0 but was [" + maxInputLength + "]" );
372374 }
373375 this .maxInputLength = maxInputLength ;
374376 return this ;
@@ -400,13 +402,15 @@ public CompletionFieldMapper build(BuilderContext context) {
400402 completionFieldType .setContextMappings (contextMappings );
401403 completionFieldType .setPreservePositionIncrements (preservePositionIncrements );
402404 completionFieldType .setPreserveSep (preserveSeparators );
403- return new CompletionFieldMapper (name , this .fieldType , context .indexSettings (), multiFieldsBuilder .build (this , context ), copyTo , maxInputLength );
405+ return new CompletionFieldMapper (name , this .fieldType , context .indexSettings (),
406+ multiFieldsBuilder .build (this , context ), copyTo , maxInputLength );
404407 }
405408 }
406409
407410 private int maxInputLength ;
408411
409- public CompletionFieldMapper (String simpleName , MappedFieldType fieldType , Settings indexSettings , MultiFields multiFields , CopyTo copyTo , int maxInputLength ) {
412+ public CompletionFieldMapper (String simpleName , MappedFieldType fieldType , Settings indexSettings ,
413+ MultiFields multiFields , CopyTo copyTo , int maxInputLength ) {
410414 super (simpleName , fieldType , Defaults .FIELD_TYPE , indexSettings , multiFields , copyTo );
411415 this .maxInputLength = maxInputLength ;
412416 }
@@ -506,7 +510,8 @@ private boolean isExternalValueOfClass(ParseContext context, Class<?> clazz) {
506510 * "STRING" - interpreted as the field value (input)
507511 * "OBJECT" - { "input": STRING|ARRAY, "weight": STRING|INT, "contexts": ARRAY|OBJECT }
508512 */
509- private void parse (ParseContext parseContext , Token token , XContentParser parser , Map <String , CompletionInputMetaData > inputMap ) throws IOException {
513+ private void parse (ParseContext parseContext , Token token ,
514+ XContentParser parser , Map <String , CompletionInputMetaData > inputMap ) throws IOException {
510515 String currentFieldName = null ;
511516 if (token == Token .VALUE_STRING ) {
512517 inputMap .put (parser .text (), new CompletionInputMetaData (parser .text (), Collections .emptyMap (), 1 ));
@@ -518,7 +523,8 @@ private void parse(ParseContext parseContext, Token token, XContentParser parser
518523 if (token == Token .FIELD_NAME ) {
519524 currentFieldName = parser .currentName ();
520525 if (!ALLOWED_CONTENT_FIELD_NAMES .contains (currentFieldName )) {
521- throw new IllegalArgumentException ("unknown field name [" + currentFieldName + "], must be one of " + ALLOWED_CONTENT_FIELD_NAMES );
526+ throw new IllegalArgumentException ("unknown field name [" + currentFieldName
527+ + "], must be one of " + ALLOWED_CONTENT_FIELD_NAMES );
522528 }
523529 } else if (currentFieldName != null ) {
524530 if (Fields .CONTENT_FIELD_NAME_INPUT .equals (currentFieldName )) {
@@ -529,7 +535,8 @@ private void parse(ParseContext parseContext, Token token, XContentParser parser
529535 if (token == Token .VALUE_STRING ) {
530536 inputs .add (parser .text ());
531537 } else {
532- throw new IllegalArgumentException ("input array must have string values, but was [" + token .name () + "]" );
538+ throw new IllegalArgumentException ("input array must have string values, but was ["
539+ + token .name () + "]" );
533540 }
534541 }
535542 } else {
@@ -552,8 +559,10 @@ private void parse(ParseContext parseContext, Token token, XContentParser parser
552559 } else {
553560 throw new IllegalArgumentException ("weight must be a number or string, but was [" + token .name () + "]" );
554561 }
555- if (weightValue .longValue () < 0 || weightValue .longValue () > Integer .MAX_VALUE ) { // always parse a long to make sure we don't get overflow
556- throw new IllegalArgumentException ("weight must be in the interval [0..2147483647], but was [" + weightValue .longValue () + "]" );
562+ // always parse a long to make sure we don't get overflow
563+ if (weightValue .longValue () < 0 || weightValue .longValue () > Integer .MAX_VALUE ) {
564+ throw new IllegalArgumentException ("weight must be in the interval [0..2147483647], but was ["
565+ + weightValue .longValue () + "]" );
557566 }
558567 weight = weightValue .intValue ();
559568 } else if (Fields .CONTENT_FIELD_NAME_CONTEXTS .equals (currentFieldName )) {
@@ -587,7 +596,8 @@ private void parse(ParseContext parseContext, Token token, XContentParser parser
587596 }
588597 }
589598 } else {
590- throw new ParsingException (parser .getTokenLocation (), "failed to parse [" + parser .currentName () + "]: expected text or object, but got " + token .name ());
599+ throw new ParsingException (parser .getTokenLocation (), "failed to parse [" + parser .currentName ()
600+ + "]: expected text or object, but got " + token .name ());
591601 }
592602 }
593603
0 commit comments