sfc-gh-lkucharski commented on code in PR #10105:
URL: https://github.com/apache/nifi/pull/10105#discussion_r2251426433


##########
nifi-extension-bundles/nifi-confluent-platform-bundle/nifi-confluent-platform-api/src/main/java/org/apache/nifi/confluent/schema/ProtobufMessageSchema.java:
##########
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.confluent.schema;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+import java.util.Optional;
+
+/**
+ * Basic abstraction over Protobuf schema message entity.
+ * It contains only the fields that are needed for crude schema insights. It's 
useful when the
+ * message name resolver needs to pinpoint specific messages by message 
indexes encoded on the wire
+ * <p>
+ * 
https://docs.confluent.io/platform/current/schema-registry/fundamentals/serdes-develop/index.html#wire-format
+ * <p>
+ * It contains bare minimum of information for name resolver to be able to 
resolve message names
+ */
+public final class ProtobufMessageSchema {
+
+    private final String name;
+    private final Optional<String> packageName;
+    private final List<ProtobufMessageSchema> childMessageSchemas = new 
ArrayList<>();
+
+    public ProtobufMessageSchema(final String name, final Optional<String> 
packageName) {
+        this.name = name;
+        this.packageName = packageName;
+    }
+
+    public String name() {
+        return name;
+    }
+
+    public Optional<String> packageName() {
+        return packageName;
+    }
+
+    public boolean isDefaultPackage() {
+        return packageName.isEmpty();
+    }
+
+    public List<ProtobufMessageSchema> getChildMessageSchemas() {
+        return childMessageSchemas;
+    }
+
+    void addChildMessage(final ProtobufMessageSchema protobufMessageSchema) {
+        childMessageSchemas.add(protobufMessageSchema);
+    }

Review Comment:
   Since the ProtobufMessageSchema is part of the API, I'd stick with the 
regular class version. Just to be future-proof. IIRC, you can't declare a field 
in a record that is not part of the constructor, and mocking frameworks need 
some kind of non standard magic to support mocking of records, also I remember 
JACKSON needed special configuration for records but I don't know if this is 
still the case. 



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to