-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #93 from kdbinsidebrains/92-support-for-scientific…
…-notation-in-table-output gradle build fixed
- Loading branch information
Showing
16 changed files
with
518 additions
and
121 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
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
72 changes: 64 additions & 8 deletions
72
src/main/java/org/kdb/inside/brains/view/FormatterOptions.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 |
---|---|---|
@@ -1,15 +1,71 @@ | ||
package org.kdb.inside.brains.view; | ||
|
||
public interface FormatterOptions { | ||
int getFloatPrecision(); | ||
import org.kdb.inside.brains.settings.KdbSettingsService; | ||
import org.kdb.inside.brains.view.console.ConsoleOptions; | ||
import org.kdb.inside.brains.view.console.NumericalOptions; | ||
|
||
boolean isWrapStrings(); | ||
import java.math.RoundingMode; | ||
import java.util.function.BooleanSupplier; | ||
|
||
boolean isPrefixSymbols(); | ||
public class FormatterOptions { | ||
private final ConsoleOptions consoleOptions; | ||
private final NumericalOptions numericalOptions; | ||
|
||
boolean isEnlistArrays(); | ||
private final BooleanSupplier thousandsSupplier; | ||
private final BooleanSupplier scientificSupplier; | ||
|
||
default boolean isThousandsSeparator() { | ||
return false; | ||
public FormatterOptions() { | ||
this(KdbSettingsService.getInstance().getConsoleOptions(), KdbSettingsService.getInstance().getNumericalOptions()); | ||
} | ||
} | ||
|
||
public FormatterOptions(ConsoleOptions consoleOptions, NumericalOptions numericalOptions) { | ||
this(consoleOptions, numericalOptions, () -> false, numericalOptions::isScientificNotation); | ||
} | ||
|
||
private FormatterOptions(ConsoleOptions consoleOptions, NumericalOptions numericalOptions, BooleanSupplier thousandsSupplier, BooleanSupplier scientificSupplier) { | ||
this.consoleOptions = consoleOptions; | ||
this.numericalOptions = numericalOptions; | ||
this.thousandsSupplier = thousandsSupplier; | ||
this.scientificSupplier = scientificSupplier; | ||
} | ||
|
||
public boolean isWrapStrings() { | ||
return consoleOptions.isWrapStrings(); | ||
} | ||
|
||
public boolean isPrefixSymbols() { | ||
return consoleOptions.isPrefixSymbols(); | ||
} | ||
|
||
public boolean isEnlistArrays() { | ||
return consoleOptions.isEnlistArrays(); | ||
} | ||
|
||
public int getFloatPrecision() { | ||
return numericalOptions.getFloatPrecision(); | ||
} | ||
|
||
public RoundingMode getRoundingMode() { | ||
return numericalOptions.getRoundingMode(); | ||
} | ||
|
||
public boolean isScientificNotation() { | ||
return scientificSupplier.getAsBoolean(); | ||
} | ||
|
||
public boolean isThousandsSeparator() { | ||
return thousandsSupplier.getAsBoolean(); | ||
} | ||
|
||
public FormatterOptions withThousandsSeparator(BooleanSupplier thousands) { | ||
return new FormatterOptions(consoleOptions, numericalOptions, thousands, scientificSupplier); | ||
} | ||
|
||
public FormatterOptions withScientificNotation(BooleanSupplier scientific) { | ||
return new FormatterOptions(consoleOptions, numericalOptions, thousandsSupplier, scientific); | ||
} | ||
|
||
public FormatterOptions withThousandAndScientific(BooleanSupplier thousands, BooleanSupplier scientific) { | ||
return new FormatterOptions(consoleOptions, numericalOptions, thousands, scientific); | ||
} | ||
} |
Oops, something went wrong.