Skip to content

Commit

Permalink
wip - refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
alancai98 committed Nov 21, 2024
1 parent 5d25a5a commit 8d9a9ce
Show file tree
Hide file tree
Showing 22 changed files with 301 additions and 347 deletions.
54 changes: 20 additions & 34 deletions partiql-ast/api/partiql-ast.api
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,6 @@ public final class org/partiql/ast/Ast {
public static final fun identifierChain (Lorg/partiql/ast/Identifier;Lorg/partiql/ast/IdentifierChain;)Lorg/partiql/ast/IdentifierChain;
public static final fun let (Ljava/util/List;)Lorg/partiql/ast/Let;
public static final fun letBinding (Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/Identifier;)Lorg/partiql/ast/Let$Binding;
public static final fun literalBool (Z)Lorg/partiql/ast/literal/LiteralBool;
public static final fun literalDecimal (Ljava/math/BigDecimal;)Lorg/partiql/ast/literal/LiteralDecimal;
public static final fun literalFloat (Ljava/lang/String;)Lorg/partiql/ast/literal/LiteralDouble;
public static final fun literalInt (I)Lorg/partiql/ast/literal/LiteralInt;
public static final fun literalLong (J)Lorg/partiql/ast/literal/LiteralLong;
public static final fun literalMissing ()Lorg/partiql/ast/literal/LiteralMissing;
public static final fun literalNull ()Lorg/partiql/ast/literal/LiteralNull;
public static final fun literalString (Ljava/lang/String;)Lorg/partiql/ast/literal/LiteralString;
public static final fun literalTypedString (Lorg/partiql/ast/DataType;Ljava/lang/String;)Lorg/partiql/ast/literal/LiteralTypedString;
public static final fun orderBy (Ljava/util/List;)Lorg/partiql/ast/OrderBy;
public static final fun query (Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/Query;
public static final fun queryBodySFW (Lorg/partiql/ast/Select;Lorg/partiql/ast/Exclude;Lorg/partiql/ast/From;Lorg/partiql/ast/Let;Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/GroupBy;Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/QueryBody$SFW;
Expand Down Expand Up @@ -2396,58 +2387,52 @@ public abstract class org/partiql/ast/literal/Literal {
public abstract fun getText ()Ljava/lang/String;
}

public class org/partiql/ast/literal/LiteralBool : org/partiql/ast/literal/Literal {
public field value Z
public fun <init> (Z)V
protected fun canEqual (Ljava/lang/Object;)Z
public fun equals (Ljava/lang/Object;)Z
public fun getText ()Ljava/lang/String;
public fun hashCode ()I
}

public class org/partiql/ast/literal/LiteralDecimal : org/partiql/ast/literal/Literal {
public field value Ljava/math/BigDecimal;
public fun <init> (Ljava/math/BigDecimal;)V
public class org/partiql/ast/literal/LiteralApprox : org/partiql/ast/literal/Literal {
protected fun canEqual (Ljava/lang/Object;)Z
public fun equals (Ljava/lang/Object;)Z
public fun getDouble ()D
public fun getText ()Ljava/lang/String;
public fun hashCode ()I
public static fun litApprox (D)Lorg/partiql/ast/literal/LiteralApprox;
public static fun litApprox (F)Lorg/partiql/ast/literal/LiteralApprox;
public static fun litApprox (Ljava/math/BigDecimal;)Lorg/partiql/ast/literal/LiteralApprox;
public static fun litApprox (Ljava/math/BigDecimal;I)Lorg/partiql/ast/literal/LiteralApprox;
}

public class org/partiql/ast/literal/LiteralDouble : org/partiql/ast/literal/Literal {
public field text Ljava/lang/String;
public field value D
public fun <init> (Ljava/lang/String;)V
public class org/partiql/ast/literal/LiteralBool : org/partiql/ast/literal/Literal {
public field value Z
protected fun canEqual (Ljava/lang/Object;)Z
public fun equals (Ljava/lang/Object;)Z
public fun getText ()Ljava/lang/String;
public fun hashCode ()I
public static fun litBool (Z)Lorg/partiql/ast/literal/LiteralBool;
}

public class org/partiql/ast/literal/LiteralInt : org/partiql/ast/literal/Literal {
public field value I
public fun <init> (I)V
public class org/partiql/ast/literal/LiteralExact : org/partiql/ast/literal/Literal {
protected fun canEqual (Ljava/lang/Object;)Z
public fun equals (Ljava/lang/Object;)Z
public fun getDecimal ()Ljava/math/BigDecimal;
public fun getText ()Ljava/lang/String;
public fun hashCode ()I
public static fun litExact (Ljava/math/BigDecimal;)Lorg/partiql/ast/literal/LiteralExact;
}

public class org/partiql/ast/literal/LiteralLong : org/partiql/ast/literal/Literal {
public field value J
public fun <init> (J)V
public class org/partiql/ast/literal/LiteralInteger : org/partiql/ast/literal/Literal {
protected fun canEqual (Ljava/lang/Object;)Z
public fun equals (Ljava/lang/Object;)Z
public fun getInteger ()J
public fun getText ()Ljava/lang/String;
public fun hashCode ()I
public static fun litInt (I)Lorg/partiql/ast/literal/LiteralInteger;
public static fun litInt (J)Lorg/partiql/ast/literal/LiteralInteger;
}

public class org/partiql/ast/literal/LiteralMissing : org/partiql/ast/literal/Literal {
public fun <init> ()V
protected fun canEqual (Ljava/lang/Object;)Z
public fun equals (Ljava/lang/Object;)Z
public fun getText ()Ljava/lang/String;
public fun hashCode ()I
public static fun litMissing ()Lorg/partiql/ast/literal/LiteralMissing;
}

public class org/partiql/ast/literal/LiteralNull : org/partiql/ast/literal/Literal {
Expand All @@ -2456,25 +2441,26 @@ public class org/partiql/ast/literal/LiteralNull : org/partiql/ast/literal/Liter
public fun equals (Ljava/lang/Object;)Z
public fun getText ()Ljava/lang/String;
public fun hashCode ()I
public static fun litNull ()Lorg/partiql/ast/literal/LiteralNull;
}

public class org/partiql/ast/literal/LiteralString : org/partiql/ast/literal/Literal {
public field value Ljava/lang/String;
public fun <init> (Ljava/lang/String;)V
protected fun canEqual (Ljava/lang/Object;)Z
public fun equals (Ljava/lang/Object;)Z
public fun getText ()Ljava/lang/String;
public fun hashCode ()I
public static fun litString (Ljava/lang/String;)Lorg/partiql/ast/literal/LiteralString;
}

public class org/partiql/ast/literal/LiteralTypedString : org/partiql/ast/literal/Literal {
public field type Lorg/partiql/ast/DataType;
public field value Ljava/lang/String;
public fun <init> (Lorg/partiql/ast/DataType;Ljava/lang/String;)V
protected fun canEqual (Ljava/lang/Object;)Z
public fun equals (Ljava/lang/Object;)Z
public fun getText ()Ljava/lang/String;
public fun hashCode ()I
public static fun litTypedString (Lorg/partiql/ast/DataType;Ljava/lang/String;)Lorg/partiql/ast/literal/LiteralTypedString;
}

public abstract class org/partiql/ast/sql/SqlBlock {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package org.partiql.ast.literal;

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

import java.math.BigDecimal;

/**
* TODO docs
*/
@EqualsAndHashCode(callSuper = false)
public class LiteralApprox extends Literal {
@NotNull
private final BigDecimal mantissa;

private final int exponent;

private LiteralApprox(@NotNull BigDecimal mantissa, int exponent) {
this.mantissa = mantissa;
this.exponent = exponent;
}

@NotNull
public static LiteralApprox litApprox(BigDecimal mantissa, int exponent) {
return new LiteralApprox(mantissa, exponent);
}

@NotNull
public static LiteralApprox litApprox(BigDecimal value) {
return new LiteralApprox(value, 0);
}

@NotNull
public static LiteralApprox litApprox(float value) {
return litApprox(BigDecimal.valueOf(value));
}

@NotNull
public static LiteralApprox litApprox(double value) {
return litApprox(BigDecimal.valueOf(value));
}

public double getDouble() {
return mantissa.scaleByPowerOfTen(exponent).doubleValue();
}

@NotNull
@Override
public String getText() {
return mantissa + "E" + exponent;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@
public class LiteralBool extends Literal {
public boolean value;

public LiteralBool(boolean value) {
private LiteralBool(boolean value) {
this.value = value;
}

@NotNull
public static LiteralBool litBool(boolean value) {
return new LiteralBool(value);
}

@NotNull
@Override
public String getText() {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,24 @@
* TODO DOCS
*/
@EqualsAndHashCode(callSuper = false)
public class LiteralDecimal extends Literal {
public class LiteralExact extends Literal {
@NotNull
public BigDecimal value;
private final BigDecimal value;

public LiteralDecimal(@NotNull BigDecimal value) {
private LiteralExact(@NotNull BigDecimal value) {
this.value = value;
}

@NotNull
public static LiteralExact litExact(BigDecimal value) {
return new LiteralExact(value);
}

@NotNull
public BigDecimal getDecimal() {
return value;
}

@NotNull
@Override
public String getText() {
Expand Down
22 changes: 0 additions & 22 deletions partiql-ast/src/main/java/org/partiql/ast/literal/LiteralInt.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.partiql.ast.literal;

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

/**
* TODO docs
*/
@EqualsAndHashCode(callSuper = false)
public class LiteralInteger extends Literal {
private final long value;

private LiteralInteger(long value) {
this.value = value;
}

@NotNull
public static LiteralInteger litInt(long value) {
return new LiteralInteger(value);
}

@NotNull
public static LiteralInteger litInt(int value) {
return new LiteralInteger(value);
}

public long getInteger() {
return value;
}

@NotNull
@Override
public String getText() {
return Long.toString(value);
}
}
22 changes: 0 additions & 22 deletions partiql-ast/src/main/java/org/partiql/ast/literal/LiteralLong.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
*/
@EqualsAndHashCode(callSuper = false)
public class LiteralMissing extends Literal {
public LiteralMissing() {}
private LiteralMissing() {}

@NotNull
public static LiteralMissing litMissing() {
return new LiteralMissing();
}

@NotNull
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
public class LiteralNull extends Literal {
public LiteralNull() {}

@NotNull
public static LiteralNull litNull() {
return new LiteralNull();
}

@NotNull
@Override
public String getText() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,15 @@ public class LiteralString extends Literal {
@NotNull
public String value;

public LiteralString(@NotNull String value) {
private LiteralString(@NotNull String value) {
this.value = value;
}

@NotNull
public static LiteralString litString(@NotNull String value) {
return new LiteralString(value);
}

@NotNull
@Override
public String getText() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@ public class LiteralTypedString extends Literal {
@NotNull
public String value;

public LiteralTypedString(@NotNull DataType type, @NotNull String value) {
private LiteralTypedString(@NotNull DataType type, @NotNull String value) {
this.type = type;
this.value = value;
}

@NotNull
public static LiteralTypedString litTypedString(@NotNull DataType type, @NotNull String value) {
return new LiteralTypedString(type, value);
}

@NotNull
@Override
public String getText() {
Expand Down
Loading

0 comments on commit 8d9a9ce

Please sign in to comment.