1 package com.github.mygreen.cellformatter.number;
2
3
4
5
6
7
8
9
10
11
12 public abstract class FormattedNumber {
13
14
15
16
17 protected final double value;
18
19
20
21
22 protected boolean useSeparator;
23
24 public FormattedNumber(final double value) {
25 this.value = value;
26 }
27
28
29
30
31
32 public double getValue() {
33 return value;
34 }
35
36
37
38
39
40 public boolean isZero() {
41 return value == 0.0d;
42 }
43
44
45
46
47
48 public boolean isPositive() {
49 return value > 0;
50 }
51
52
53
54
55
56 public boolean isNegative() {
57 return value < 0;
58 }
59
60 public NativeNumber asNative() {
61 return (NativeNumber) this;
62 }
63
64 public DecimalNumber asDecimal() {
65 return (DecimalNumber) this;
66 }
67
68 public PercentNumber asPercent() {
69 return (PercentNumber) this;
70 }
71
72 public ExponentNumber asExponent() {
73 return (ExponentNumber) this;
74 }
75
76 public FractionNumber asFraction() {
77 return (FractionNumber) this;
78 }
79
80
81
82
83
84 public boolean isUseSeparator() {
85 return useSeparator;
86 }
87
88
89
90
91
92 public void setUseSeparator(boolean useSeparator) {
93 this.useSeparator = useSeparator;
94 }
95 }