lkuchars commented on code in PR #10105:
URL: https://github.com/apache/nifi/pull/10105#discussion_r2276438315


##########
nifi-extension-bundles/nifi-standard-services/nifi-schema-registry-service-api/src/main/java/org/apache/nifi/schemaregistry/services/StandardSchemaDefinition.java:
##########
@@ -0,0 +1,111 @@
+/*
+ * 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.schemaregistry.services;
+
+import org.apache.nifi.serialization.record.SchemaIdentifier;
+
+import java.util.Map;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * Simple implementation of SchemaDefinition that holds a schema identifier, 
text, and references.
+ */
+public class StandardSchemaDefinition implements SchemaDefinition {
+
+    private final SchemaIdentifier identifier;
+    private final String text;
+    private final Map<String, SchemaDefinition> references;
+    private final SchemaType schemaType;
+
+    /**
+     * Creates a new StandardSchemaDefinition.
+     *
+     * @param identifier the schema identifier
+     * @param text       the schema text content
+     * @param references map of schema references (key = reference name, value 
= referenced schema)
+     */
+    public StandardSchemaDefinition(final SchemaIdentifier identifier,
+                                    final String text,
+                                    final SchemaType schemaType,
+                                    final Map<String, SchemaDefinition> 
references
+
+    ) {
+        this.identifier = requireNonNull(identifier, "Schema identifier cannot 
be null");
+        this.text = requireNonNull(text, "Schema text cannot be null");
+        this.schemaType = requireNonNull(schemaType, "Schema type cannot be 
null");
+        this.references = references != null ? Map.copyOf(references) : 
Map.of();
+    }
+
+    /**
+     * Creates a new StandardSchemaDefinition without references.
+     *
+     * @param identifier the schema identifier
+     * @param text       the schema text content
+     */
+    public StandardSchemaDefinition(final SchemaIdentifier identifier, final 
String text, final SchemaType schemaType) {
+        this(identifier, text, schemaType, null);
+    }
+
+    @Override
+    public SchemaType getSchemaType() {
+        return schemaType;
+    }
+
+    @Override
+    public SchemaIdentifier getIdentifier() {
+        return identifier;
+    }
+
+    @Override
+    public String getText() {
+        return text;
+    }
+
+    @Override
+    public Map<String, SchemaDefinition> getReferences() {
+        return references;
+    }
+
+    @Override
+    public final boolean equals(final Object o) {
+        if (!(o instanceof final StandardSchemaDefinition that)) {
+            return false;
+        }
+
+        return identifier.equals(that.identifier) && text.equals(that.text) && 
references.equals(that.references) && schemaType == that.schemaType;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = identifier.hashCode();
+        result = 31 * result + text.hashCode();
+        result = 31 * result + references.hashCode();
+        result = 31 * result + schemaType.hashCode();
+        return result;
+    }
+
+    @Override
+    public String toString() {
+        return "StandardSchemaDefinition{" +
+            "identifier=" + identifier +
+            ", text='" + text + '\'' +

Review Comment:
   Done



##########
nifi-extension-bundles/nifi-standard-services/nifi-schema-registry-service-api/src/main/java/org/apache/nifi/schemaregistry/services/StandardMessageName.java:
##########
@@ -0,0 +1,65 @@
+/*
+ * 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.schemaregistry.services;
+
+import java.util.Objects;
+import java.util.Optional;
+
+public class StandardMessageName implements MessageName {
+
+    private final Optional<String> namespace;
+    private final String name;
+
+    public StandardMessageName(final Optional<String> namespace, final String 
name) {
+        this.name = Objects.requireNonNull(name, "name must not be null");
+        this.namespace = namespace;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public Optional<String> getNamespace() {
+        return namespace;
+    }
+
+    @Override
+    public final boolean equals(final Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (!(o instanceof final StandardMessageName that)) {
+            return false;
+        }
+
+        return name.equals(that.name) && namespace.equals(that.namespace);
+    }
+
+    @Override
+    public int hashCode() {
+        int result = name.hashCode();
+        result = 31 * result + namespace.hashCode();
+        return result;
+    }
+
+    @Override
+    public String toString() {
+        return String.format("StandardMessageName{name='%s', namespace=%s}", 
name, namespace);

Review Comment:
   Done



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