Created
July 24, 2019 21:39
-
-
Save jakelandis/ba1d08666093dc3e5d87ef3afa7dfe81 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "http://json-schema.org/draft-07/schema#", | |
"type": "object", | |
"properties": { | |
"one": { | |
"type": "string" | |
}, | |
"two": { | |
"type": "string" | |
}, | |
"three": { | |
"type": "number" | |
}, | |
"four": { | |
"type":"object", | |
"properties" :{ | |
"five": { | |
"type": "integer" | |
}, | |
"inner_four": { | |
"type": "object", | |
"properties": { | |
"five": { | |
"type": "string" | |
} | |
} | |
} | |
} | |
}, | |
"sibling": { | |
"type": "object", | |
"properties": { | |
"sister": { | |
"type": "string" | |
}, | |
"brother": { | |
"type": "boolean" | |
} | |
} | |
}, | |
"six": { | |
"type": "integer" | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package co.elastic; | |
import java.io.IOException; | |
import java.lang.Boolean; | |
import java.lang.Double; | |
import java.lang.Long; | |
import java.lang.Override; | |
import java.lang.String; | |
import java.lang.Void; | |
import org.elasticsearch.common.ParseField; | |
import org.elasticsearch.common.xcontent.ConstructingObjectParser; | |
import org.elasticsearch.common.xcontent.ToXContent; | |
import org.elasticsearch.common.xcontent.ToXContentObject; | |
import org.elasticsearch.common.xcontent.XContentBuilder; | |
/** | |
* GENERATED CODE - DO NOT MODIFY */ | |
public final class Foo implements ToXContentObject { | |
public static final ConstructingObjectParser<Foo, Void> PARSER = new ConstructingObjectParser<>(Foo.class.getName(), a -> new Foo( | |
(String) a[1], | |
(String) a[2], | |
(Double) a[3], | |
(Four) a[4], | |
(Sibling) a[5], | |
(Long) a[6])); | |
static { | |
PARSER.declareString(ConstructingObjectParser.constructorArg(), new ParseField("one")); | |
PARSER.declareString(ConstructingObjectParser.constructorArg(), new ParseField("two")); | |
PARSER.declareDouble(ConstructingObjectParser.constructorArg(), new ParseField("three")); | |
PARSER.declareObject(ConstructingObjectParser.constructorArg(), Four.PARSER, new ParseField("four")); | |
PARSER.declareObject(ConstructingObjectParser.constructorArg(), Sibling.PARSER, new ParseField("sibling")); | |
PARSER.declareLong(ConstructingObjectParser.constructorArg(), new ParseField("six")); | |
} | |
public final String one; | |
public final String two; | |
public final Double three; | |
public final Four four; | |
public final Sibling sibling; | |
public final Long six; | |
Foo(String one, String two, Double three, Four four, Sibling sibling, Long six) { | |
this.one = one; | |
this.two = two; | |
this.three = three; | |
this.four = four; | |
this.sibling = sibling; | |
this.six = six; | |
} | |
@Override | |
public XContentBuilder toXContent(final XContentBuilder builder, final ToXContent.Params params) | |
throws IOException { | |
builder.startObject(); | |
builder.field("one",one); | |
builder.field("two",two); | |
builder.field("three",three); | |
builder.field("four",four); | |
builder.field("sibling",sibling); | |
builder.field("six",six); | |
builder.endObject(); | |
return builder; | |
} | |
public static class Four implements ToXContentObject { | |
public static final ConstructingObjectParser<Four, Void> PARSER = new ConstructingObjectParser<>(Four.class.getName(), a -> new Four( | |
(Long) a[1], | |
(InnerFour) a[2])); | |
static { | |
PARSER.declareLong(ConstructingObjectParser.constructorArg(), new ParseField("five")); | |
PARSER.declareObject(ConstructingObjectParser.constructorArg(), InnerFour.PARSER, new ParseField("inner_four")); | |
} | |
public final Long five; | |
public final InnerFour inner_four; | |
Four(Long five, InnerFour inner_four) { | |
this.five = five; | |
this.inner_four = inner_four; | |
} | |
@Override | |
public XContentBuilder toXContent(final XContentBuilder builder, final ToXContent.Params params) | |
throws IOException { | |
builder.startObject(); | |
builder.field("five",five); | |
builder.field("inner_four",inner_four); | |
builder.endObject(); | |
return builder; | |
} | |
} | |
public static class InnerFour implements ToXContentObject { | |
public static final ConstructingObjectParser<InnerFour, Void> PARSER = new ConstructingObjectParser<>(InnerFour.class.getName(), a -> new InnerFour( | |
(String) a[1])); | |
static { | |
PARSER.declareString(ConstructingObjectParser.constructorArg(), new ParseField("five")); | |
} | |
public final String five; | |
InnerFour(String five) { | |
this.five = five; | |
} | |
@Override | |
public XContentBuilder toXContent(final XContentBuilder builder, final ToXContent.Params params) | |
throws IOException { | |
builder.startObject(); | |
builder.field("five",five); | |
builder.endObject(); | |
return builder; | |
} | |
} | |
public static class Sibling implements ToXContentObject { | |
public static final ConstructingObjectParser<Sibling, Void> PARSER = new ConstructingObjectParser<>(Sibling.class.getName(), a -> new Sibling( | |
(String) a[1], | |
(Boolean) a[2])); | |
static { | |
PARSER.declareString(ConstructingObjectParser.constructorArg(), new ParseField("sister")); | |
PARSER.declareBoolean(ConstructingObjectParser.constructorArg(), new ParseField("brother")); | |
} | |
public final String sister; | |
public final Boolean brother; | |
Sibling(String sister, Boolean brother) { | |
this.sister = sister; | |
this.brother = brother; | |
} | |
@Override | |
public XContentBuilder toXContent(final XContentBuilder builder, final ToXContent.Params params) | |
throws IOException { | |
builder.startObject(); | |
builder.field("sister",sister); | |
builder.field("brother",brother); | |
builder.endObject(); | |
return builder; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment