merlimat commented on a change in pull request #3752: revise the schema default 
type not null
URL: https://github.com/apache/pulsar/pull/3752#discussion_r263035591
 
 

 ##########
 File path: 
pulsar-client-api/src/main/java/org/apache/pulsar/client/api/Schema.java
 ##########
 @@ -167,49 +167,95 @@ default T decode(byte[] bytes, byte[] schemaVersion) {
     }
 
     /**
-     * Create a Avro schema type by extracting the fields of the specified 
class.
+     * Create a allow null Avro schema type by extracting the fields of the 
specified class.
      *
      * @param clazz the POJO class to be used to extract the Avro schema
      * @return a Schema instance
      */
     static <T> Schema<T> AVRO(Class<T> clazz) {
-        return DefaultImplementation.newAvroSchema(clazz);
+        return DefaultImplementation.newAvroSchema(clazz, true);
     }
 
     /**
-     * Create a JSON schema type by extracting the fields of the specified 
class.
+     * Create a Avro schema type by extracting the fields of the specified 
class.
+     *
+     * @param clazz the POJO class to be used to extract the Avro schema
+     *              allowNull the create a allow null or not null Avro schema
+     * @return a Schema instance
+     */
+    static <T> Schema<T> AVRO(Class<T> clazz, Boolean allowNull) {
+        return DefaultImplementation.newAvroSchema(clazz, allowNull);
+    }
+
+
+    /**
+     * Create a allow null JSON schema type by extracting the fields of the 
specified class.
      *
      * @param clazz the POJO class to be used to extract the JSON schema
      * @return a Schema instance
      */
     static <T> Schema<T> JSON(Class<T> clazz) {
-        return DefaultImplementation.newJSONSchema(clazz);
+        return DefaultImplementation.newJSONSchema(clazz, true);
+    }
+
+    /**
+     * Create a allow null JSON schema type by extracting the fields of the 
specified class.
+     *
+     * @param clazz the POJO class to be used to extract the JSON schema
+     *              allowNull the create a allow null or not null JSON schema
+     * @return a Schema instance
+     */
+    static <T> Schema<T> JSON(Class<T> clazz, Boolean allowNull) {
+        return DefaultImplementation.newJSONSchema(clazz, allowNull);
     }
 
+
     /**
      * Key Value Schema using passed in schema type, support JSON and AVRO 
currently.
      */
     static <K, V> Schema<KeyValue<K, V>> KeyValue(Class<K> key, Class<V> 
value, SchemaType type) {
-        return DefaultImplementation.newKeyValueSchema(key, value, type);
+        return DefaultImplementation.newKeyValueSchema(key, value, type, true);
     }
 
+    /**
+     * Key Value Schema using passed in schema type, support JSON and AVRO 
currently.
+     */
+    static <K, V> Schema<KeyValue<K, V>> KeyValue(Class<K> key, Class<V> 
value, SchemaType type, Boolean allowNull) {
 
 Review comment:
   This becomes even more confusing, because `allowNull` here would be applied 
to, say, a protobuf schema for which it will not make sense.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to