Skip to content

Commit 2e5b4b0

Browse files
authored
Merge pull request #8613 from mP1/feature/SpreadsheetFormatterSharedToString-was-ToStringSpreadsheetFormatter-extends-SpreadsheetFormatterShared
SpreadsheetFormatterSharedToString was ToStringSpreadsheetFormatter e…
2 parents 3ffd6dc + 34fc764 commit 2e5b4b0

File tree

3 files changed

+30
-40
lines changed

3 files changed

+30
-40
lines changed

src/main/java/walkingkooka/spreadsheet/format/ToStringSpreadsheetFormatter.java renamed to src/main/java/walkingkooka/spreadsheet/format/SpreadsheetFormatterSharedToString.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
/**
3131
* Wrapos another {@link SpreadsheetFormatter} and uses the provided {@link #toString()}.
3232
*/
33-
final class ToStringSpreadsheetFormatter implements SpreadsheetFormatter,
34-
TreePrintable {
33+
final class SpreadsheetFormatterSharedToString extends SpreadsheetFormatterShared
34+
implements TreePrintable {
3535

3636
static SpreadsheetFormatter with(final SpreadsheetFormatter formatter,
3737
final String toString) {
@@ -45,13 +45,13 @@ static SpreadsheetFormatter with(final SpreadsheetFormatter formatter,
4545
if (temp.toString().equals(toString)) {
4646
formatterWithToString = formatter; // no need to wrap
4747
} else {
48-
if (temp instanceof ToStringSpreadsheetFormatter) {
49-
temp = ((ToStringSpreadsheetFormatter) temp).formatter;
48+
if (temp instanceof SpreadsheetFormatterSharedToString) {
49+
temp = ((SpreadsheetFormatterSharedToString) temp).formatter;
5050
}
5151
if (temp.toString().equals(toString)) {
5252
formatterWithToString = formatter; // no need to wrap
5353
} else {
54-
formatterWithToString = new ToStringSpreadsheetFormatter(
54+
formatterWithToString = new SpreadsheetFormatterSharedToString(
5555
formatter,
5656
toString
5757
);
@@ -61,8 +61,8 @@ static SpreadsheetFormatter with(final SpreadsheetFormatter formatter,
6161
return formatterWithToString;
6262
}
6363

64-
private ToStringSpreadsheetFormatter(final SpreadsheetFormatter formatter,
65-
final String toString) {
64+
private SpreadsheetFormatterSharedToString(final SpreadsheetFormatter formatter,
65+
final String toString) {
6666
super();
6767

6868
this.formatter = formatter;
@@ -98,11 +98,11 @@ public int hashCode() {
9898
@Override
9999
public boolean equals(final Object other) {
100100
return this == other ||
101-
other instanceof ToStringSpreadsheetFormatter &&
101+
other instanceof SpreadsheetFormatterSharedToString &&
102102
this.equals0(Cast.to(other));
103103
}
104104

105-
private boolean equals0(final ToStringSpreadsheetFormatter other) {
105+
private boolean equals0(final SpreadsheetFormatterSharedToString other) {
106106
return this.formatter.equals(other.formatter) &&
107107
this.toString.equals(other.toString);
108108
}

src/main/java/walkingkooka/spreadsheet/format/SpreadsheetFormatters.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,11 @@ public static SpreadsheetFormatter text(final TextSpreadsheetFormatParserToken t
198198
}
199199

200200
/**
201-
* {@see ToStringSpreadsheetFormatter}
201+
* {@see SpreadsheetFormatterSharedToString}
202202
*/
203203
public static SpreadsheetFormatter toString(final SpreadsheetFormatter formatter,
204204
final String toString) {
205-
return ToStringSpreadsheetFormatter.with(
205+
return SpreadsheetFormatterSharedToString.with(
206206
formatter,
207207
toString
208208
);

src/test/java/walkingkooka/spreadsheet/format/ToStringSpreadsheetFormatterTest.java renamed to src/test/java/walkingkooka/spreadsheet/format/SpreadsheetFormatterSharedToStringTest.java

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@
1919

2020
import org.junit.jupiter.api.Test;
2121
import walkingkooka.HashCodeEqualsDefinedTesting2;
22-
import walkingkooka.ToStringTesting;
2322
import walkingkooka.collect.list.Lists;
24-
import walkingkooka.reflect.ClassTesting2;
25-
import walkingkooka.reflect.JavaVisibility;
2623
import walkingkooka.spreadsheet.format.provider.SpreadsheetFormatterSelectorToken;
2724
import walkingkooka.tree.text.TextNode;
2825

@@ -33,10 +30,8 @@
3330
import static org.junit.jupiter.api.Assertions.assertSame;
3431
import static org.junit.jupiter.api.Assertions.assertThrows;
3532

36-
public final class ToStringSpreadsheetFormatterTest implements SpreadsheetFormatterTesting2<ToStringSpreadsheetFormatter>,
37-
HashCodeEqualsDefinedTesting2<ToStringSpreadsheetFormatter>,
38-
ToStringTesting<ToStringSpreadsheetFormatter>,
39-
ClassTesting2<ToStringSpreadsheetFormatter> {
33+
public final class SpreadsheetFormatterSharedToStringTest extends SpreadsheetFormatterSharedTestCase<SpreadsheetFormatterSharedToString>
34+
implements HashCodeEqualsDefinedTesting2<SpreadsheetFormatterSharedToString> {
4035

4136
private final static List<SpreadsheetFormatterSelectorToken> TOKENS = Lists.of(
4237
SpreadsheetFormatterSelectorToken.with(
@@ -83,7 +78,7 @@ public String toString() {
8378
public void testWithNullFormatterFails() {
8479
assertThrows(
8580
NullPointerException.class,
86-
() -> ToStringSpreadsheetFormatter.with(
81+
() -> SpreadsheetFormatterSharedToString.with(
8782
null,
8883
TO_STRING
8984
)
@@ -94,7 +89,7 @@ public void testWithNullFormatterFails() {
9489
public void testWithNullToStringFails() {
9590
assertThrows(
9691
NullPointerException.class,
97-
() -> ToStringSpreadsheetFormatter.with(
92+
() -> SpreadsheetFormatterSharedToString.with(
9893
FORMATTER,
9994
null
10095
)
@@ -105,7 +100,7 @@ public void testWithNullToStringFails() {
105100
public void testWithToStringSameToString() {
106101
assertSame(
107102
FORMATTER,
108-
ToStringSpreadsheetFormatter.with(
103+
SpreadsheetFormatterSharedToString.with(
109104
FORMATTER,
110105
FORMATTER.toString()
111106
)
@@ -114,10 +109,10 @@ public void testWithToStringSameToString() {
114109

115110
@Test
116111
public void testWithToStringSameToString2() {
117-
final ToStringSpreadsheetFormatter formatter = this.createFormatter();
112+
final SpreadsheetFormatterSharedToString formatter = this.createFormatter();
118113
assertSame(
119114
formatter,
120-
ToStringSpreadsheetFormatter.with(
115+
SpreadsheetFormatterSharedToString.with(
121116
formatter,
122117
formatter.toString()
123118
)
@@ -126,11 +121,11 @@ public void testWithToStringSameToString2() {
126121

127122
@Test
128123
public void testWithToStringSpreadsheetFormatterUnwraps() {
129-
final ToStringSpreadsheetFormatter formatter = this.createFormatter();
124+
final SpreadsheetFormatterSharedToString formatter = this.createFormatter();
130125

131126
assertSame(
132127
formatter,
133-
ToStringSpreadsheetFormatter.with(
128+
SpreadsheetFormatterSharedToString.with(
134129
formatter,
135130
FORMATTER.toString()
136131
)
@@ -155,9 +150,9 @@ public void testTokens() {
155150
}
156151

157152
@Override
158-
public ToStringSpreadsheetFormatter createFormatter() {
159-
return (ToStringSpreadsheetFormatter)
160-
ToStringSpreadsheetFormatter.with(
153+
public SpreadsheetFormatterSharedToString createFormatter() {
154+
return (SpreadsheetFormatterSharedToString)
155+
SpreadsheetFormatterSharedToString.with(
161156
FORMATTER,
162157
TO_STRING
163158
);
@@ -178,7 +173,7 @@ public Object value() {
178173
@Test
179174
public void testEqualsDifferentFormatter() {
180175
this.checkNotEquals(
181-
ToStringSpreadsheetFormatter.with(
176+
SpreadsheetFormatterSharedToString.with(
182177
SpreadsheetFormatters.fake(),
183178
TO_STRING
184179
)
@@ -188,15 +183,15 @@ public void testEqualsDifferentFormatter() {
188183
@Test
189184
public void testEqualsDifferentToString() {
190185
this.checkNotEquals(
191-
ToStringSpreadsheetFormatter.with(
186+
SpreadsheetFormatterSharedToString.with(
192187
FORMATTER,
193188
"DifferentToString"
194189
)
195190
);
196191
}
197192

198193
@Override
199-
public ToStringSpreadsheetFormatter createObject() {
194+
public SpreadsheetFormatterSharedToString createObject() {
200195
return this.createFormatter();
201196
}
202197

@@ -216,20 +211,15 @@ public void testToString() {
216211
public void testTreePrintable() {
217212
this.treePrintAndCheck(
218213
this.createFormatter(),
219-
"ToStringSpreadsheetFormatter\n" +
220-
" TestSpreadsheetFormatter (walkingkooka.spreadsheet.format.ToStringSpreadsheetFormatterTest$1)\n"
214+
"SpreadsheetFormatterSharedToString\n" +
215+
" TestSpreadsheetFormatter (walkingkooka.spreadsheet.format.SpreadsheetFormatterSharedToStringTest$1)\n"
221216
);
222217
}
223218

224219
// Class............................................................................................................
225220

226221
@Override
227-
public Class<ToStringSpreadsheetFormatter> type() {
228-
return ToStringSpreadsheetFormatter.class;
229-
}
230-
231-
@Override
232-
public JavaVisibility typeVisibility() {
233-
return JavaVisibility.PACKAGE_PRIVATE;
222+
public Class<SpreadsheetFormatterSharedToString> type() {
223+
return SpreadsheetFormatterSharedToString.class;
234224
}
235225
}

0 commit comments

Comments
 (0)