{"action":"created","comment":{"url":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments/77964896","id":77964896,"diff_hunk":"@@ -117,658 +148,904 @@ public boolean isPrettyPrint() {\n         return generator.isPrettyPrint();\n     }\n \n+    /**\n+     * Indicate that the current {@link XContentBuilder} must write a line feed (\"\\n\")\n+     * at the end of the built object.\n+     * <p>\n+     * This only applies for JSON XContent type. It has no effect for other types.\n+     */\n     public XContentBuilder lfAtEnd() {\n         generator.usePrintLineFeedAtEnd();\n         return this;\n     }\n \n+    /**\n+     * Set the \"human readable\" flag. Once set, some types of values are written in a\n+     * format easier to read for a human.\n+     */\n     public XContentBuilder humanReadable(boolean humanReadable) {\n         this.humanReadable = humanReadable;\n         return this;\n     }\n \n+    /**\n+     * @return the value of the \"human readable\" flag. When the value is equal to true,\n+     * some types of values are written in a format easier to read for a human.\n+     */\n     public boolean humanReadable() {\n         return this.humanReadable;\n     }\n \n-    public XContentBuilder field(String name, ToXContent xContent) throws IOException {\n-        field(name);\n-        xContent.toXContent(this, ToXContent.EMPTY_PARAMS);\n-        return this;\n-    }\n+    ////////////////////////////////////////////////////////////////////////////\n+    // Structure (object, array, field, null values...)\n+    //////////////////////////////////\n \n-    public XContentBuilder field(String name, ToXContent xContent, ToXContent.Params params) throws IOException {\n-        field(name);\n-        xContent.toXContent(this, params);\n+    public XContentBuilder startObject() throws IOException {\n+        writeStartObject();\n         return this;\n     }\n \n     public XContentBuilder startObject(String name) throws IOException {\n-        field(name);\n-        startObject();\n-        return this;\n+        return field(name).startObject();\n     }\n \n-    public XContentBuilder startObject() throws IOException {\n-        generator.writeStartObject();\n+    public XContentBuilder endObject() throws IOException {\n+        writeEndObject();\n         return this;\n     }\n \n-    public XContentBuilder endObject() throws IOException {\n-        generator.writeEndObject();\n+    public XContentBuilder startArray() throws IOException {\n+        writeStartArray();\n         return this;\n     }\n \n-    public XContentBuilder array(String name, String... values) throws IOException {\n-        startArray(name);\n-        for (String value : values) {\n-            value(value);\n-        }\n-        endArray();\n-        return this;\n+    public XContentBuilder startArray(String name) throws IOException {\n+        return field(name).startArray();\n     }\n \n-    public XContentBuilder array(String name, Object... values) throws IOException {\n-        startArray(name);\n-        for (Object value : values) {\n-            value(value);\n-        }\n-        endArray();\n+    public XContentBuilder endArray() throws IOException {\n+        writeEndArray();\n         return this;\n     }\n \n-    public XContentBuilder startArray(String name) throws IOException {\n-        field(name);\n-        startArray();\n+    public XContentBuilder field(String name) throws IOException {\n+        writeFieldName(name);\n         return this;\n     }\n \n-    public XContentBuilder startArray() throws IOException {\n-        generator.writeStartArray();\n+    public XContentBuilder nullField(String name) throws IOException {\n+        writeNullField(name);\n         return this;\n     }\n \n-    public XContentBuilder endArray() throws IOException {\n-        generator.writeEndArray();\n+    public XContentBuilder nullValue() throws IOException {\n+        writeNull();\n         return this;\n     }\n \n-    public XContentBuilder field(String name) throws IOException {\n-        if (name == null) {\n-            throw new IllegalArgumentException(\"field name cannot be null\");\n-        }\n-        generator.writeFieldName(name);\n-        return this;\n+    ////////////////////////////////////////////////////////////////////////////\n+    // Boolean\n+    //////////////////////////////////\n+\n+    public XContentBuilder field(String name, Boolean value) throws IOException {\n+        return (value == null) ? nullField(name) : field(name, value.booleanValue());\n     }\n \n-    public XContentBuilder field(String name, char[] value, int offset, int length) throws IOException {\n-        field(name);\n-        if (value == null) {\n-            generator.writeNull();\n-        } else {\n-            generator.writeString(value, offset, length);\n-        }\n+    public XContentBuilder field(String name, boolean value) throws IOException {\n+        writeBooleanField(name, value);\n         return this;\n     }\n \n-    public XContentBuilder field(String name, String value) throws IOException {\n-        field(name);\n-        if (value == null) {\n-            generator.writeNull();\n-        } else {\n-            generator.writeString(value);\n-        }\n-        return this;\n+    public XContentBuilder array(String name, boolean[] values) throws IOException {\n+        return field(name).values(values);\n     }\n \n-    public XContentBuilder field(String name, Integer value) throws IOException {\n-        field(name);\n-        if (value == null) {\n-            generator.writeNull();\n-        } else {\n-            generator.writeNumber(value.intValue());\n+    private XContentBuilder values(boolean[] values) throws IOException {\n+        if (values == null) {\n+            return nullValue();\n+        }\n+        startArray();\n+        for (boolean b : values) {\n+            value(b);\n         }\n+        endArray();\n         return this;\n     }\n \n-    public XContentBuilder field(String name, int value) throws IOException {\n-        field(name);\n-        generator.writeNumber(value);\n-        return this;\n+    public XContentBuilder value(Boolean value) throws IOException {\n+        return (value == null) ? nullValue() : value(value.booleanValue());\n     }\n \n-    public XContentBuilder field(String name, Long value) throws IOException {\n-        field(name);\n-        if (value == null) {\n-            generator.writeNull();\n-        } else {\n-            generator.writeNumber(value.longValue());\n-        }\n+    public XContentBuilder value(boolean value) throws IOException {\n+        writeBoolean(value);\n         return this;\n     }\n \n-    public XContentBuilder field(String name, long value) throws IOException {\n-        field(name);\n-        generator.writeNumber(value);\n-        return this;\n+    ////////////////////////////////////////////////////////////////////////////\n+    // Byte\n+    //////////////////////////////////\n+\n+    public XContentBuilder field(String name, Byte value) throws IOException {\n+        return (value == null) ? nullField(name) : field(name, value.byteValue());\n     }\n \n-    public XContentBuilder field(String name, Float value) throws IOException {\n-        field(name);\n-        if (value == null) {\n-            generator.writeNull();\n-        } else {\n-            generator.writeNumber(value.floatValue());\n-        }\n-        return this;\n+    public XContentBuilder field(String name, byte value) throws IOException {\n+        return field(name).value(value);\n     }\n \n-    public XContentBuilder field(String name, float value) throws IOException {\n-        field(name);\n-        generator.writeNumber(value);\n+    public XContentBuilder value(Byte value) throws IOException {\n+        return (value == null) ? nullValue() : value(value.byteValue());\n+    }\n+\n+    public XContentBuilder value(byte value) throws IOException {\n+        writeNumber(value);\n         return this;\n     }\n \n+    ////////////////////////////////////////////////////////////////////////////\n+    // Double\n+    //////////////////////////////////\n+\n     public XContentBuilder field(String name, Double value) throws IOException {\n-        field(name);\n-        if (value == null) {\n-            generator.writeNull();\n-        } else {\n-            generator.writeNumber(value);\n-        }\n-        return this;\n+        return (value == null) ? nullField(name) : field(name, value.doubleValue());\n     }\n \n     public XContentBuilder field(String name, double value) throws IOException {\n-        field(name);\n-        generator.writeNumber(value);\n+        writeNumberField(name, value);\n         return this;\n     }\n \n-    public XContentBuilder field(String name, BigDecimal value) throws IOException {\n-        return field(name, value, value.scale(), RoundingMode.HALF_UP, true);\n+    public XContentBuilder array(String name, double[] values) throws IOException {\n+        return field(name).values(values);\n     }\n \n-    public XContentBuilder field(String name, BigDecimal value, int scale, RoundingMode rounding, boolean toDouble) throws IOException {\n-        field(name);\n-        if (value == null) {\n-            generator.writeNull();\n-        } else {\n-            if (toDouble) {\n-                try {\n-                    generator.writeNumber(value.setScale(scale, rounding).doubleValue());\n-                } catch (ArithmeticException e) {\n-                    generator.writeString(value.toEngineeringString());\n-                }\n-            } else {\n-                generator.writeString(value.toEngineeringString());\n-            }\n+    private XContentBuilder values(double[] values) throws IOException {\n+        if (values == null) {\n+            return nullValue();\n+        }\n+        startArray();\n+        for (double b : values) {\n+            value(b);\n         }\n+        endArray();\n         return this;\n     }\n \n-    /**\n-     * Writes the binary content of the given BytesRef\n-     * Use {@link org.elasticsearch.common.xcontent.XContentParser#binaryValue()} to read the value back\n-     */\n-    public XContentBuilder field(String name, BytesRef value) throws IOException {\n-        field(name);\n-        generator.writeBinary(value.bytes, value.offset, value.length);\n-        return this;\n+    public XContentBuilder value(Double value) throws IOException {\n+        return (value == null) ? nullValue() : value(value.doubleValue());\n     }\n \n-    /**\n-     * Writes the binary content of the given BytesReference\n-     * Use {@link org.elasticsearch.common.xcontent.XContentParser#binaryValue()} to read the value back\n-     */\n-    public XContentBuilder field(String name, BytesReference value) throws IOException {\n-        field(name);\n-        final BytesRef ref = value.toBytesRef();\n-        generator.writeBinary(ref.bytes, ref.offset, ref.length);\n+    public XContentBuilder value(double value) throws IOException {\n+        writeNumber(value);\n         return this;\n     }\n \n-    /**\n-     * Writes the binary content of the given BytesRef as UTF-8 bytes\n-     * Use {@link XContentParser#utf8Bytes()} to read the value back\n-     */\n-    public XContentBuilder utf8Field(String name, BytesRef value) throws IOException {\n-        field(name);\n-        generator.writeUTF8String(value.bytes, value.offset, value.length);\n-        return this;\n-    }\n+    ////////////////////////////////////////////////////////////////////////////\n+    // Float\n+    //////////////////////////////////\n \n-    public XContentBuilder field(String name, Text value) throws IOException {\n-        field(name);\n-        if (value.hasString()) {\n-            generator.writeString(value.string());\n-        } else {\n-            // TODO: TextBytesOptimization we can use a buffer here to convert it? maybe add a request to jackson to support InputStream as well?\n-            final BytesRef ref = value.bytes().toBytesRef();\n-            generator.writeUTF8String(ref.bytes, ref.offset, ref.length);\n-        }\n-        return this;\n+    public XContentBuilder field(String name, Float value) throws IOException {\n+        return (value == null) ? nullField(name) : field(name, value.floatValue());\n     }\n \n-    public XContentBuilder field(String name, byte[] value, int offset, int length) throws IOException {\n-        field(name);\n-        generator.writeBinary(value, offset, length);\n+    public XContentBuilder field(String name, float value) throws IOException {\n+        writeNumberField(name, value);\n         return this;\n     }\n \n-    public XContentBuilder field(String name, Map<String, Object> value) throws IOException {\n-        field(name);\n-        value(value);\n-        return this;\n+    public XContentBuilder array(String name, float[] values) throws IOException {\n+        return field(name).values(values);\n     }\n \n-    public XContentBuilder field(String name, Iterable<?> value) throws IOException {\n-        if (value instanceof Path) {\n-            //treat Paths as single value\n-            field(name);\n-            value(value);\n-        } else {\n-            startArray(name);\n-            for (Object o : value) {\n-                value(o);\n-            }\n-            endArray();\n+    private XContentBuilder values(float[] values) throws IOException {\n+        if (values == null) {\n+            return nullValue();\n         }\n-        return this;\n-    }\n-\n-    public XContentBuilder field(String name, boolean... value) throws IOException {\n-        startArray(name);\n-        for (boolean o : value) {\n-            value(o);\n+        startArray();\n+        for (float f : values) {\n+            value(f);\n         }\n         endArray();\n         return this;\n     }\n \n-    public XContentBuilder field(String name, String... value) throws IOException {\n-        startArray(name);\n-        for (String o : value) {\n-            value(o);\n-        }\n-        endArray();\n-        return this;\n+    public XContentBuilder value(Float value) throws IOException {\n+        return (value == null) ? nullValue() : value(value.floatValue());\n     }\n \n-    public XContentBuilder field(String name, Object... value) throws IOException {\n-        startArray(name);\n-        for (Object o : value) {\n-            value(o);\n-        }\n-        endArray();\n+    public XContentBuilder value(float value) throws IOException {\n+        writeNumber(value);\n         return this;\n     }\n \n-    public XContentBuilder field(String name, int... value) throws IOException {\n-        startArray(name);\n-        for (Object o : value) {\n-            value(o);\n-        }\n-        endArray();\n-        return this;\n+    ////////////////////////////////////////////////////////////////////////////\n+    // Integer\n+    //////////////////////////////////\n+\n+    public XContentBuilder field(String name, Integer value) throws IOException {\n+        return (value == null) ? nullField(name) : field(name, value.intValue());\n     }\n \n-    public XContentBuilder field(String name, long... value) throws IOException {\n-        startArray(name);\n-        for (Object o : value) {\n-            value(o);\n-        }\n-        endArray();\n+    public XContentBuilder field(String name, int value) throws IOException {\n+        writeNumberField(name, value);\n         return this;\n     }\n \n-    public XContentBuilder field(String name, float... value) throws IOException {\n-        startArray(name);\n-        for (Object o : value) {\n-            value(o);\n-        }\n-        endArray();\n-        return this;\n+    public XContentBuilder array(String name, int[] values) throws IOException {\n+        return field(name).values(values);\n     }\n \n-    public XContentBuilder field(String name, double... value) throws IOException {\n-        startArray(name);\n-        for (Object o : value) {\n-            value(o);\n+    private XContentBuilder values(int[] values) throws IOException {\n+        if (values == null) {\n+            return nullValue();\n         }\n-        endArray();\n+        writeArray(values);\n         return this;\n     }\n \n-    public XContentBuilder field(String name, Object value) throws IOException {\n-        field(name);\n-        writeValue(value);\n-        return this;\n+    public XContentBuilder value(Integer value) throws IOException {\n+        return (value == null) ? nullValue() : value(value.intValue());\n     }\n \n-    public XContentBuilder value(Object value) throws IOException {\n-        writeValue(value);\n+    public XContentBuilder value(int value) throws IOException {\n+        writeNumber(value);\n         return this;\n     }\n \n-    public XContentBuilder field(String name, boolean value) throws IOException {\n-        field(name);\n-        generator.writeBoolean(value);\n-        return this;\n-    }\n+    ////////////////////////////////////////////////////////////////////////////\n+    // Long\n+    //////////////////////////////////\n \n-    public XContentBuilder field(String name, byte[] value) throws IOException {\n-        field(name);\n-        if (value == null) {\n-            generator.writeNull();\n-        } else {\n-            generator.writeBinary(value);\n-        }\n-        return this;\n+    public XContentBuilder field(String name, Long value) throws IOException {\n+        return (value == null) ? nullField(name) : field(name, value.longValue());\n     }\n \n-    public XContentBuilder field(String name, ReadableInstant date) throws IOException {\n-        field(name);\n-        return value(date);\n+    public XContentBuilder field(String name, long value) throws IOException {\n+        writeNumberField(name, value);\n+        return this;\n     }\n \n-    public XContentBuilder field(String name, ReadableInstant date, DateTimeFormatter formatter) throws IOException {\n-        field(name);\n-        return value(date, formatter);\n+    public XContentBuilder array(String name, long[] values) throws IOException {\n+        return field(name).values(values);\n     }\n \n-    public XContentBuilder field(String name, Date date) throws IOException {\n-        field(name);\n-        return value(date);\n+    private XContentBuilder values(long[] values) throws IOException {\n+        if (values == null) {\n+            return nullValue();\n+        }\n+        writeArray(values);\n+        return this;\n     }\n \n-    public XContentBuilder field(String name, Date date, DateTimeFormatter formatter) throws IOException {\n-        field(name);\n-        return value(date, formatter);\n+    public XContentBuilder value(Long value) throws IOException {\n+        return (value == null) ? nullValue() : value(value.longValue());\n     }\n \n-    public XContentBuilder nullField(String name) throws IOException {\n-        generator.writeNullField(name);\n+    public XContentBuilder value(long value) throws IOException {\n+        writeNumber(value);\n         return this;\n     }\n \n-    public XContentBuilder nullValue() throws IOException {\n-        generator.writeNull();\n-        return this;\n-    }\n+    ////////////////////////////////////////////////////////////////////////////\n+    // Short\n+    //////////////////////////////////\n \n-    public XContentBuilder rawField(String fieldName, InputStream content) throws IOException {\n-        generator.writeRawField(fieldName, content);\n-        return this;\n+    public XContentBuilder field(String name, Short value) throws IOException {\n+        return (value == null) ? nullField(name) : field(name, value.shortValue());\n     }\n \n-    public XContentBuilder rawField(String fieldName, BytesReference content) throws IOException {\n-        generator.writeRawField(fieldName, content);\n-        return this;\n+    public XContentBuilder field(String name, short value) throws IOException {\n+        return field(name).value(value);\n     }\n \n-    public XContentBuilder rawValue(BytesReference content) throws IOException {\n-        generator.writeRawValue(content);\n-        return this;\n+    public XContentBuilder array(String name, short[] values) throws IOException {\n+        return field(name).values(values);\n     }\n \n-    public XContentBuilder timeValueField(String rawFieldName, String readableFieldName, TimeValue timeValue) throws IOException {\n-        if (humanReadable) {\n-            field(readableFieldName, timeValue.toString());\n+    private XContentBuilder values(short[] values) throws IOException {\n+        if (values == null) {\n+            return nullValue();\n         }\n-        field(rawFieldName, timeValue.millis());\n+        startArray();\n+        for (short s : values) {\n+            value(s);\n+        }\n+        endArray();\n         return this;\n     }\n \n-    public XContentBuilder timeValueField(String rawFieldName, String readableFieldName, long rawTime) throws IOException {\n-        if (humanReadable) {\n-            field(readableFieldName, new TimeValue(rawTime).toString());\n-        }\n-        field(rawFieldName, rawTime);\n-        return this;\n+    public XContentBuilder value(Short value) throws IOException {\n+        return (value == null) ? nullValue() : value(value.shortValue());\n     }\n \n-    public XContentBuilder timeValueField(String rawFieldName, String readableFieldName, long rawTime, TimeUnit timeUnit) throws\n-        IOException {\n-        if (humanReadable) {\n-            field(readableFieldName, new TimeValue(rawTime, timeUnit).toString());\n-        }\n-        field(rawFieldName, rawTime);\n+    public XContentBuilder value(short value) throws IOException {\n+        writeNumber(value);\n         return this;\n     }\n \n-    public XContentBuilder dateValueField(String rawFieldName, String readableFieldName, long rawTimestamp) throws IOException {\n-        if (humanReadable) {\n-            field(readableFieldName, defaultDatePrinter.print(rawTimestamp));\n+    ////////////////////////////////////////////////////////////////////////////\n+    // String\n+    //////////////////////////////////\n+\n+    public XContentBuilder field(String name, String value) throws IOException {\n+        if (value == null) {\n+            return nullField(name);\n         }\n-        field(rawFieldName, rawTimestamp);\n+        writeStringField(name, value);\n         return this;\n     }\n \n-    public XContentBuilder byteSizeField(String rawFieldName, String readableFieldName, ByteSizeValue byteSizeValue) throws IOException {\n-        if (humanReadable) {\n-            field(readableFieldName, byteSizeValue.toString());\n+    public XContentBuilder array(String name, String... values) throws IOException {\n+        return field(name).values(values);\n+    }\n+\n+    private XContentBuilder values(String[] values) throws IOException {\n+        if (values == null) {\n+            return nullValue();\n         }\n-        field(rawFieldName, byteSizeValue.bytes());\n+        startArray();\n+        for (String s : values) {\n+            value(s);\n+        }\n+        endArray();\n         return this;\n     }\n \n-    public XContentBuilder byteSizeField(String rawFieldName, String readableFieldName, long rawSize) throws IOException {\n-        if (humanReadable) {\n-            field(readableFieldName, new ByteSizeValue(rawSize).toString());\n+    public XContentBuilder value(String value) throws IOException {\n+        if (value == null) {\n+            return nullValue();\n         }\n-        field(rawFieldName, rawSize);\n+        writeString(value);\n         return this;\n     }\n \n-    public XContentBuilder percentageField(String rawFieldName, String readableFieldName, double percentage) throws IOException {\n-        if (humanReadable) {\n-            field(readableFieldName, String.format(Locale.ROOT, \"%1.1f%%\", percentage));\n+    ////////////////////////////////////////////////////////////////////////////\n+    // Binary\n+    //////////////////////////////////\n+\n+    public XContentBuilder field(String name, byte[] value) throws IOException {\n+        if (value == null) {\n+            return nullField(name);\n         }\n-        field(rawFieldName, percentage);\n+        writeBinaryField(name, value);\n         return this;\n     }\n \n-    public XContentBuilder value(Boolean value) throws IOException {\n+    public XContentBuilder value(byte[] value) throws IOException {\n         if (value == null) {\n             return nullValue();\n         }\n-        return value(value.booleanValue());\n-    }\n-\n-    public XContentBuilder value(boolean value) throws IOException {\n-        generator.writeBoolean(value);\n+        writeBinary(value);\n         return this;\n     }\n \n-    public XContentBuilder value(ReadableInstant date) throws IOException {\n-        return value(date, defaultDatePrinter);\n+    public XContentBuilder field(String name, byte[] value, int offset, int length) throws IOException {\n+        return field(name).value(value, offset, length);\n     }\n \n-    public XContentBuilder value(ReadableInstant date, DateTimeFormatter dateTimeFormatter) throws IOException {\n-        if (date == null) {\n+    public XContentBuilder value(byte[] value, int offset, int length) throws IOException {\n+        if (value == null) {\n             return nullValue();\n         }\n-        return value(dateTimeFormatter.print(date));\n-    }\n-\n-    public XContentBuilder value(Date date) throws IOException {\n-        return value(date, defaultDatePrinter);\n+        writeBinary(value, offset, length);\n+        return this;\n     }\n \n-    public XContentBuilder value(Date date, DateTimeFormatter dateTimeFormatter) throws IOException {\n-        if (date == null) {\n+    /**\n+     * Writes the binary content of the given {@link BytesRef}.\n+     *\n+     * Use {@link org.elasticsearch.common.xcontent.XContentParser#binaryValue()} to read the value back\n+     */\n+    public XContentBuilder field(String name, BytesRef value) throws IOException {\n+        return field(name).value(value);\n+    }\n+\n+    /**\n+     * Writes the binary content of the given {@link BytesRef} as UTF-8 bytes.\n+     *\n+     * Use {@link XContentParser#utf8Bytes()} to read the value back\n+     */\n+    public XContentBuilder utf8Field(String name, BytesRef value) throws IOException {\n+        return field(name).utf8Value(value);\n+    }\n+\n+    /**\n+     * Writes the binary content of the given {@link BytesRef}.\n+     *\n+     * Use {@link org.elasticsearch.common.xcontent.XContentParser#binaryValue()} to read the value back\n+     */\n+    public XContentBuilder value(BytesRef value) throws IOException {","path":"core/src/main/java/org/elasticsearch/common/xcontent/XContentBuilder.java","position":820,"original_position":820,"commit_id":"a3b5c92cc1b5696b23b7169c80b0dc41a1102409","original_commit_id":"a3b5c92cc1b5696b23b7169c80b0dc41a1102409","user":{"login":"tlrx","id":642733,"avatar_url":"https://avatars.githubusercontent.com/u/642733?v=3","gravatar_id":"","url":"https://api.github.com/users/tlrx","html_url":"https://github.com/tlrx","followers_url":"https://api.github.com/users/tlrx/followers","following_url":"https://api.github.com/users/tlrx/following{/other_user}","gists_url":"https://api.github.com/users/tlrx/gists{/gist_id}","starred_url":"https://api.github.com/users/tlrx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tlrx/subscriptions","organizations_url":"https://api.github.com/users/tlrx/orgs","repos_url":"https://api.github.com/users/tlrx/repos","events_url":"https://api.github.com/users/tlrx/events{/privacy}","received_events_url":"https://api.github.com/users/tlrx/received_events","type":"User","site_admin":false},"body":"Good point - this will also be more coherent with the `XContentParser.binaryValue()` method","created_at":"2016-09-08T08:28:36Z","updated_at":"2016-09-08T08:28:36Z","html_url":"https://github.com/elastic/elasticsearch/pull/20344#discussion_r77964896","pull_request_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/20344","_links":{"self":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments/77964896"},"html":{"href":"https://github.com/elastic/elasticsearch/pull/20344#discussion_r77964896"},"pull_request":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/20344"}}},"pull_request":{"url":"https://api.github.com/repos/elastic/elasticsearch/pulls/20344","id":84155673,"html_url":"https://github.com/elastic/elasticsearch/pull/20344","diff_url":"https://github.com/elastic/elasticsearch/pull/20344.diff","patch_url":"https://github.com/elastic/elasticsearch/pull/20344.patch","issue_url":"https://api.github.com/repos/elastic/elasticsearch/issues/20344","number":20344,"state":"open","locked":false,"title":"Clean up XContentBuilder","user":{"login":"tlrx","id":642733,"avatar_url":"https://avatars.githubusercontent.com/u/642733?v=3","gravatar_id":"","url":"https://api.github.com/users/tlrx","html_url":"https://github.com/tlrx","followers_url":"https://api.github.com/users/tlrx/followers","following_url":"https://api.github.com/users/tlrx/following{/other_user}","gists_url":"https://api.github.com/users/tlrx/gists{/gist_id}","starred_url":"https://api.github.com/users/tlrx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tlrx/subscriptions","organizations_url":"https://api.github.com/users/tlrx/orgs","repos_url":"https://api.github.com/users/tlrx/repos","events_url":"https://api.github.com/users/tlrx/events{/privacy}","received_events_url":"https://api.github.com/users/tlrx/received_events","type":"User","site_admin":false},"body":"Work in progress - I'd like the CI to run\r\n\r\nThis PR cleans most of the methods of XContentBuilder so that:\r\n\r\n- methods that actually write to the underlying `XContentGenerator` are now private and all prefixed with a \"write\" (like `writeNumber(long)`)\r\n- Jackson's convenience methods are used instead of our custom ones (ie `field(String,long) `now uses Jackson's `writeNumberField(String, long)` instead of calling `writeField(String)` then `writeNumber(long)`)\r\n- null checks are added for all field names and values\r\n- methods are grouped by type in the class source\r\n- methods have the same parameters names\r\n- duplicated methods like `field(String, String...)` and `array(String, String...`) are removed in favor of the latter\r\n- varargs methods now have the \"array\" name to reflect that it builds arrays\r\n- unused methods like `field(String,BigDecimal)` are removed\r\n- all methods now follow the execution path field(String,?) -> field(String) then value(?), and value(?) -> writeSomething() method. Methods to build arrays also follow the same execution path.\r\n- use optimized Jackson v2.8 methods to write int and long arrays\r\n\r\nIt also adds basic tests for these method so that Jackson updates will be more comfortable.\r\n\r\n","created_at":"2016-09-06T16:37:17Z","updated_at":"2016-09-08T08:28:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"139688fea4f18be5a91ba4125daffb8a2ab9c5fc","assignee":{"login":"nik9000","id":215970,"avatar_url":"https://avatars.githubusercontent.com/u/215970?v=3","gravatar_id":"","url":"https://api.github.com/users/nik9000","html_url":"https://github.com/nik9000","followers_url":"https://api.github.com/users/nik9000/followers","following_url":"https://api.github.com/users/nik9000/following{/other_user}","gists_url":"https://api.github.com/users/nik9000/gists{/gist_id}","starred_url":"https://api.github.com/users/nik9000/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nik9000/subscriptions","organizations_url":"https://api.github.com/users/nik9000/orgs","repos_url":"https://api.github.com/users/nik9000/repos","events_url":"https://api.github.com/users/nik9000/events{/privacy}","received_events_url":"https://api.github.com/users/nik9000/received_events","type":"User","site_admin":false},"assignees":[{"login":"nik9000","id":215970,"avatar_url":"https://avatars.githubusercontent.com/u/215970?v=3","gravatar_id":"","url":"https://api.github.com/users/nik9000","html_url":"https://github.com/nik9000","followers_url":"https://api.github.com/users/nik9000/followers","following_url":"https://api.github.com/users/nik9000/following{/other_user}","gists_url":"https://api.github.com/users/nik9000/gists{/gist_id}","starred_url":"https://api.github.com/users/nik9000/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nik9000/subscriptions","organizations_url":"https://api.github.com/users/nik9000/orgs","repos_url":"https://api.github.com/users/nik9000/repos","events_url":"https://api.github.com/users/nik9000/events{/privacy}","received_events_url":"https://api.github.com/users/nik9000/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/20344/commits","review_comments_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/20344/comments","review_comment_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments{/number}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/20344/comments","statuses_url":"https://api.github.com/repos/elastic/elasticsearch/statuses/a3b5c92cc1b5696b23b7169c80b0dc41a1102409","head":{"label":"tlrx:refactor-xcontentbuilder","ref":"refactor-xcontentbuilder","sha":"a3b5c92cc1b5696b23b7169c80b0dc41a1102409","user":{"login":"tlrx","id":642733,"avatar_url":"https://avatars.githubusercontent.com/u/642733?v=3","gravatar_id":"","url":"https://api.github.com/users/tlrx","html_url":"https://github.com/tlrx","followers_url":"https://api.github.com/users/tlrx/followers","following_url":"https://api.github.com/users/tlrx/following{/other_user}","gists_url":"https://api.github.com/users/tlrx/gists{/gist_id}","starred_url":"https://api.github.com/users/tlrx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tlrx/subscriptions","organizations_url":"https://api.github.com/users/tlrx/orgs","repos_url":"https://api.github.com/users/tlrx/repos","events_url":"https://api.github.com/users/tlrx/events{/privacy}","received_events_url":"https://api.github.com/users/tlrx/received_events","type":"User","site_admin":false},"repo":{"id":24718639,"name":"elasticsearch","full_name":"tlrx/elasticsearch","owner":{"login":"tlrx","id":642733,"avatar_url":"https://avatars.githubusercontent.com/u/642733?v=3","gravatar_id":"","url":"https://api.github.com/users/tlrx","html_url":"https://github.com/tlrx","followers_url":"https://api.github.com/users/tlrx/followers","following_url":"https://api.github.com/users/tlrx/following{/other_user}","gists_url":"https://api.github.com/users/tlrx/gists{/gist_id}","starred_url":"https://api.github.com/users/tlrx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tlrx/subscriptions","organizations_url":"https://api.github.com/users/tlrx/orgs","repos_url":"https://api.github.com/users/tlrx/repos","events_url":"https://api.github.com/users/tlrx/events{/privacy}","received_events_url":"https://api.github.com/users/tlrx/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tlrx/elasticsearch","description":"Open Source, Distributed, RESTful Search Engine","fork":true,"url":"https://api.github.com/repos/tlrx/elasticsearch","forks_url":"https://api.github.com/repos/tlrx/elasticsearch/forks","keys_url":"https://api.github.com/repos/tlrx/elasticsearch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tlrx/elasticsearch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tlrx/elasticsearch/teams","hooks_url":"https://api.github.com/repos/tlrx/elasticsearch/hooks","issue_events_url":"https://api.github.com/repos/tlrx/elasticsearch/issues/events{/number}","events_url":"https://api.github.com/repos/tlrx/elasticsearch/events","assignees_url":"https://api.github.com/repos/tlrx/elasticsearch/assignees{/user}","branches_url":"https://api.github.com/repos/tlrx/elasticsearch/branches{/branch}","tags_url":"https://api.github.com/repos/tlrx/elasticsearch/tags","blobs_url":"https://api.github.com/repos/tlrx/elasticsearch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tlrx/elasticsearch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tlrx/elasticsearch/git/refs{/sha}","trees_url":"https://api.github.com/repos/tlrx/elasticsearch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tlrx/elasticsearch/statuses/{sha}","languages_url":"https://api.github.com/repos/tlrx/elasticsearch/languages","stargazers_url":"https://api.github.com/repos/tlrx/elasticsearch/stargazers","contributors_url":"https://api.github.com/repos/tlrx/elasticsearch/contributors","subscribers_url":"https://api.github.com/repos/tlrx/elasticsearch/subscribers","subscription_url":"https://api.github.com/repos/tlrx/elasticsearch/subscription","commits_url":"https://api.github.com/repos/tlrx/elasticsearch/commits{/sha}","git_commits_url":"https://api.github.com/repos/tlrx/elasticsearch/git/commits{/sha}","comments_url":"https://api.github.com/repos/tlrx/elasticsearch/comments{/number}","issue_comment_url":"https://api.github.com/repos/tlrx/elasticsearch/issues/comments{/number}","contents_url":"https://api.github.com/repos/tlrx/elasticsearch/contents/{+path}","compare_url":"https://api.github.com/repos/tlrx/elasticsearch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tlrx/elasticsearch/merges","archive_url":"https://api.github.com/repos/tlrx/elasticsearch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tlrx/elasticsearch/downloads","issues_url":"https://api.github.com/repos/tlrx/elasticsearch/issues{/number}","pulls_url":"https://api.github.com/repos/tlrx/elasticsearch/pulls{/number}","milestones_url":"https://api.github.com/repos/tlrx/elasticsearch/milestones{/number}","notifications_url":"https://api.github.com/repos/tlrx/elasticsearch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tlrx/elasticsearch/labels{/name}","releases_url":"https://api.github.com/repos/tlrx/elasticsearch/releases{/id}","deployments_url":"https://api.github.com/repos/tlrx/elasticsearch/deployments","created_at":"2014-10-02T12:51:44Z","updated_at":"2014-10-02T08:42:36Z","pushed_at":"2016-09-07T13:09:10Z","git_url":"git://github.com/tlrx/elasticsearch.git","ssh_url":"git@github.com:tlrx/elasticsearch.git","clone_url":"https://github.com/tlrx/elasticsearch.git","svn_url":"https://github.com/tlrx/elasticsearch","homepage":"http://elasticsearch.org","size":205852,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"elastic:master","ref":"master","sha":"e77f4710e4979071e8cfe876af081d0d6ce53855","user":{"login":"elastic","id":6764390,"avatar_url":"https://avatars.githubusercontent.com/u/6764390?v=3","gravatar_id":"","url":"https://api.github.com/users/elastic","html_url":"https://github.com/elastic","followers_url":"https://api.github.com/users/elastic/followers","following_url":"https://api.github.com/users/elastic/following{/other_user}","gists_url":"https://api.github.com/users/elastic/gists{/gist_id}","starred_url":"https://api.github.com/users/elastic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elastic/subscriptions","organizations_url":"https://api.github.com/users/elastic/orgs","repos_url":"https://api.github.com/users/elastic/repos","events_url":"https://api.github.com/users/elastic/events{/privacy}","received_events_url":"https://api.github.com/users/elastic/received_events","type":"Organization","site_admin":false},"repo":{"id":507775,"name":"elasticsearch","full_name":"elastic/elasticsearch","owner":{"login":"elastic","id":6764390,"avatar_url":"https://avatars.githubusercontent.com/u/6764390?v=3","gravatar_id":"","url":"https://api.github.com/users/elastic","html_url":"https://github.com/elastic","followers_url":"https://api.github.com/users/elastic/followers","following_url":"https://api.github.com/users/elastic/following{/other_user}","gists_url":"https://api.github.com/users/elastic/gists{/gist_id}","starred_url":"https://api.github.com/users/elastic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elastic/subscriptions","organizations_url":"https://api.github.com/users/elastic/orgs","repos_url":"https://api.github.com/users/elastic/repos","events_url":"https://api.github.com/users/elastic/events{/privacy}","received_events_url":"https://api.github.com/users/elastic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/elastic/elasticsearch","description":"Open Source, Distributed, RESTful Search Engine","fork":false,"url":"https://api.github.com/repos/elastic/elasticsearch","forks_url":"https://api.github.com/repos/elastic/elasticsearch/forks","keys_url":"https://api.github.com/repos/elastic/elasticsearch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/elastic/elasticsearch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/elastic/elasticsearch/teams","hooks_url":"https://api.github.com/repos/elastic/elasticsearch/hooks","issue_events_url":"https://api.github.com/repos/elastic/elasticsearch/issues/events{/number}","events_url":"https://api.github.com/repos/elastic/elasticsearch/events","assignees_url":"https://api.github.com/repos/elastic/elasticsearch/assignees{/user}","branches_url":"https://api.github.com/repos/elastic/elasticsearch/branches{/branch}","tags_url":"https://api.github.com/repos/elastic/elasticsearch/tags","blobs_url":"https://api.github.com/repos/elastic/elasticsearch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/elastic/elasticsearch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/elastic/elasticsearch/git/refs{/sha}","trees_url":"https://api.github.com/repos/elastic/elasticsearch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/elastic/elasticsearch/statuses/{sha}","languages_url":"https://api.github.com/repos/elastic/elasticsearch/languages","stargazers_url":"https://api.github.com/repos/elastic/elasticsearch/stargazers","contributors_url":"https://api.github.com/repos/elastic/elasticsearch/contributors","subscribers_url":"https://api.github.com/repos/elastic/elasticsearch/subscribers","subscription_url":"https://api.github.com/repos/elastic/elasticsearch/subscription","commits_url":"https://api.github.com/repos/elastic/elasticsearch/commits{/sha}","git_commits_url":"https://api.github.com/repos/elastic/elasticsearch/git/commits{/sha}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/comments{/number}","issue_comment_url":"https://api.github.com/repos/elastic/elasticsearch/issues/comments{/number}","contents_url":"https://api.github.com/repos/elastic/elasticsearch/contents/{+path}","compare_url":"https://api.github.com/repos/elastic/elasticsearch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/elastic/elasticsearch/merges","archive_url":"https://api.github.com/repos/elastic/elasticsearch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/elastic/elasticsearch/downloads","issues_url":"https://api.github.com/repos/elastic/elasticsearch/issues{/number}","pulls_url":"https://api.github.com/repos/elastic/elasticsearch/pulls{/number}","milestones_url":"https://api.github.com/repos/elastic/elasticsearch/milestones{/number}","notifications_url":"https://api.github.com/repos/elastic/elasticsearch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/elastic/elasticsearch/labels{/name}","releases_url":"https://api.github.com/repos/elastic/elasticsearch/releases{/id}","deployments_url":"https://api.github.com/repos/elastic/elasticsearch/deployments","created_at":"2010-02-08T13:20:56Z","updated_at":"2016-09-08T08:22:09Z","pushed_at":"2016-09-08T06:49:19Z","git_url":"git://github.com/elastic/elasticsearch.git","ssh_url":"git@github.com:elastic/elasticsearch.git","clone_url":"https://github.com/elastic/elasticsearch.git","svn_url":"https://github.com/elastic/elasticsearch","homepage":"https://www.elastic.co/products/elasticsearch","size":347899,"stargazers_count":18303,"watchers_count":18303,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":6231,"mirror_url":null,"open_issues_count":1142,"forks":6231,"open_issues":1142,"watchers":18303,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/20344"},"html":{"href":"https://github.com/elastic/elasticsearch/pull/20344"},"issue":{"href":"https://api.github.com/repos/elastic/elasticsearch/issues/20344"},"comments":{"href":"https://api.github.com/repos/elastic/elasticsearch/issues/20344/comments"},"review_comments":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/20344/comments"},"review_comment":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/20344/commits"},"statuses":{"href":"https://api.github.com/repos/elastic/elasticsearch/statuses/a3b5c92cc1b5696b23b7169c80b0dc41a1102409"}}}}
{"actor":{"display_login":"tlrx"}}