korlov42 commented on code in PR #2811:
URL: https://github.com/apache/ignite-3/pull/2811#discussion_r1387845646


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/property/SqlPropertiesHelper.java:
##########
@@ -0,0 +1,155 @@
+/*
+ * 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.ignite.internal.sql.engine.property;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import org.apache.ignite.internal.sql.engine.property.SqlProperties.Builder;
+import org.apache.ignite.internal.util.CollectionUtils;
+import org.apache.ignite.internal.util.FilteringIterator;
+import org.apache.ignite.internal.util.IgniteUtils;
+
+/**
+ * Utility class to work with {@link Property}.
+ */
+public final class SqlPropertiesHelper {
+    private SqlPropertiesHelper() {
+        throw new IllegalStateException();
+    }
+
+    /** Creates empty properties object. */
+    public static SqlProperties emptyProperties() {
+        return new SqlPropertiesImpl(Map.of());
+    }
+
+    /** Creates new builder. */
+    public static Builder newBuilder() {
+        return new BuilderImpl();
+    }
+
+    /**
+     * Merges two properties objects into single one.
+     *
+     * <p>If conflict arises, conflicted values of secondary object will be 
overridden with values
+     * of primary object.
+     *
+     * @param primary A properties whose values will be preserved.
+     * @param secondary A properties whose values will be overridden in case 
of conflict.
+     * @return A properties object containing properties from both objects.
+     */
+    public static SqlProperties merge(SqlProperties primary, SqlProperties 
secondary) {
+        Builder builder = builderFromProperties(secondary);
+
+        for (Map.Entry<Property<?>, Object> entry : primary) {
+            builder.set((Property<Object>) entry.getKey(), entry.getValue());
+        }
+
+        return builder.build();
+    }
+
+    /**
+     * Creates a chained properties object. That is, on every access to the 
property it will look up
+     * certain property in the primary object, and then, if property was not 
found, in secondary.
+     *
+     * @param primary A primary object.
+     * @param secondary A secondary object.
+     * @return A chained properties object.
+     */
+    public static SqlProperties chain(SqlProperties primary, SqlProperties 
secondary) {

Review Comment:
   tests have been added



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