[ 
https://issues.apache.org/jira/browse/TINKERPOP-3173?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18018474#comment-18018474
 ] 

ASF GitHub Bot commented on TINKERPOP-3173:
-------------------------------------------

kenhuuu commented on code in PR #3195:
URL: https://github.com/apache/tinkerpop/pull/3195#discussion_r2325950257


##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/NotP.java:
##########
@@ -0,0 +1,110 @@
+/*
+ * 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.tinkerpop.gremlin.process.traversal;
+
+import java.io.Serializable;
+import java.util.Objects;
+
+public class NotP<V> extends P<V> {
+    private P<V> originalP;
+    public NotP(final P<V> p) {
+        super(null, (V) null);
+
+        if (null == p) {
+            throw new IllegalArgumentException("Cannot negate a null P");
+        }
+        this.originalP = p;
+        this.biPredicate = new NotPBiPredicate<>(p.getBiPredicate());
+    }
+
+    /**
+     * Gets the current value to be passed to the predicate for testing.
+     */
+    @Override
+    public V getValue() {
+        return originalP.getValue();
+    }
+
+    @Override
+    public void setValue(final V value) {
+        super.setValue(value);
+        if (originalP != null) {
+            originalP.setValue(value);
+        }
+    }
+
+    @Override
+    public String toString() {
+        return null == this.getValue() ? this.biPredicate.toString() : 
String.format("not(%s(%s))", this.originalP.biPredicate.toString(), 
this.getValue());
+    }
+
+    @Override
+    public P<V> negate() {
+        return originalP;
+    }
+
+    public P<V> clone() {
+        return new NotP<>(this.originalP.clone());
+    }
+
+    public static class NotPBiPredicate<T, U> implements PBiPredicate<T, U>, 
Serializable {
+        PBiPredicate<T, U> original;

Review Comment:
   Nit: final





> Simplify Comparability Semantics
> --------------------------------
>
>                 Key: TINKERPOP-3173
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-3173
>             Project: TinkerPop
>          Issue Type: Improvement
>          Components: process
>    Affects Versions: 3.7.3
>            Reporter: Cole Greer
>            Priority: Major
>
> As recently discussed on the 
> [devlist|https://lists.apache.org/thread/hsqw2tvc72dw4z40nnbbdmygrqx43syr], 
> our current system of ternary boolean logic should be simplified to binary 
> boolean logic where invalid comparisons simply return false.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to