wuchong commented on a change in pull request #11080: [FLINK-15988][json] Make
JsonRowSerializationSchema's constructor private
URL: https://github.com/apache/flink/pull/11080#discussion_r380085712
##########
File path:
flink-formats/flink-json/src/main/java/org/apache/flink/formats/json/JsonRowSerializationSchema.java
##########
@@ -99,35 +94,66 @@ public JsonRowSerializationSchema(TypeInformation<Row>
typeInfo) {
@PublicEvolving
public static class Builder {
- private final RowTypeInfo typeInfo;
+ private RowTypeInfo typeInfo;
+
+ private Builder() {
+ // private constructor
+ }
/**
+ * @deprecated Use {@link JsonRowSerializationSchema#builder()}
instead.
+ *
* Creates a JSON serialization schema for the given type
information.
*
* @param typeInfo Type information describing the result type.
The field names of {@link Row}
* are used to parse the JSON properties.
*/
+ @Deprecated
public Builder(TypeInformation<Row> typeInfo) {
checkArgument(typeInfo instanceof RowTypeInfo, "Only
RowTypeInfo is supported");
this.typeInfo = (RowTypeInfo) typeInfo;
}
/**
+ * @deprecated Use {@link JsonRowSerializationSchema#builder()}
instead.
+ *
* Creates a JSON serialization schema for the given JSON
schema.
*
* @param jsonSchema JSON schema describing the result type
*
* @see <a
href="http://json-schema.org/">http://json-schema.org/</a>
*/
+ @Deprecated
public Builder(String jsonSchema) {
this(JsonRowSchemaConverter.convert(checkNotNull(jsonSchema)));
}
+ /**
+ * Sets type information for JSON serialization schema.
+ *
+ * @param typeInfo Type information describing the result type.
The field names of {@link Row}
+ * are used to parse the JSON properties.
+ */
+ public Builder withTypeInfo(TypeInformation<Row> typeInfo) {
+ checkArgument(typeInfo instanceof RowTypeInfo, "Only
RowTypeInfo is supported");
+ this.typeInfo = (RowTypeInfo) typeInfo;
+ return this;
+ }
+
+ /**
+ * Finalizes the configuration and checks validity.
+ * @return Configured {@link JsonRowSerializationSchema}
+ */
public JsonRowSerializationSchema build() {
+ checkArgument(typeInfo != null, "typeInfo should be
set.");
return new JsonRowSerializationSchema(typeInfo);
}
}
+ public static Builder builder() {
Review comment:
Add a javadoc on this method.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services