Skip to content

Commit

Permalink
[v1] Change public fields to Lombok getters; make concrete classes fi…
Browse files Browse the repository at this point in the history
…nal (#1685)

* [v1] Change public fields to Lombok getters; make concrete classes final

* [v1] Remove top-level DDL node (#1693)
  • Loading branch information
alancai98 authored Dec 27, 2024
1 parent 1abe677 commit 71e9ee3
Show file tree
Hide file tree
Showing 105 changed files with 1,050 additions and 806 deletions.
709 changes: 314 additions & 395 deletions partiql-ast/api/partiql-ast.api

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions partiql-ast/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
plugins {
id(Plugins.conventions)
id(Plugins.publish)
// Need the Kotlin lombok plugin to allow for Kotlin code in partiql-ast to understand Java Lombok annotations.
// https://kotlinlang.org/docs/lombok.html
id(Plugins.kotlinLombok) version Versions.kotlinLombok
}

dependencies {
Expand Down
5 changes: 0 additions & 5 deletions partiql-ast/src/main/java/org/partiql/ast/AstVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import org.partiql.ast.ddl.AttributeConstraint;
import org.partiql.ast.ddl.ColumnDefinition;
import org.partiql.ast.ddl.CreateTable;
import org.partiql.ast.ddl.Ddl;
import org.partiql.ast.ddl.KeyValue;
import org.partiql.ast.ddl.PartitionBy;
import org.partiql.ast.ddl.TableConstraint;
Expand Down Expand Up @@ -88,10 +87,6 @@ public R visitStatement(Statement node, C ctx) {
//
// DDL
//
public R visitDdl(Ddl node, C ctx) {
return defaultVisit(node, ctx);
}

public R visitCreateTable(CreateTable node, C ctx) {
return defaultVisit(node, ctx);
}
Expand Down
24 changes: 16 additions & 8 deletions partiql-ast/src/main/java/org/partiql/ast/DataType.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.partiql.ast;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.partiql.ast.ddl.AttributeConstraint;
Expand All @@ -9,7 +10,7 @@
import java.util.List;

@EqualsAndHashCode(callSuper = false)
public class DataType extends AstEnum {
public final class DataType extends AstEnum {
/**
* A field definition with in a Struct Type Definition
*/
Expand All @@ -28,26 +29,33 @@ public class DataType extends AstEnum {
@EqualsAndHashCode(callSuper = false)
public static class StructField extends AstNode {
@NotNull
public final Identifier name;
@Getter
private final Identifier name;

@NotNull
public final DataType type;
@Getter
private final DataType type;

public final boolean isOptional;
@Getter
private final boolean optional;

@Nullable
public final List<AttributeConstraint> constraints;
@Getter
private final List<AttributeConstraint> constraints;

@Nullable
public final String comment;
@Getter
private final String comment;

public StructField(
@NotNull Identifier name,
@NotNull DataType type,
boolean isOptional,
boolean optional,
@Nullable List<AttributeConstraint> constraints,
@Nullable String comment) {
this.name = name;
this.type = type;
this.isOptional = isOptional;
this.optional = optional;
this.constraints = constraints;
this.comment = comment;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* TODO docs, equals, hashcode
*/
@EqualsAndHashCode(callSuper = false)
public class DatetimeField extends AstEnum {
public final class DatetimeField extends AstEnum {
public static final int YEAR = 0;
public static final int MONTH = 1;
public static final int DAY = 2;
Expand Down
6 changes: 4 additions & 2 deletions partiql-ast/src/main/java/org/partiql/ast/Exclude.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
Expand All @@ -12,9 +13,10 @@
*/
@Builder(builderClassName = "Builder")
@EqualsAndHashCode(callSuper = false)
public class Exclude extends AstNode {
public final class Exclude extends AstNode {
@NotNull
public final List<ExcludePath> excludePaths;
@Getter
private final List<ExcludePath> excludePaths;

public Exclude(@NotNull List<ExcludePath> excludePaths) {
this.excludePaths = excludePaths;
Expand Down
9 changes: 6 additions & 3 deletions partiql-ast/src/main/java/org/partiql/ast/ExcludePath.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import org.jetbrains.annotations.NotNull;
import org.partiql.ast.expr.ExprVarRef;

Expand All @@ -13,12 +14,14 @@
*/
@Builder(builderClassName = "Builder")
@EqualsAndHashCode(callSuper = false)
public class ExcludePath extends AstNode {
public final class ExcludePath extends AstNode {
@NotNull
public final ExprVarRef root;
@Getter
private final ExprVarRef root;

@NotNull
public final List<ExcludeStep> excludeSteps;
@Getter
private final List<ExcludeStep> excludeSteps;

public ExcludePath(@NotNull ExprVarRef root, @NotNull List<ExcludeStep> excludeSteps) {
this.root = root;
Expand Down
7 changes: 5 additions & 2 deletions partiql-ast/src/main/java/org/partiql/ast/ExcludeStep.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
Expand All @@ -18,7 +19,8 @@ public abstract class ExcludeStep extends AstNode {
@EqualsAndHashCode(callSuper = false)
public static class StructField extends ExcludeStep {
@NotNull
public final Identifier symbol;
@Getter
private final Identifier symbol;

public StructField(@NotNull Identifier symbol) {
this.symbol = symbol;
Expand All @@ -44,7 +46,8 @@ public <R, C> R accept(@NotNull AstVisitor<R, C> visitor, C ctx) {
@Builder(builderClassName = "Builder")
@EqualsAndHashCode(callSuper = false)
public static class CollIndex extends ExcludeStep {
public final int index;
@Getter
private final int index;

public CollIndex(int index) {
this.index = index;
Expand Down
9 changes: 6 additions & 3 deletions partiql-ast/src/main/java/org/partiql/ast/Explain.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
Expand All @@ -13,12 +14,14 @@
*/
@Builder(builderClassName = "Builder")
@EqualsAndHashCode(callSuper = false)
public class Explain extends Statement {
public final class Explain extends Statement {
@NotNull
public final Map<String, Literal> options;
@Getter
private final Map<String, Literal> options;

@NotNull
public final Statement statement;
@Getter
private final Statement statement;

public Explain(@NotNull Map<String, Literal> options, @NotNull Statement statement) {
this.options = options;
Expand Down
6 changes: 4 additions & 2 deletions partiql-ast/src/main/java/org/partiql/ast/From.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
Expand All @@ -12,9 +13,10 @@
*/
@Builder(builderClassName = "Builder")
@EqualsAndHashCode(callSuper = false)
public class From extends AstNode {
public final class From extends AstNode {
@NotNull
public final List<FromTableRef> tableRefs;
@Getter
private final List<FromTableRef> tableRefs;

public From(@NotNull List<FromTableRef> tableRefs) {
this.tableRefs = tableRefs;
Expand Down
15 changes: 10 additions & 5 deletions partiql-ast/src/main/java/org/partiql/ast/FromExpr.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.partiql.ast.expr.Expr;
Expand All @@ -14,18 +15,22 @@
*/
@Builder(builderClassName = "Builder")
@EqualsAndHashCode(callSuper = false)
public class FromExpr extends FromTableRef {
public final class FromExpr extends FromTableRef {
@NotNull
public final Expr expr;
@Getter
private final Expr expr;

@NotNull
public final FromType fromType;
@Getter
private final FromType fromType;

@Nullable
public final Identifier asAlias;
@Getter
private final Identifier asAlias;

@Nullable
public final Identifier atAlias;
@Getter
private final Identifier atAlias;

public FromExpr(@NotNull Expr expr, @NotNull FromType fromType, @Nullable Identifier asAlias,
@Nullable Identifier atAlias) {
Expand Down
15 changes: 10 additions & 5 deletions partiql-ast/src/main/java/org/partiql/ast/FromJoin.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.partiql.ast.expr.Expr;
Expand All @@ -14,18 +15,22 @@
*/
@Builder(builderClassName = "Builder")
@EqualsAndHashCode(callSuper = false)
public class FromJoin extends FromTableRef {
public final class FromJoin extends FromTableRef {
@NotNull
public final FromTableRef lhs;
@Getter
private final FromTableRef lhs;

@NotNull
public final FromTableRef rhs;
@Getter
private final FromTableRef rhs;

@Nullable
public final JoinType joinType;
@Getter
private final JoinType joinType;

@Nullable
public final Expr condition;
@Getter
private final Expr condition;

public FromJoin(@NotNull FromTableRef lhs, @NotNull FromTableRef rhs, @Nullable JoinType joinType, @Nullable Expr condition) {
this.lhs = lhs;
Expand Down
2 changes: 1 addition & 1 deletion partiql-ast/src/main/java/org/partiql/ast/FromType.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* TODO docs, equals, hashcode
*/
@EqualsAndHashCode(callSuper = false)
public class FromType extends AstEnum {
public final class FromType extends AstEnum {
public static final int SCAN = 0;
public static final int UNPIVOT = 1;

Expand Down
18 changes: 12 additions & 6 deletions partiql-ast/src/main/java/org/partiql/ast/GroupBy.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.partiql.ast.expr.Expr;
Expand All @@ -14,15 +15,18 @@
*/
@Builder(builderClassName = "Builder")
@EqualsAndHashCode(callSuper = false)
public class GroupBy extends AstNode {
public final class GroupBy extends AstNode {
@NotNull
public final GroupByStrategy strategy;
@Getter
private final GroupByStrategy strategy;

@NotNull
public final List<Key> keys;
@Getter
private final List<Key> keys;

@Nullable
public final Identifier asAlias;
@Getter
private final Identifier asAlias;

public GroupBy(@NotNull GroupByStrategy strategy, @NotNull List<Key> keys, @Nullable Identifier asAlias) {
this.strategy = strategy;
Expand Down Expand Up @@ -52,10 +56,12 @@ public <R, C> R accept(@NotNull AstVisitor<R, C> visitor, C ctx) {
@EqualsAndHashCode(callSuper = false)
public static class Key extends AstNode {
@NotNull
public final Expr expr;
@Getter
private final Expr expr;

@Nullable
public final Identifier asAlias;
@Getter
private final Identifier asAlias;

public Key(@NotNull Expr expr, @Nullable Identifier asAlias) {
this.expr = expr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* TODO docs, equals, hashcode
*/
@EqualsAndHashCode(callSuper = false)
public class GroupByStrategy extends AstEnum {
public final class GroupByStrategy extends AstEnum {
public static final int FULL = 0;
public static final int PARTIAL = 1;

Expand Down
13 changes: 8 additions & 5 deletions partiql-ast/src/main/java/org/partiql/ast/Identifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
Expand All @@ -12,15 +13,17 @@
*/
@Builder(builderClassName = "Builder")
@EqualsAndHashCode(callSuper = false)
public class Identifier extends AstNode {
public final class Identifier extends AstNode {
@NotNull
public final String symbol;
@Getter
private final String symbol;

public final boolean isDelimited;
@Getter
private final boolean delimited;

public Identifier(@NotNull String symbol, boolean isDelimited) {
public Identifier(@NotNull String symbol, boolean delimited) {
this.symbol = symbol;
this.isDelimited = isDelimited;
this.delimited = delimited;
}

@NotNull
Expand Down
Loading

0 comments on commit 71e9ee3

Please sign in to comment.