Skip to content

Commit

Permalink
Rename compose method to avoid compile warnings
Browse files Browse the repository at this point in the history
The use of the same name for the compose function generated a
'potentially ambiguous' compile warning.
  • Loading branch information
aherbert committed Aug 18, 2024
1 parent 7dc1343 commit 2ed8d31
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,8 @@ private static <R, S, T> T create(BiFunction<R, S, T> constructor, R r, S s) {
this.sumOfSquares = sumOfSquares;
this.sumOfLogs = sumOfLogs;
this.config = config;
consumer = Statistics.compose(min, max, moment, sum, product, sumOfSquares, sumOfLogs);
consumer = Statistics.composeDoubleConsumers(min, max, moment, sum, product,
sumOfSquares, sumOfLogs);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ private static <T> T create(Function<int[], T> constructor, int[] values) {
this.config = config;
// The final consumer should never be null as the builder is created
// with at least one statistic.
consumer = Statistics.compose(min, max, sum, sumOfSquares,
composeAsInt(moment, product, sumOfLogs));
consumer = Statistics.composeIntConsumers(min, max, sum, sumOfSquares,
composeAsInt(moment, product, sumOfLogs));
}

/**
Expand All @@ -260,7 +260,7 @@ private static <T> T create(Function<int[], T> constructor, int[] values) {
* @return a composed consumer (or null)
*/
private static IntConsumer composeAsInt(DoubleConsumer... consumers) {
final DoubleConsumer c = Statistics.compose(consumers);
final DoubleConsumer c = Statistics.composeDoubleConsumers(consumers);
if (c != null) {
return c::accept;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ private static <T> T create(Function<long[], T> constructor, long[] values) {
this.config = config;
// The final consumer should never be null as the builder is created
// with at least one statistic.
consumer = Statistics.compose(min, max, sum, sumOfSquares,
composeAsLong(moment, product, sumOfLogs));
consumer = Statistics.composeLongConsumers(min, max, sum, sumOfSquares,
composeAsLong(moment, product, sumOfLogs));
}

/**
Expand All @@ -260,7 +260,7 @@ private static <T> T create(Function<long[], T> constructor, long[] values) {
* @return a composed consumer (or null)
*/
private static LongConsumer composeAsLong(DoubleConsumer... consumers) {
final DoubleConsumer c = Statistics.compose(consumers);
final DoubleConsumer c = Statistics.composeDoubleConsumers(consumers);
if (c != null) {
return c::accept;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ static boolean zeroVariance(double m1, double m2) {
* @param consumers Consumers.
* @return a composed consumer (or null)
*/
static DoubleConsumer compose(DoubleConsumer... consumers) {
static DoubleConsumer composeDoubleConsumers(DoubleConsumer... consumers) {
DoubleConsumer action = DOUBLE_NOOP;
for (final DoubleConsumer consumer : consumers) {
if (consumer != null) {
Expand All @@ -195,7 +195,7 @@ static DoubleConsumer compose(DoubleConsumer... consumers) {
* @param consumers Consumers.
* @return a composed consumer (or null)
*/
static IntConsumer compose(IntConsumer... consumers) {
static IntConsumer composeIntConsumers(IntConsumer... consumers) {
IntConsumer action = INT_NOOP;
for (final IntConsumer consumer : consumers) {
if (consumer != null) {
Expand All @@ -212,7 +212,7 @@ static IntConsumer compose(IntConsumer... consumers) {
* @param consumers Consumers.
* @return a composed consumer (or null)
*/
static LongConsumer compose(LongConsumer... consumers) {
static LongConsumer composeLongConsumers(LongConsumer... consumers) {
LongConsumer action = LONG_NOOP;
for (final LongConsumer consumer : consumers) {
if (consumer != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ void testNoOpDoubleConsumer() {

@Test
void testComposeDoubleConsumers() {
Assertions.assertNull(Statistics.compose((DoubleConsumer) null));
Assertions.assertNull(Statistics.compose((DoubleConsumer) null, (DoubleConsumer) null));
Assertions.assertNull(Statistics.composeDoubleConsumers((DoubleConsumer) null));
Assertions.assertNull(Statistics.composeDoubleConsumers((DoubleConsumer) null, (DoubleConsumer) null));
final double[] v1 = {0};
final double[] v2 = {0};
final DoubleConsumer c1 = x -> v1[0] = x;
final DoubleConsumer c2 = x -> v2[0] = x;
final DoubleConsumer combined = Statistics.compose(c1, c2);
final DoubleConsumer combined = Statistics.composeDoubleConsumers(c1, c2);
final double y = 42;
combined.accept(y);
Assertions.assertEquals(y, v1[0]);
Expand All @@ -72,13 +72,13 @@ void testNoOpIntConsumer() {

@Test
void testComposeIntConsumers() {
Assertions.assertNull(Statistics.compose((IntConsumer) null));
Assertions.assertNull(Statistics.compose((IntConsumer) null, (IntConsumer) null));
Assertions.assertNull(Statistics.composeIntConsumers((IntConsumer) null));
Assertions.assertNull(Statistics.composeIntConsumers((IntConsumer) null, (IntConsumer) null));
final int[] v1 = {0};
final int[] v2 = {0};
final IntConsumer c1 = x -> v1[0] = x;
final IntConsumer c2 = x -> v2[0] = x;
final IntConsumer combined = Statistics.compose(c1, c2);
final IntConsumer combined = Statistics.composeIntConsumers(c1, c2);
final int y = 42;
combined.accept(y);
Assertions.assertEquals(y, v1[0]);
Expand All @@ -101,13 +101,13 @@ void testNoOpLongConsumer() {

@Test
void testComposeLongConsumers() {
Assertions.assertNull(Statistics.compose((LongConsumer) null));
Assertions.assertNull(Statistics.compose((LongConsumer) null, (LongConsumer) null));
Assertions.assertNull(Statistics.composeLongConsumers((LongConsumer) null));
Assertions.assertNull(Statistics.composeLongConsumers((LongConsumer) null, (LongConsumer) null));
final long[] v1 = {0};
final long[] v2 = {0};
final LongConsumer c1 = x -> v1[0] = x;
final LongConsumer c2 = x -> v2[0] = x;
final LongConsumer combined = Statistics.compose(c1, c2);
final LongConsumer combined = Statistics.composeLongConsumers(c1, c2);
final long y = 42;
combined.accept(y);
Assertions.assertEquals(y, v1[0]);
Expand Down

0 comments on commit 2ed8d31

Please sign in to comment.