Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable formatting of BigDecimal and BigInteger in the web console. #1990

Merged
merged 2 commits into from
Feb 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package io.deephaven.web.client.api.i18n;

import com.google.gwt.i18n.client.NumberFormat;
import io.deephaven.web.client.api.BigDecimalWrapper;
import io.deephaven.web.client.api.BigIntegerWrapper;
import io.deephaven.web.client.api.LongWrapper;
import jsinterop.annotations.JsConstructor;
import jsinterop.annotations.JsType;
import jsinterop.base.Js;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
Expand Down Expand Up @@ -46,6 +50,10 @@ public String format(Object number) {
Objects.requireNonNull(number);
if (number instanceof Double) {// aka typeof number, and non-null
return wrapped.format((double) (Double) number);
} else if (number instanceof BigDecimalWrapper) {
return wrapped.format(((BigDecimalWrapper) number).getWrapped());
} else if (number instanceof BigIntegerWrapper) {
return wrapped.format(((BigIntegerWrapper) number).getWrapped());
} else if (number instanceof LongWrapper) {
return wrapped.format((Long) ((LongWrapper) number).getWrapped());
}
Expand Down