dawidwys commented on a change in pull request #11646: [FLINK-16988][table] Add 
core table source/sink interfaces
URL: https://github.com/apache/flink/pull/11646#discussion_r404619586
 
 

 ##########
 File path: 
flink-table/flink-table-common/src/main/java/org/apache/flink/table/connector/ChangelogMode.java
 ##########
 @@ -0,0 +1,116 @@
+/*
+ * 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.flink.table.connector;
+
+import org.apache.flink.annotation.PublicEvolving;
+import org.apache.flink.types.RowKind;
+import org.apache.flink.util.Preconditions;
+
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.Objects;
+import java.util.Set;
+
+/**
+ * The set of changes contained in a changelog.
+ *
+ * @see RowKind
+ */
+@PublicEvolving
+public final class ChangelogMode {
+
+       private static final ChangelogMode INSERT_ONLY = 
ChangelogMode.newBuilder()
+               .addContainedKind(RowKind.INSERT)
+               .build();
+
+       private final Set<RowKind> kinds;
+
+       private ChangelogMode(Set<RowKind> kinds) {
+               Preconditions.checkArgument(
+                       kinds.size() > 0,
+                       "At least one kind of row should be contained in a 
changelog.");
+               this.kinds = Collections.unmodifiableSet(kinds);
+       }
+
+       /**
+        * Shortcut for a simple {@link RowKind#INSERT}-only changelog.
+        */
+       public static ChangelogMode insertOnly() {
+               return INSERT_ONLY;
+       }
+
+       /**
+        * Builder for configuring and creating instances of {@link 
ChangelogMode}.
+        */
+       public static Builder newBuilder() {
+               return new Builder();
+       }
+
+       public Set<RowKind> getContainedKinds() {
+               return kinds;
+       }
+
+       public boolean contains(RowKind kind) {
+               return kinds.contains(kind);
+       }
+
+       public boolean containsOnly(RowKind kind) {
+               return kinds.size() == 1 && kinds.contains(kind);
+       }
+
+       @Override
+       public boolean equals(Object o) {
+               if (this == o) {
+                       return true;
+               }
+               if (o == null || getClass() != o.getClass()) {
+                       return false;
+               }
+               ChangelogMode that = (ChangelogMode) o;
+               return kinds.equals(that.kinds);
+       }
+
+       @Override
+       public int hashCode() {
+               return Objects.hash(kinds);
+       }
+
+       // 
--------------------------------------------------------------------------------------------
+
+       /**
+        * Builder for configuring and creating instances of {@link 
ChangelogMode}.
+        */
+       public static class Builder {
+
+               private final Set<RowKind> kinds = 
EnumSet.noneOf(RowKind.class);
+
+               public Builder() {
 
 Review comment:
   nit: Could it be private?

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

Reply via email to