You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wayang.apache.org by be...@apache.org on 2022/05/23 13:20:11 UTC
[incubator-wayang] 22/38: [WAYANG-28] add basic implementation on Sniff
This is an automated email from the ASF dual-hosted git repository.
bertty pushed a commit to branch WAYANG-28-update
in repository https://gitbox.apache.org/repos/asf/incubator-wayang.git
commit 6731ebb51e558326d077c2dfa6bafbe5f67bc54c
Author: Bertty Contreras-Rojas <be...@scalytics.io>
AuthorDate: Tue Apr 6 13:28:37 2021 -0400
[WAYANG-28] add basic implementation on Sniff
---
.../core/sniffer/sniff/CollectionTagsToSniff.java | 46 ++++++++++++++++++++++
.../core/sniffer/sniff/SingleTagToSniff.java | 42 ++++++++++++++++++++
2 files changed, 88 insertions(+)
diff --git a/wayang-plugins/wayang-hackit/wayang-hackit-core/src/main/java/org/apache/wayang/plugin/hackit/core/sniffer/sniff/CollectionTagsToSniff.java b/wayang-plugins/wayang-hackit/wayang-hackit-core/src/main/java/org/apache/wayang/plugin/hackit/core/sniffer/sniff/CollectionTagsToSniff.java
new file mode 100644
index 00000000..a2811b0d
--- /dev/null
+++ b/wayang-plugins/wayang-hackit/wayang-hackit-core/src/main/java/org/apache/wayang/plugin/hackit/core/sniffer/sniff/CollectionTagsToSniff.java
@@ -0,0 +1,46 @@
+/*
+ * 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.wayang.plugin.hackit.core.sniffer.sniff;
+
+import org.apache.wayang.plugin.hackit.core.tags.HackitTag;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class CollectionTagsToSniff implements Sniff {
+
+ public Set<HackitTag> tags2sniff;
+
+ public CollectionTagsToSniff(){
+ this.tags2sniff = new HashSet<>();
+ }
+
+ public boolean sniff(HackitTag tag){
+ return this.tags2sniff.contains(tag);
+ }
+
+ public void addTag2sniff(HackitTag tag) {
+ this.tags2sniff.add(tag);
+ }
+
+ @Override
+ public boolean sniff(Object input) {
+ return false;
+ }
+}
diff --git a/wayang-plugins/wayang-hackit/wayang-hackit-core/src/main/java/org/apache/wayang/plugin/hackit/core/sniffer/sniff/SingleTagToSniff.java b/wayang-plugins/wayang-hackit/wayang-hackit-core/src/main/java/org/apache/wayang/plugin/hackit/core/sniffer/sniff/SingleTagToSniff.java
new file mode 100644
index 00000000..9ce8eded
--- /dev/null
+++ b/wayang-plugins/wayang-hackit/wayang-hackit-core/src/main/java/org/apache/wayang/plugin/hackit/core/sniffer/sniff/SingleTagToSniff.java
@@ -0,0 +1,42 @@
+/*
+ * 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.wayang.plugin.hackit.core.sniffer.sniff;
+
+import org.apache.wayang.plugin.hackit.core.tags.HackitTag;
+
+public class SingleTagToSniff implements Sniff {
+
+ public HackitTag tags2sniff;
+
+ public boolean sniff(HackitTag tag){
+ return this.tags2sniff.equals(tag);
+ }
+
+ public void addTag2sniff(HackitTag tag) {
+ if(this.tags2sniff != null){
+ throw new RuntimeException("The SingleTagToSniff already got the tag, if you need more of one tag use CollectionTagsToSniff class");
+ }
+ this.tags2sniff = tag;
+ }
+
+ @Override
+ public boolean sniff(Object input) {
+ return false;
+ }
+}