-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
301 additions
and
347 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
partiql-ast/src/main/java/org/partiql/ast/literal/LiteralApprox.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 0 additions & 26 deletions
26
partiql-ast/src/main/java/org/partiql/ast/literal/LiteralDouble.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 0 additions & 22 deletions
22
partiql-ast/src/main/java/org/partiql/ast/literal/LiteralInt.java
This file was deleted.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
partiql-ast/src/main/java/org/partiql/ast/literal/LiteralInteger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
22
partiql-ast/src/main/java/org/partiql/ast/literal/LiteralLong.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.