From 02e943651a5f213f39e271758f7507cc1e4bf95a Mon Sep 17 00:00:00 2001 From: Alan Cai Date: Fri, 13 Dec 2024 15:08:28 -0800 Subject: [PATCH] [v1] Make AstNode equals and hashcode abstract; add missing impls (#1677) --- partiql-ast/api/partiql-ast.api | 8 ++++++++ partiql-ast/src/main/java/org/partiql/ast/AstNode.java | 6 ++++++ partiql-ast/src/main/java/org/partiql/ast/GroupBy.java | 1 + partiql-ast/src/main/java/org/partiql/ast/Let.java | 1 + 4 files changed, 16 insertions(+) diff --git a/partiql-ast/api/partiql-ast.api b/partiql-ast/api/partiql-ast.api index 96bd22662..b6c444f29 100644 --- a/partiql-ast/api/partiql-ast.api +++ b/partiql-ast/api/partiql-ast.api @@ -124,8 +124,10 @@ public abstract class org/partiql/ast/AstEnum : org/partiql/ast/AstNode { public abstract class org/partiql/ast/AstNode { public fun ()V public abstract fun accept (Lorg/partiql/ast/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun equals (Ljava/lang/Object;)Z public abstract fun getChildren ()Ljava/util/List; public fun getTag ()I + public abstract fun hashCode ()I public fun setTag (I)V } @@ -886,7 +888,10 @@ public class org/partiql/ast/GroupBy$Key : org/partiql/ast/AstNode { public fun (Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/Identifier;)V public fun accept (Lorg/partiql/ast/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object; public static fun builder ()Lorg/partiql/ast/GroupBy$Key$Builder; + protected fun canEqual (Ljava/lang/Object;)Z + public fun equals (Ljava/lang/Object;)Z public fun getChildren ()Ljava/util/List; + public fun hashCode ()I } public class org/partiql/ast/GroupBy$Key$Builder { @@ -1001,7 +1006,10 @@ public class org/partiql/ast/Let$Binding : org/partiql/ast/AstNode { public fun (Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/Identifier;)V public fun accept (Lorg/partiql/ast/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object; public static fun builder ()Lorg/partiql/ast/Let$Binding$Builder; + protected fun canEqual (Ljava/lang/Object;)Z + public fun equals (Ljava/lang/Object;)Z public fun getChildren ()Ljava/util/List; + public fun hashCode ()I } public class org/partiql/ast/Let$Binding$Builder { diff --git a/partiql-ast/src/main/java/org/partiql/ast/AstNode.java b/partiql-ast/src/main/java/org/partiql/ast/AstNode.java index d7a760686..21e8e175d 100644 --- a/partiql-ast/src/main/java/org/partiql/ast/AstNode.java +++ b/partiql-ast/src/main/java/org/partiql/ast/AstNode.java @@ -23,4 +23,10 @@ public void setTag(int tag) { public abstract List getChildren(); public abstract R accept(@NotNull AstVisitor visitor, C ctx); + + @Override + public abstract int hashCode(); + + @Override + public abstract boolean equals(Object obj); } diff --git a/partiql-ast/src/main/java/org/partiql/ast/GroupBy.java b/partiql-ast/src/main/java/org/partiql/ast/GroupBy.java index 31712019c..13f39c2f5 100644 --- a/partiql-ast/src/main/java/org/partiql/ast/GroupBy.java +++ b/partiql-ast/src/main/java/org/partiql/ast/GroupBy.java @@ -49,6 +49,7 @@ public R accept(@NotNull AstVisitor visitor, C ctx) { * TODO docs, equals, hashcode */ @lombok.Builder(builderClassName = "Builder") + @EqualsAndHashCode(callSuper = false) public static class Key extends AstNode { @NotNull public final Expr expr; diff --git a/partiql-ast/src/main/java/org/partiql/ast/Let.java b/partiql-ast/src/main/java/org/partiql/ast/Let.java index 19ad445a3..3182bf796 100644 --- a/partiql-ast/src/main/java/org/partiql/ast/Let.java +++ b/partiql-ast/src/main/java/org/partiql/ast/Let.java @@ -36,6 +36,7 @@ public R accept(@NotNull AstVisitor visitor, C ctx) { * TODO docs, equals, hashcode */ @lombok.Builder(builderClassName = "Builder") + @EqualsAndHashCode(callSuper = false) public static class Binding extends AstNode { @NotNull public final Expr expr;