Cole-Greer commented on code in PR #3214: URL: https://github.com/apache/tinkerpop/pull/3214#discussion_r2377339854
########## gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/RangeLocalStepPlaceholder.java: ########## @@ -0,0 +1,151 @@ +/* + * 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.step.filter; + +import org.apache.tinkerpop.gremlin.process.traversal.Traversal; +import org.apache.tinkerpop.gremlin.process.traversal.Traverser; +import org.apache.tinkerpop.gremlin.process.traversal.step.GValue; +import org.apache.tinkerpop.gremlin.process.traversal.step.GValueHolder; +import org.apache.tinkerpop.gremlin.process.traversal.step.map.RangeLocalStep; +import org.apache.tinkerpop.gremlin.process.traversal.step.map.ScalarMapStep; +import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Objects; +import java.util.Set; + +public class RangeLocalStepPlaceholder<S> extends ScalarMapStep<S,S> implements RangeLocalStepContract<S>, GValueHolder<S, S> { + + protected GValue<Long> low; + protected GValue<Long> high; + + public RangeLocalStepPlaceholder(final Traversal.Admin traversal, final GValue<Long> low, final GValue<Long> high) { + super(traversal); + this.low = low; + this.high = high; + traversal.getGValueManager().register(low); + traversal.getGValueManager().register(high); + } + + @Override + public boolean isParameterized() { + return low.isVariable() || high.isVariable(); + } + + @Override + public void updateVariable(String name, Object value) { + if (name.equals(low.getName())) { Review Comment: It's ok if `low = GValue.of(null, 1)` as this works out to `name.equals(null)` which is just false. We could get NPEs if any of `name`, `low`, or `high` were null. Those all fall into the category of things which should never happen. I will add explicit checks to block nulls and throw IllegalArgumentExceptions if someone ever tries to pass a null to this class. The concrete RangeLocalStep stores primitive `long` values here, and the placeholders really shouldn't need to figure out how to properly map a null to a primitive argument. As for `name` being null, I'm leaning towards ignoring it. There's no reason a user should ever call `updateVariable()` with a null name, and I think it's fine to just let that surface as an NPE to them. -- 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: commits-unsubscr...@tinkerpop.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org