Skip to content

Commit

Permalink
Make boolean getters use 'is' prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
alancai98 committed Dec 18, 2024
1 parent 7e451aa commit c99ca07
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 67 deletions.
29 changes: 14 additions & 15 deletions partiql-ast/api/partiql-ast.api
Original file line number Diff line number Diff line change
Expand Up @@ -732,9 +732,9 @@ public class org/partiql/ast/DataType$StructField : org/partiql/ast/AstNode {
public fun equals (Ljava/lang/Object;)Z
public fun getChildren ()Ljava/util/List;
public fun getName ()Lorg/partiql/ast/Identifier;
public fun getOptional ()Z
public fun getType ()Lorg/partiql/ast/DataType;
public fun hashCode ()I
public fun isOptional ()Z
}

public final class org/partiql/ast/DatetimeField : org/partiql/ast/AstEnum {
Expand Down Expand Up @@ -1029,9 +1029,9 @@ public final class org/partiql/ast/Identifier : org/partiql/ast/AstNode {
public static fun builder ()Lorg/partiql/ast/Identifier$Builder;
public fun equals (Ljava/lang/Object;)Z
public fun getChildren ()Ljava/util/List;
public fun getDelimited ()Z
public fun getSymbol ()Ljava/lang/String;
public fun hashCode ()I
public fun isDelimited ()Z
}

public class org/partiql/ast/Identifier$Builder {
Expand Down Expand Up @@ -1268,9 +1268,9 @@ public class org/partiql/ast/QueryBody$SetOp : org/partiql/ast/QueryBody {
protected fun canEqual (Ljava/lang/Object;)Z
public fun equals (Ljava/lang/Object;)Z
public fun getChildren ()Ljava/util/List;
public fun getOuter ()Z
public fun getType ()Lorg/partiql/ast/SetOp;
public fun hashCode ()I
public fun isOuter ()Z
}

public class org/partiql/ast/QueryBody$SetOp$Builder {
Expand Down Expand Up @@ -1496,17 +1496,17 @@ public class org/partiql/ast/ddl/AttributeConstraint$Null : org/partiql/ast/ddl/
public fun accept (Lorg/partiql/ast/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object;
protected fun canEqual (Ljava/lang/Object;)Z
public fun equals (Ljava/lang/Object;)Z
public fun getNullable ()Z
public fun hashCode ()I
public fun isNullable ()Z
}

public class org/partiql/ast/ddl/AttributeConstraint$Unique : org/partiql/ast/ddl/AttributeConstraint {
public fun <init> (Lorg/partiql/ast/IdentifierChain;Z)V
public fun accept (Lorg/partiql/ast/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object;
protected fun canEqual (Ljava/lang/Object;)Z
public fun equals (Ljava/lang/Object;)Z
public fun getPrimaryKey ()Z
public fun hashCode ()I
public fun isPrimaryKey ()Z
}

public final class org/partiql/ast/ddl/ColumnDefinition : org/partiql/ast/AstNode {
Expand All @@ -1519,8 +1519,8 @@ public final class org/partiql/ast/ddl/ColumnDefinition : org/partiql/ast/AstNod
public fun getConstraints ()Ljava/util/List;
public fun getDataType ()Lorg/partiql/ast/DataType;
public fun getName ()Lorg/partiql/ast/Identifier;
public fun getOptional ()Z
public fun hashCode ()I
public fun isOptional ()Z
}

public class org/partiql/ast/ddl/ColumnDefinition$Builder {
Expand Down Expand Up @@ -1608,8 +1608,8 @@ public class org/partiql/ast/ddl/TableConstraint$Unique : org/partiql/ast/ddl/Ta
public fun equals (Ljava/lang/Object;)Z
public fun getChildren ()Ljava/util/List;
public fun getColumns ()Ljava/util/List;
public fun getPrimaryKey ()Z
public fun hashCode ()I
public fun isPrimaryKey ()Z
}

public abstract class org/partiql/ast/dml/ConflictAction : org/partiql/ast/AstNode {
Expand Down Expand Up @@ -2027,10 +2027,10 @@ public final class org/partiql/ast/expr/ExprBetween : org/partiql/ast/expr/Expr
public fun equals (Ljava/lang/Object;)Z
public fun getChildren ()Ljava/util/List;
public fun getFrom ()Lorg/partiql/ast/expr/Expr;
public fun getNot ()Z
public fun getTo ()Lorg/partiql/ast/expr/Expr;
public fun getValue ()Lorg/partiql/ast/expr/Expr;
public fun hashCode ()I
public fun isNot ()Z
}

public class org/partiql/ast/expr/ExprBetween$Builder {
Expand All @@ -2048,10 +2048,10 @@ public final class org/partiql/ast/expr/ExprBoolTest : org/partiql/ast/expr/Expr
public static fun builder ()Lorg/partiql/ast/expr/ExprBoolTest$Builder;
public fun equals (Ljava/lang/Object;)Z
public fun getChildren ()Ljava/util/List;
public fun getNot ()Z
public fun getTruthValue ()Lorg/partiql/ast/expr/TruthValue;
public fun getValue ()Lorg/partiql/ast/expr/Expr;
public fun hashCode ()I
public fun isNot ()Z
}

public class org/partiql/ast/expr/ExprBoolTest$Builder {
Expand Down Expand Up @@ -2180,9 +2180,9 @@ public final class org/partiql/ast/expr/ExprInCollection : org/partiql/ast/expr/
public fun equals (Ljava/lang/Object;)Z
public fun getChildren ()Ljava/util/List;
public fun getLhs ()Lorg/partiql/ast/expr/Expr;
public fun getNot ()Z
public fun getRhs ()Lorg/partiql/ast/expr/Expr;
public fun hashCode ()I
public fun isNot ()Z
}

public class org/partiql/ast/expr/ExprInCollection$Builder {
Expand All @@ -2199,10 +2199,10 @@ public final class org/partiql/ast/expr/ExprIsType : org/partiql/ast/expr/Expr {
public static fun builder ()Lorg/partiql/ast/expr/ExprIsType$Builder;
public fun equals (Ljava/lang/Object;)Z
public fun getChildren ()Ljava/util/List;
public fun getNot ()Z
public fun getType ()Lorg/partiql/ast/DataType;
public fun getValue ()Lorg/partiql/ast/expr/Expr;
public fun hashCode ()I
public fun isNot ()Z
}

public class org/partiql/ast/expr/ExprIsType$Builder {
Expand All @@ -2220,10 +2220,10 @@ public final class org/partiql/ast/expr/ExprLike : org/partiql/ast/expr/Expr {
public fun equals (Ljava/lang/Object;)Z
public fun getChildren ()Ljava/util/List;
public fun getEscape ()Lorg/partiql/ast/expr/Expr;
public fun getNot ()Z
public fun getPattern ()Lorg/partiql/ast/expr/Expr;
public fun getValue ()Lorg/partiql/ast/expr/Expr;
public fun hashCode ()I
public fun isNot ()Z
}

public class org/partiql/ast/expr/ExprLike$Builder {
Expand Down Expand Up @@ -2268,9 +2268,9 @@ public final class org/partiql/ast/expr/ExprMissingPredicate : org/partiql/ast/e
public static fun builder ()Lorg/partiql/ast/expr/ExprMissingPredicate$Builder;
public fun equals (Ljava/lang/Object;)Z
public fun getChildren ()Ljava/util/List;
public fun getNot ()Z
public fun getValue ()Lorg/partiql/ast/expr/Expr;
public fun hashCode ()I
public fun isNot ()Z
}

public class org/partiql/ast/expr/ExprMissingPredicate$Builder {
Expand Down Expand Up @@ -2320,9 +2320,9 @@ public final class org/partiql/ast/expr/ExprNullPredicate : org/partiql/ast/expr
public static fun builder ()Lorg/partiql/ast/expr/ExprNullPredicate$Builder;
public fun equals (Ljava/lang/Object;)Z
public fun getChildren ()Ljava/util/List;
public fun getNot ()Z
public fun getValue ()Lorg/partiql/ast/expr/Expr;
public fun hashCode ()I
public fun isNot ()Z
}

public class org/partiql/ast/expr/ExprNullPredicate$Builder {
Expand Down Expand Up @@ -2473,7 +2473,6 @@ public final class org/partiql/ast/expr/ExprRowValue : org/partiql/ast/expr/Expr
public static fun builder ()Lorg/partiql/ast/expr/ExprRowValue$Builder;
public fun equals (Ljava/lang/Object;)Z
public fun getChildren ()Ljava/util/List;
public fun getExplicit ()Z
public fun getValues ()Ljava/util/List;
public fun hashCode ()I
public fun isExplicit ()Z
Expand Down
4 changes: 0 additions & 4 deletions partiql-ast/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ plugins {
kotlin("plugin.lombok") version "2.1.0"
}

kotlinLombok {
lombokConfigurationFile(file("lombok.config"))
}

dependencies {
api(Deps.ionElement)
compileOnly(Deps.lombok)
Expand Down
3 changes: 0 additions & 3 deletions partiql-ast/lombok.config

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@
@lombok.Builder(builderClassName = "Builder")
@EqualsAndHashCode(callSuper = false)
public final class ExprRowValue extends Expr {
public boolean isExplicit() {
return explicit;
}

/**
* Specifies whether the ROW keyword explicitly precedes the elements in the textual representation. For example,
* {@code ROW (1, 2, 3)} versus {@code (1, 2, 3)}. In the first example, {@code isExplicit} is true.
Expand Down
18 changes: 9 additions & 9 deletions partiql-ast/src/main/java/org/partiql/ast/sql/SqlDialect.kt
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ public abstract class SqlDialect : AstVisitor<SqlBlock, SqlBlock>() {
override fun visitExprLike(node: ExprLike, tail: SqlBlock): SqlBlock {
var t = tail
t = visitExprWrapped(node.value, t)
t = t concat if (node.not) " NOT LIKE " else " LIKE "
t = t concat if (node.isNot) " NOT LIKE " else " LIKE "
t = visitExprWrapped(node.pattern, t)
val escape = node.escape
if (escape != null) {
Expand All @@ -409,7 +409,7 @@ public abstract class SqlDialect : AstVisitor<SqlBlock, SqlBlock>() {
override fun visitExprBetween(node: ExprBetween, tail: SqlBlock): SqlBlock {
var t = tail
t = visitExprWrapped(node.value, t)
t = t concat if (node.not) " NOT BETWEEN " else " BETWEEN "
t = t concat if (node.isNot) " NOT BETWEEN " else " BETWEEN "
t = visitExprWrapped(node.from, t)
t = t concat " AND "
t = visitExprWrapped(node.to, t)
Expand All @@ -419,29 +419,29 @@ public abstract class SqlDialect : AstVisitor<SqlBlock, SqlBlock>() {
override fun visitExprInCollection(node: ExprInCollection, tail: SqlBlock): SqlBlock {
var t = tail
t = visitExprWrapped(node.lhs, t)
t = t concat if (node.not) " NOT IN " else " IN "
t = t concat if (node.isNot) " NOT IN " else " IN "
t = visitExprWrapped(node.rhs, t)
return t
}

override fun visitExprNullPredicate(node: ExprNullPredicate, tail: SqlBlock): SqlBlock {
var t = tail
t = visitExprWrapped(node.value, t)
t = t concat if (node.not) " IS NOT NULL" else " IS NULL"
t = t concat if (node.isNot) " IS NOT NULL" else " IS NULL"
return t
}

override fun visitExprMissingPredicate(node: ExprMissingPredicate, tail: SqlBlock): SqlBlock {
var t = tail
t = visitExprWrapped(node.value, t)
t = t concat if (node.not) " IS NOT MISSING" else " IS MISSING"
t = t concat if (node.isNot) " IS NOT MISSING" else " IS MISSING"
return t
}

override fun visitExprBoolTest(node: ExprBoolTest, tail: SqlBlock): SqlBlock {
var t = tail
t = visitExprWrapped(node.value, t)
t = t concat if (node.not) " IS NOT " else " IS "
t = t concat if (node.isNot) " IS NOT " else " IS "
t = t concat when (node.truthValue.code()) {
TruthValue.TRUE -> "TRUE"
TruthValue.FALSE -> "FALSE"
Expand All @@ -454,7 +454,7 @@ public abstract class SqlDialect : AstVisitor<SqlBlock, SqlBlock>() {
override fun visitExprIsType(node: ExprIsType, tail: SqlBlock): SqlBlock {
var t = tail
t = visitExprWrapped(node.value, t)
t = t concat if (node.not) " IS NOT " else " IS "
t = t concat if (node.isNot) " IS NOT " else " IS "
t = visitDataType(node.type, t)
return t
}
Expand Down Expand Up @@ -631,7 +631,7 @@ public abstract class SqlDialect : AstVisitor<SqlBlock, SqlBlock>() {

override fun visitQueryBodySetOp(node: QueryBody.SetOp, tail: SqlBlock): SqlBlock {
val op = mutableListOf<String>()
when (node.outer) {
when (node.isOuter) {
true -> op.add("OUTER")
else -> {}
}
Expand Down Expand Up @@ -894,7 +894,7 @@ public abstract class SqlDialect : AstVisitor<SqlBlock, SqlBlock>() {
)
}

private fun Identifier.sql() = when (delimited) {
private fun Identifier.sql() = when (isDelimited) {
true -> "\"$symbol\""
false -> symbol // verbatim ..
}
Expand Down
34 changes: 17 additions & 17 deletions partiql-ast/src/main/kotlin/org/partiql/ast/AstRewriter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ public abstract class AstRewriter<C> : AstVisitor<AstNode, C>() {
val value = visitExpr(node.value, ctx) as Expr
val from = visitExpr(node.from, ctx) as Expr
val to = visitExpr(node.to, ctx) as Expr
val not = node.not
return if (value !== node.value || from !== node.from || to !== node.to || not != node.not) {
val not = node.isNot
return if (value !== node.value || from !== node.from || to !== node.to || not != node.isNot) {
ExprBetween(value, from, to, not)
} else {
node
Expand Down Expand Up @@ -186,8 +186,8 @@ public abstract class AstRewriter<C> : AstVisitor<AstNode, C>() {
override fun visitExprInCollection(node: ExprInCollection, ctx: C): AstNode {
val lhs = visitExpr(node.lhs, ctx) as Expr
val rhs = visitExpr(node.rhs, ctx) as Expr
val not = node.not
return if (lhs !== node.lhs || rhs !== node.rhs || not != node.not) {
val not = node.isNot
return if (lhs !== node.lhs || rhs !== node.rhs || not != node.isNot) {
ExprInCollection(lhs, rhs, not)
} else {
node
Expand All @@ -196,8 +196,8 @@ public abstract class AstRewriter<C> : AstVisitor<AstNode, C>() {

override fun visitExprMissingPredicate(node: ExprMissingPredicate, ctx: C): AstNode {
val value = visitExpr(node.value, ctx) as Expr
val not = node.not
return if (value !== node.value || not != node.not) {
val not = node.isNot
return if (value !== node.value || not != node.isNot) {
ExprMissingPredicate(value, not)
} else {
node
Expand All @@ -206,8 +206,8 @@ public abstract class AstRewriter<C> : AstVisitor<AstNode, C>() {

override fun visitExprNullPredicate(node: ExprNullPredicate, ctx: C): AstNode {
val value = visitExpr(node.value, ctx) as Expr
val not = node.not
return if (value !== node.value || not != node.not) {
val not = node.isNot
return if (value !== node.value || not != node.isNot) {
ExprNullPredicate(value, not)
} else {
node
Expand All @@ -216,9 +216,9 @@ public abstract class AstRewriter<C> : AstVisitor<AstNode, C>() {

override fun visitExprBoolTest(node: ExprBoolTest, ctx: C): AstNode {
val value = visitExpr(node.value, ctx) as Expr
val not = node.not
val not = node.isNot
val truthValue = node.truthValue
return if (value !== node.value || not != node.not || truthValue != node.truthValue) {
return if (value !== node.value || not != node.isNot || truthValue != node.truthValue) {
ExprBoolTest(value, not, truthValue)
} else {
node
Expand All @@ -228,8 +228,8 @@ public abstract class AstRewriter<C> : AstVisitor<AstNode, C>() {
override fun visitExprIsType(node: ExprIsType, ctx: C): AstNode {
val value = visitExpr(node.value, ctx) as Expr
val type = node.type
val not = node.not
return if (value !== node.value || type !== node.type || not != node.not) {
val not = node.isNot
return if (value !== node.value || type !== node.type || not != node.isNot) {
ExprIsType(value, type, not)
} else {
node
Expand All @@ -240,8 +240,8 @@ public abstract class AstRewriter<C> : AstVisitor<AstNode, C>() {
val value = visitExpr(node.value, ctx) as Expr
val pattern = visitExpr(node.pattern, ctx) as Expr
val escape = node.escape?.let { visitExpr(it, ctx) as Expr? }
val not = node.not
return if (value !== node.value || pattern !== node.pattern || escape !== node.escape || not != node.not) {
val not = node.isNot
return if (value !== node.value || pattern !== node.pattern || escape !== node.escape || not != node.isNot) {
ExprLike(value, pattern, escape, not)
} else {
node
Expand Down Expand Up @@ -670,7 +670,7 @@ public abstract class AstRewriter<C> : AstVisitor<AstNode, C>() {

override fun visitIdentifier(node: Identifier, ctx: C): AstNode {
val symbol = node.symbol
val isDelimited = node.delimited
val isDelimited = node.isDelimited
return identifier(symbol, isDelimited)
}

Expand Down Expand Up @@ -731,10 +731,10 @@ public abstract class AstRewriter<C> : AstVisitor<AstNode, C>() {

public override fun visitQueryBodySetOp(node: QueryBody.SetOp, ctx: C): AstNode {
val type = visitSetOp(node.type, ctx) as SetOp
val isOuter = node.outer
val isOuter = node.isOuter
val lhs = visitExpr(node.lhs, ctx) as Expr
val rhs = visitExpr(node.rhs, ctx) as Expr
return if (type !== node.type || isOuter != node.outer || lhs !== node.lhs || rhs !== node.rhs) {
return if (type !== node.type || isOuter != node.isOuter || lhs !== node.lhs || rhs !== node.rhs) {
QueryBody.SetOp(type, isOuter, lhs, rhs)
} else {
node
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -645,8 +645,8 @@ internal class PartiQLParserDefault : PartiQLParser {
val constrName = ctx.constraintName()?.let { visitQualifiedName(it.qualifiedName()) }
val body = visitAs<AttributeConstraint>(ctx.columnConstraint())
when (body) {
is AttributeConstraint.Unique -> columnConstraintUnique(constrName, body.primaryKey)
is AttributeConstraint.Null -> columnConstraintNullable(constrName, body.nullable)
is AttributeConstraint.Unique -> columnConstraintUnique(constrName, body.isPrimaryKey)
is AttributeConstraint.Null -> columnConstraintNullable(constrName, body.isNullable)
is AttributeConstraint.Check -> columnConstraintCheck(constrName, body.searchCondition)
else -> throw error(ctx, "Unexpected Table Constraint Definition")
}
Expand Down Expand Up @@ -677,7 +677,7 @@ internal class PartiQLParserDefault : PartiQLParser {
val constraintName = ctx.constraintName()?.let { visitQualifiedName(it.qualifiedName()) }
val body = visitAs<TableConstraint>(ctx.tableConstraint())
when (body) {
is TableConstraint.Unique -> tableConstraintUnique(constraintName, body.columns, body.primaryKey)
is TableConstraint.Unique -> tableConstraintUnique(constraintName, body.columns, body.isPrimaryKey)
else -> throw error(ctx, "Unexpected Table Constraint Definition")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ internal object AstToPlan {
return Identifier.of(part(identifier))
}

fun part(identifier: AstIdentifier): Identifier.Part = when (identifier.delimited) {
fun part(identifier: AstIdentifier): Identifier.Part = when (identifier.isDelimited) {
true -> Identifier.Part.delimited(identifier.symbol)
false -> Identifier.Part.regular(identifier.symbol)
}
Expand Down
Loading

0 comments on commit c99ca07

Please sign in to comment.