/** * Generate schemas for all input and output types with the given {@link SchemaGenerator}. * @param generator The {@link SchemaGenerator} for generating type schema. */ public void generateSchema(SchemaGenerator generator) throws UnsupportedTypeException { if (inputs == null && outputs == null && inputTypes != null && outputTypes != null) { // Generate both inputs and outputs before making this visible Map<String, Set<Schema>> inputs = generateSchema(generator, inputTypes); Map<String, Set<Schema>> outputs = generateSchema(generator, outputTypes); this.inputs = inputs; this.outputs = outputs; } }
public void toJson(FlowSpecification flowSpec, Appendable appendable) throws IOException { Preconditions.checkState(schemaGenerator != null, "No schema generator is configured. Fail to serialize to json"); try { for (FlowletDefinition flowletDef : flowSpec.getFlowlets().values()) { flowletDef.generateSchema(schemaGenerator); } gson.toJson(flowSpec, FlowSpecification.class, appendable); } catch (UnsupportedTypeException e) { throw new IOException(e); } }