julianhyde commented on code in PR #3502: URL: https://github.com/apache/calcite/pull/3502#discussion_r1393223537
########## core/src/main/java/org/apache/calcite/rex/RexLambdaExpression.java: ########## @@ -0,0 +1,101 @@ +/* + * 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.calcite.rex; + +import org.apache.calcite.rel.type.RelDataType; +import org.apache.calcite.sql.SqlKind; + +import org.apache.commons.lang3.StringUtils; + +import org.checkerframework.checker.nullness.qual.Nullable; + +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * Represents a lambda expression. + */ +public class RexLambdaExpression extends RexNode { + //~ Instance fields -------------------------------------------------------- + + private final List<RexLambdaRef> parameters; + private final RexNode expression; + + //~ Constructors ----------------------------------------------------------- + + RexLambdaExpression(List<RexLambdaRef> parameters, RexNode expression) { + this.expression = expression; + this.parameters = parameters; + } + + //~ Methods ---------------------------------------------------------------- + + @Override public RelDataType getType() { + return expression.getType(); + } + + @Override public SqlKind getKind() { + return SqlKind.LAMBDA; + } + + @Override public <R> R accept(RexVisitor<R> visitor) { + return visitor.visitLambda(this); + } + + @Override public <R, P> R accept(RexBiVisitor<R, P> visitor, P arg) { + return visitor.visitLambda(this, arg); + } + + public RexNode getExpression() { + return expression; + } + + public List<RexLambdaRef> getParameters() { + return parameters; + } + + @Override public boolean equals(@Nullable Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RexLambdaExpression rexLambdaExpression = (RexLambdaExpression) o; + return Objects.equals(expression, rexLambdaExpression.expression) + && Objects.equals(parameters, rexLambdaExpression.parameters); + } + + @Override public int hashCode() { + return Objects.hash(expression, parameters); + } + + @Override public String toString() { Review Comment: why override `toString` rather than `computeDigest`? I think it would be clearer and more concise if you use a `for` loop rather than functional style. -- 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]
