Skip to content

Commit

Permalink
Add Lombok Builders to classes; make every field final
Browse files Browse the repository at this point in the history
  • Loading branch information
alancai98 committed Oct 16, 2024
1 parent 9cfbc51 commit 9b3f074
Show file tree
Hide file tree
Showing 62 changed files with 1,113 additions and 331 deletions.
4 changes: 4 additions & 0 deletions buildSrc/src/main/kotlin/partiql.versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ object Versions {
const val kotlinxCollections = "0.3.5"
const val picoCli = "4.7.0"
const val kasechange = "1.3.0"
const val kotlinLombok = "1.9.20"
const val kotlinxCoroutines = "1.8.1"
const val kotlinxCoroutinesJdk8 = "1.8.1"
const val ktlint = "0.42.1" // we're on an old version of ktlint. TODO upgrade https://github.com/partiql/partiql-lang-kotlin/issues/1418
const val lombok = "1.18.34"

// Testing
const val assertj = "3.11.0"
Expand Down Expand Up @@ -80,6 +82,7 @@ object Deps {
const val kotlinxCoroutines = "org.jetbrains.kotlinx:kotlinx-coroutines-core:${Versions.kotlinxCoroutines}"
const val kotlinxCoroutinesJdk8 = "org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:${Versions.kotlinxCoroutinesJdk8}"
const val ktlint = "com.pinterest.ktlint:ktlint-core:${Versions.ktlint}"
const val lombok = "org.projectlombok:lombok:${Versions.lombok}"

// Testing
const val assertj = "org.assertj:assertj-core:${Versions.assertj}"
Expand Down Expand Up @@ -107,5 +110,6 @@ object Plugins {
const val detekt = "io.gitlab.arturbosch.detekt"
const val dokka = "org.jetbrains.dokka"
const val library = "org.gradle.java-library"
const val kotlinLombok = "org.jetbrains.kotlin.plugin.lombok"
const val testFixtures = "org.gradle.java-test-fixtures"
}
967 changes: 800 additions & 167 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,7 @@
plugins {
id(Plugins.conventions)
id(Plugins.publish)
id(Plugins.kotlinLombok) version Versions.kotlinLombok
}

dependencies {
Expand All @@ -24,6 +25,8 @@ dependencies {
// TODO REMOVE ME ONCE PartiQLValue IS REMOVED
// THE AST NEEDS ITS OWN "VALUE" REPRESENTATION
api(project(":partiql-spi"))
compileOnly(Deps.lombok)
annotationProcessor(Deps.lombok)
}

tasks.shadowJar {
Expand Down
4 changes: 3 additions & 1 deletion partiql-ast/src/main/java/org/partiql/ast/v1/Exclude.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.partiql.ast.v1;

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

import java.util.ArrayList;
Expand All @@ -9,9 +10,10 @@
/**
* TODO docs, equals, hashcode
*/
@Builder
public class Exclude extends AstNode {
@NotNull
public List<ExcludePath> excludePaths;
public final List<ExcludePath> excludePaths;

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

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

Expand All @@ -10,12 +11,13 @@
/**
* TODO docs, equals, hashcode
*/
@Builder
public class ExcludePath extends AstNode {
@NotNull
public ExprVarRef root;
public final ExprVarRef root;

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

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

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

import java.util.ArrayList;
Expand All @@ -13,9 +14,10 @@ public abstract class ExcludeStep extends AstNode {
/**
* TODO docs, equals, hashcode
*/
@Builder
public static class StructField extends ExcludeStep {
@NotNull
public Identifier symbol;
public final Identifier symbol;

public StructField(@NotNull Identifier symbol) {
this.symbol = symbol;
Expand All @@ -38,8 +40,9 @@ public <R, C> R accept(@NotNull AstVisitor<R, C> visitor, C ctx) {
/**
* TODO docs, equals, hashcode
*/
@Builder
public static class CollIndex extends ExcludeStep {
public int index;
public final int index;

public CollIndex(int index) {
this.index = index;
Expand All @@ -60,6 +63,7 @@ public <R, C> R accept(@NotNull AstVisitor<R, C> visitor, C ctx) {
/**
* TODO docs, equals, hashcode
*/
@Builder
public static class StructWildcard extends ExcludeStep {
@NotNull
@Override
Expand All @@ -76,6 +80,7 @@ public <R, C> R accept(@NotNull AstVisitor<R, C> visitor, C ctx) {
/**
* TODO docs, equals, hashcode
*/
@Builder
public static class CollWildcard extends ExcludeStep {
@NotNull
@Override
Expand Down
6 changes: 4 additions & 2 deletions partiql-ast/src/main/java/org/partiql/ast/v1/Explain.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.partiql.ast.v1;

import lombok.Builder;
import org.jetbrains.annotations.NotNull;
import org.partiql.value.PartiQLValue;

Expand All @@ -11,13 +12,14 @@
/**
* TODO docs, equals, hashcode
*/
@Builder
public class Explain extends Statement {
// TODO get rid of PartiQLValue once https://github.com/partiql/partiql-lang-kotlin/issues/1589 is resolved
@NotNull
public Map<String, PartiQLValue> options;
public final Map<String, PartiQLValue> options;

@NotNull
public Statement statement;
public final Statement statement;

public Explain(@NotNull Map<String, PartiQLValue> options, @NotNull Statement statement) {
this.options = options;
Expand Down
4 changes: 3 additions & 1 deletion partiql-ast/src/main/java/org/partiql/ast/v1/From.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.partiql.ast.v1;

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

import java.util.ArrayList;
Expand All @@ -9,9 +10,10 @@
/**
* TODO docs, equals, hashcode
*/
@Builder
public class From extends AstNode {
@NotNull
public List<FromTableRef> tableRefs;
public final List<FromTableRef> tableRefs;

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

import lombok.Builder;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.partiql.ast.v1.expr.Expr;
Expand All @@ -11,18 +12,19 @@
/**
* TODO docs, equals, hashcode
*/
@Builder
public class FromExpr extends FromTableRef {
@NotNull
public Expr expr;
public final Expr expr;

@NotNull
public FromType fromType;
public final FromType fromType;

@Nullable
public Identifier asAlias;
public final Identifier asAlias;

@Nullable
public Identifier atAlias;
public final Identifier atAlias;

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

import lombok.Builder;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.partiql.ast.v1.expr.Expr;
Expand All @@ -11,18 +12,19 @@
/**
* TODO docs, equals, hashcode
*/
@Builder
public class FromJoin extends FromTableRef {
@NotNull
public From lhs;
public final From lhs;

@NotNull
public From rhs;
public final From rhs;

@Nullable
public JoinType joinType;
public final JoinType joinType;

@Nullable
public Expr condition;
public final Expr condition;

public FromJoin(@NotNull From lhs, @NotNull From rhs, @Nullable JoinType joinType, @Nullable Expr condition) {
this.lhs = lhs;
Expand Down
13 changes: 8 additions & 5 deletions partiql-ast/src/main/java/org/partiql/ast/v1/GroupBy.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.partiql.ast.v1;

import lombok.Builder;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.partiql.ast.v1.expr.Expr;
Expand All @@ -11,15 +12,16 @@
/**
* TODO docs, equals, hashcode
*/
@Builder
public class GroupBy extends AstNode {
@NotNull
public GroupByStrategy strategy;
public final GroupByStrategy strategy;

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

@Nullable
public Identifier asAlias;
public final Identifier asAlias;

public GroupBy(@NotNull GroupByStrategy strategy, @NotNull List<Key> keys, @Nullable Identifier asAlias) {
this.strategy = strategy;
Expand All @@ -45,12 +47,13 @@ public <R, C> R accept(@NotNull AstVisitor<R, C> visitor, C ctx) {
/**
* TODO docs, equals, hashcode
*/
@Builder
public static class Key extends AstNode {
@NotNull
public Expr expr;
public final Expr expr;

@Nullable
public Identifier asAlias;
public final Identifier asAlias;

public Key(@NotNull Expr expr, @Nullable Identifier asAlias) {
this.expr = expr;
Expand Down
6 changes: 4 additions & 2 deletions partiql-ast/src/main/java/org/partiql/ast/v1/Identifier.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.partiql.ast.v1;

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

import java.util.ArrayList;
Expand All @@ -8,11 +9,12 @@
/**
* TODO docs, equals, hashcode
*/
@Builder
public class Identifier extends AstNode {
@NotNull
public String symbol;
public final String symbol;

public boolean isDelimited;
public final boolean isDelimited;

public Identifier(@NotNull String symbol, boolean isDelimited) {
this.symbol = symbol;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.partiql.ast.v1;

import lombok.Builder;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand All @@ -10,12 +11,13 @@
/**
* TODO docs, equals, hashcode
*/
@Builder
public class IdentifierChain extends AstNode {
@NotNull
public Identifier root;
public final Identifier root;

@Nullable
public IdentifierChain next;
public final IdentifierChain next;

public IdentifierChain(@NotNull Identifier root, @Nullable IdentifierChain next) {
this.root = root;
Expand Down
9 changes: 6 additions & 3 deletions partiql-ast/src/main/java/org/partiql/ast/v1/Let.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.partiql.ast.v1;

import lombok.Builder;
import org.jetbrains.annotations.NotNull;
import org.partiql.ast.v1.expr.Expr;

Expand All @@ -10,9 +11,10 @@
/**
* TODO docs, equals, hashcode
*/
@Builder
public class Let extends AstNode {
@NotNull
public List<Binding> bindings;
public final List<Binding> bindings;

public Let(@NotNull List<Binding> bindings) {
this.bindings = bindings;
Expand All @@ -32,12 +34,13 @@ public <R, C> R accept(@NotNull AstVisitor<R, C> visitor, C ctx) {
/**
* TODO docs, equals, hashcode
*/
@Builder
public static class Binding extends AstNode {
@NotNull
public Expr expr;
public final Expr expr;

@NotNull
public Identifier asAlias;
public final Identifier asAlias;

public Binding(@NotNull Expr expr, @NotNull Identifier asAlias) {
this.expr = expr;
Expand Down
4 changes: 3 additions & 1 deletion partiql-ast/src/main/java/org/partiql/ast/v1/OrderBy.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.partiql.ast.v1;

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

import java.util.ArrayList;
Expand All @@ -9,9 +10,10 @@
/**
* TODO docs, equals, hashcode
*/
@Builder
public class OrderBy extends AstNode {
@NotNull
public List<Sort> sorts;
public final List<Sort> sorts;

public OrderBy(@NotNull List<Sort> sorts) {
this.sorts = sorts;
Expand Down
4 changes: 3 additions & 1 deletion partiql-ast/src/main/java/org/partiql/ast/v1/Query.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.partiql.ast.v1;

import lombok.Builder;
import org.jetbrains.annotations.NotNull;
import org.partiql.ast.v1.expr.Expr;

Expand All @@ -10,9 +11,10 @@
/**
* TODO docs, equals, hashcode
*/
@Builder
public class Query extends Statement {
@NotNull
public Expr expr;
public final Expr expr;

public Query(@NotNull Expr expr) {
this.expr = expr;
Expand Down
Loading

0 comments on commit 9b3f074

Please sign in to comment.