Skip to content
Merged
Show file tree
Hide file tree
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
Expand Up @@ -31,10 +31,10 @@
/**
* A {@link SpreadsheetFormatter} that forms a collection trying each {@link SpreadsheetFormatter formatter} until success.
*/
final class SpreadsheetFormatterCollection implements SpreadsheetFormatter {
final class SpreadsheetFormatterSharedCollection extends SpreadsheetFormatterShared {

/**
* Creates a new {@link SpreadsheetFormatterCollection} as necessary.
* Creates a new {@link SpreadsheetFormatterSharedCollection} as necessary.
*/
static SpreadsheetFormatter with(final List<SpreadsheetFormatter> formatters) {
Objects.requireNonNull(formatters, "formatters");
Expand All @@ -49,7 +49,7 @@ static SpreadsheetFormatter with(final List<SpreadsheetFormatter> formatters) {
result = copy.iterator().next();
break;
default:
result = new SpreadsheetFormatterCollection(copy);
result = new SpreadsheetFormatterSharedCollection(copy);
break;
}

Expand All @@ -59,7 +59,7 @@ static SpreadsheetFormatter with(final List<SpreadsheetFormatter> formatters) {
/**
* Private ctor.
*/
private SpreadsheetFormatterCollection(final List<SpreadsheetFormatter> formatters) {
private SpreadsheetFormatterSharedCollection(final List<SpreadsheetFormatter> formatters) {
super();
this.formatters = formatters;
}
Expand Down Expand Up @@ -104,11 +104,11 @@ public int hashCode() {
@Override
public boolean equals(final Object other) {
return this == other ||
other instanceof SpreadsheetFormatterCollection &&
other instanceof SpreadsheetFormatterSharedCollection &&
this.equals0(Cast.to(other));
}

private boolean equals0(final SpreadsheetFormatterCollection other) {
private boolean equals0(final SpreadsheetFormatterSharedCollection other) {
return this.formatters.equals(other.formatters);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ public static SpreadsheetFormatter badgeError(final SpreadsheetFormatter formatt
}

/**
* {@see SpreadsheetFormatterCollection}
* {@see SpreadsheetFormatterSharedCollection}
*/
public static SpreadsheetFormatter collection(final List<SpreadsheetFormatter> formatters) {
return SpreadsheetFormatterCollection.with(formatters);
return SpreadsheetFormatterSharedCollection.with(formatters);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertThrows;

public final class SpreadsheetFormatterCollectionTest implements SpreadsheetFormatterTesting2<SpreadsheetFormatterCollection>,
HashCodeEqualsDefinedTesting2<SpreadsheetFormatterCollection> {
public final class SpreadsheetFormatterSharedCollectionTest extends SpreadsheetFormatterSharedTestCase<SpreadsheetFormatterSharedCollection>
implements HashCodeEqualsDefinedTesting2<SpreadsheetFormatterSharedCollection> {

private final static Integer VALUE1 = 11;
private final static Double VALUE2 = 222.5;
Expand All @@ -43,22 +43,22 @@ public final class SpreadsheetFormatterCollectionTest implements SpreadsheetForm
public void testWithNullFails() {
assertThrows(
NullPointerException.class,
() -> SpreadsheetFormatterCollection.with(null)
() -> SpreadsheetFormatterSharedCollection.with(null)
);
}

@Test
public void testWithEmptyFails() {
assertThrows(
IllegalArgumentException.class,
() -> SpreadsheetFormatterCollection.with(Lists.empty())
() -> SpreadsheetFormatterSharedCollection.with(Lists.empty())
);
}

@Test
public void testWithOneUnwraps() {
final SpreadsheetFormatter formatter = SpreadsheetFormatters.fake();
assertSame(formatter, SpreadsheetFormatterCollection.with(Lists.of(formatter)));
assertSame(formatter, SpreadsheetFormatterSharedCollection.with(Lists.of(formatter)));
}

// format...........................................................................................................
Expand All @@ -82,9 +82,9 @@ public void testFormatNull() {
}

@Override
public SpreadsheetFormatterCollection createFormatter() {
public SpreadsheetFormatterSharedCollection createFormatter() {
return Cast.to(
SpreadsheetFormatterCollection.with(
SpreadsheetFormatterSharedCollection.with(
Lists.of(
this.formatter1(),
this.formatter2()
Expand Down Expand Up @@ -149,13 +149,13 @@ public void testTokens() {
@Test
public void testEqualsDifferentFormatters() {
this.checkNotEquals(
SpreadsheetFormatterCollection.with(
SpreadsheetFormatterSharedCollection.with(
Lists.of(
this.formatter1(),
this.formatter2()
)
),
SpreadsheetFormatterCollection.with(
SpreadsheetFormatterSharedCollection.with(
Lists.of(
this.formatter1()
)
Expand All @@ -164,9 +164,9 @@ public void testEqualsDifferentFormatters() {
}

@Override
public SpreadsheetFormatterCollection createObject() {
return (SpreadsheetFormatterCollection)
SpreadsheetFormatterCollection.with(
public SpreadsheetFormatterSharedCollection createObject() {
return (SpreadsheetFormatterSharedCollection)
SpreadsheetFormatterSharedCollection.with(
Lists.of(
SpreadsheetFormatters.defaultText(),
SpreadsheetFormatters.defaultText()
Expand All @@ -187,8 +187,8 @@ public void testToString() {
// class............................................................................................................

@Override
public Class<SpreadsheetFormatterCollection> type() {
return SpreadsheetFormatterCollection.class;
public Class<SpreadsheetFormatterSharedCollection> type() {
return SpreadsheetFormatterSharedCollection.class;
}

@Override
Expand Down
Loading