public final String toSchema() { StringBuilder builder = new StringBuilder(); appendDocumentation(builder, documentation()); builder.append("oneof ").append(name()).append(" {"); if (!fields().isEmpty()) { builder.append('\n'); for (FieldElement field : fields()) { appendIndented(builder, field.toSchema()); } } if (!groups().isEmpty()) { builder.append('\n'); for (GroupElement group : groups()) { appendIndented(builder, group.toSchema()); } } return builder.append("}\n").toString(); }
static ImmutableList<OneOf> fromElements(String packageName, ImmutableList<OneOfElement> elements, boolean extension) { ImmutableList.Builder<OneOf> oneOfs = ImmutableList.builder(); for (OneOfElement oneOf : elements) { if (!oneOf.groups().isEmpty()) { GroupElement group = oneOf.groups().get(0); throw new IllegalStateException(group.location() + ": 'group' is not supported"); } oneOfs.add(new OneOf(oneOf.name(), oneOf.documentation(), Field.fromElements(packageName, oneOf.fields(), extension))); } return oneOfs.build(); }
@Override public boolean equals(Object o) { if (o == this) { return true; } if (o instanceof OneOfElement) { OneOfElement that = (OneOfElement) o; return (this.name.equals(that.name())) && (this.documentation.equals(that.documentation())) && (this.fields.equals(that.fields())) && (this.groups.equals(that.groups())); } return false; }
static ImmutableList<OneOf> fromElements(String packageName, ImmutableList<OneOfElement> elements, boolean extension) { ImmutableList.Builder<OneOf> oneOfs = ImmutableList.builder(); for (OneOfElement oneOf : elements) { if (!oneOf.groups().isEmpty()) { throw new IllegalStateException("'group' is not supported"); } oneOfs.add(new OneOf(oneOf.name(), oneOf.documentation(), Field.fromElements(packageName, oneOf.fields(), extension))); } return oneOfs.build(); }
static ImmutableList<OneOf> fromElements(String packageName, ImmutableList<OneOfElement> elements, boolean extension) { ImmutableList.Builder<OneOf> oneOfs = ImmutableList.builder(); for (OneOfElement oneOf : elements) { if (!oneOf.groups().isEmpty()) { throw new IllegalStateException("'group' is not supported"); } oneOfs.add(new OneOf(oneOf.name(), oneOf.documentation(), Field.fromElements(packageName, oneOf.fields(), extension))); } return oneOfs.build(); }
public final String toSchema() { StringBuilder builder = new StringBuilder(); appendDocumentation(builder, documentation()); builder.append("oneof ").append(name()).append(" {"); if (!fields().isEmpty()) { builder.append('\n'); for (FieldElement field : fields()) { appendIndented(builder, field.toSchema()); } } if (!groups().isEmpty()) { builder.append('\n'); for (GroupElement group : groups()) { appendIndented(builder, group.toSchema()); } } return builder.append("}\n").toString(); }
public final String toSchema() { StringBuilder builder = new StringBuilder(); appendDocumentation(builder, documentation()); builder.append("oneof ").append(name()).append(" {"); if (!fields().isEmpty()) { builder.append('\n'); for (FieldElement field : fields()) { appendIndented(builder, field.toSchema()); } } if (!groups().isEmpty()) { builder.append('\n'); for (GroupElement group : groups()) { appendIndented(builder, group.toSchema()); } } return builder.append("}\n").toString(); }
Builder(OneOfElement source) { this.name = source.name(); this.documentation = source.documentation(); this.fields = source.fields(); this.groups = source.groups(); } @Override