mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Fix checkstyle errors
This commit is contained in:
parent
8b9d39dbb8
commit
cb67595f5b
|
@ -19,7 +19,6 @@ import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.DoubleSummaryStatistics;
|
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -35,8 +34,6 @@ import java.util.function.Supplier;
|
||||||
import java.util.function.ToDoubleFunction;
|
import java.util.function.ToDoubleFunction;
|
||||||
import java.util.function.ToIntFunction;
|
import java.util.function.ToIntFunction;
|
||||||
import java.util.function.ToLongFunction;
|
import java.util.function.ToLongFunction;
|
||||||
import java.util.stream.Collector;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import org.teavm.classlib.java.util.TDoubleSummaryStatistics;
|
import org.teavm.classlib.java.util.TDoubleSummaryStatistics;
|
||||||
import org.teavm.classlib.java.util.TIntSummaryStatistics;
|
import org.teavm.classlib.java.util.TIntSummaryStatistics;
|
||||||
import org.teavm.classlib.java.util.TLongSummaryStatistics;
|
import org.teavm.classlib.java.util.TLongSummaryStatistics;
|
||||||
|
@ -105,7 +102,7 @@ public final class TCollectors {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
(m1, m2) -> {
|
(m1, m2) -> {
|
||||||
for (Map.Entry<K, V> e : m2.entrySet()) {
|
for (var e : m2.entrySet()) {
|
||||||
V newV = TObjects.requireNonNull(e.getValue());
|
V newV = TObjects.requireNonNull(e.getValue());
|
||||||
V oldV = m1.putIfAbsent(e.getKey(), newV);
|
V oldV = m1.putIfAbsent(e.getKey(), newV);
|
||||||
if (oldV != null) {
|
if (oldV != null) {
|
||||||
|
@ -128,7 +125,7 @@ public final class TCollectors {
|
||||||
return TCollector.of(mapFactory,
|
return TCollector.of(mapFactory,
|
||||||
(map, el) -> map.merge(keyMapper.apply(el), valueMapper.apply(el), mergeFunction),
|
(map, el) -> map.merge(keyMapper.apply(el), valueMapper.apply(el), mergeFunction),
|
||||||
(m1, m2) -> {
|
(m1, m2) -> {
|
||||||
for (Map.Entry<K, V> e : m2.entrySet()) {
|
for (var e : m2.entrySet()) {
|
||||||
m1.merge(e.getKey(), e.getValue(), mergeFunction);
|
m1.merge(e.getKey(), e.getValue(), mergeFunction);
|
||||||
}
|
}
|
||||||
return m1;
|
return m1;
|
||||||
|
@ -156,7 +153,7 @@ public final class TCollectors {
|
||||||
downstream.accumulator().accept(container, t);
|
downstream.accumulator().accept(container, t);
|
||||||
};
|
};
|
||||||
BinaryOperator<Map<K, I>> mapMerger = (m1, m2) -> {
|
BinaryOperator<Map<K, I>> mapMerger = (m1, m2) -> {
|
||||||
for (Map.Entry<K, I> e : m2.entrySet()) {
|
for (var e : m2.entrySet()) {
|
||||||
m1.merge(e.getKey(), e.getValue(), downstream.combiner());
|
m1.merge(e.getKey(), e.getValue(), downstream.combiner());
|
||||||
}
|
}
|
||||||
return m1;
|
return m1;
|
||||||
|
@ -169,7 +166,9 @@ public final class TCollectors {
|
||||||
Function<I, I> replacer = castFunction(downstream.finisher());
|
Function<I, I> replacer = castFunction(downstream.finisher());
|
||||||
Function<Map<K, I>, M> finisher = toReplace -> {
|
Function<Map<K, I>, M> finisher = toReplace -> {
|
||||||
toReplace.replaceAll((k, v) -> replacer.apply(v));
|
toReplace.replaceAll((k, v) -> replacer.apply(v));
|
||||||
return (M) toReplace;
|
@SuppressWarnings("unchecked")
|
||||||
|
var result = (M) toReplace;
|
||||||
|
return result;
|
||||||
};
|
};
|
||||||
return TCollector.of(castFactory(mapFactory), mapAppender, mapMerger, finisher);
|
return TCollector.of(castFactory(mapFactory), mapAppender, mapMerger, finisher);
|
||||||
}
|
}
|
||||||
|
@ -189,7 +188,7 @@ public final class TCollectors {
|
||||||
TCollector<T, A, R> downstream,
|
TCollector<T, A, R> downstream,
|
||||||
Function<R, K> finisher) {
|
Function<R, K> finisher) {
|
||||||
|
|
||||||
EnumSet<TCollector.Characteristics> newCharacteristics = EnumSet.copyOf(downstream.characteristics());
|
var newCharacteristics = EnumSet.copyOf(downstream.characteristics());
|
||||||
newCharacteristics.remove(TCollector.Characteristics.IDENTITY_FINISH);
|
newCharacteristics.remove(TCollector.Characteristics.IDENTITY_FINISH);
|
||||||
|
|
||||||
return new TCollectorImpl<>(downstream.supplier(),
|
return new TCollectorImpl<>(downstream.supplier(),
|
||||||
|
@ -299,21 +298,36 @@ public final class TCollectors {
|
||||||
return TCollector.of(
|
return TCollector.of(
|
||||||
TIntSummaryStatistics::new,
|
TIntSummaryStatistics::new,
|
||||||
(r, t) -> r.accept(mapper.applyAsInt(t)),
|
(r, t) -> r.accept(mapper.applyAsInt(t)),
|
||||||
(l, r) -> { l.combine(r); return l; }, TCollector.Characteristics.IDENTITY_FINISH);
|
(l, r) -> {
|
||||||
|
l.combine(r);
|
||||||
|
return l;
|
||||||
|
},
|
||||||
|
TCollector.Characteristics.IDENTITY_FINISH
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> TCollector<T, ?, TLongSummaryStatistics> summarizingLong(ToLongFunction<? super T> mapper) {
|
public static <T> TCollector<T, ?, TLongSummaryStatistics> summarizingLong(ToLongFunction<? super T> mapper) {
|
||||||
return TCollector.of(
|
return TCollector.of(
|
||||||
TLongSummaryStatistics::new,
|
TLongSummaryStatistics::new,
|
||||||
(r, t) -> r.accept(mapper.applyAsLong(t)),
|
(r, t) -> r.accept(mapper.applyAsLong(t)),
|
||||||
(l, r) -> { l.combine(r); return l; }, TCollector.Characteristics.IDENTITY_FINISH);
|
(l, r) -> {
|
||||||
|
l.combine(r);
|
||||||
|
return l;
|
||||||
|
},
|
||||||
|
TCollector.Characteristics.IDENTITY_FINISH
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> TCollector<T, ?, TDoubleSummaryStatistics> summarizingDouble(ToDoubleFunction<? super T> mapper) {
|
public static <T> TCollector<T, ?, TDoubleSummaryStatistics> summarizingDouble(ToDoubleFunction<? super T> mapper) {
|
||||||
return TCollector.of(
|
return TCollector.of(
|
||||||
TDoubleSummaryStatistics::new,
|
TDoubleSummaryStatistics::new,
|
||||||
(r, t) -> r.accept(mapper.applyAsDouble(t)),
|
(r, t) -> r.accept(mapper.applyAsDouble(t)),
|
||||||
(l, r) -> { l.combine(r); return l; }, TCollector.Characteristics.IDENTITY_FINISH);
|
(l, r) -> {
|
||||||
|
l.combine(r);
|
||||||
|
return l;
|
||||||
|
},
|
||||||
|
TCollector.Characteristics.IDENTITY_FINISH
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T, A1, A2, R1, R2, R> TCollector<T, ?, R> teeingUnwrap(TCollector<? super T, A1, R1> left,
|
private static <T, A1, A2, R1, R2, R> TCollector<T, ?, R> teeingUnwrap(TCollector<? super T, A1, R1> left,
|
||||||
|
|
|
@ -61,7 +61,9 @@
|
||||||
<module name="MethodName">
|
<module name="MethodName">
|
||||||
<property name="format" value="^(([A-Z][A-Z0-9]+)|([a-z][a-z0-9]*))([A-Z][a-z0-9]*)*"/>
|
<property name="format" value="^(([A-Z][A-Z0-9]+)|([a-z][a-z0-9]*))([A-Z][a-z0-9]*)*"/>
|
||||||
</module>
|
</module>
|
||||||
<module name="MethodTypeParameterName"/>
|
<module name="MethodTypeParameterName">
|
||||||
|
<property name="format" value="^[A-Z][A-Z0-9]*$"/>
|
||||||
|
</module>
|
||||||
<module name="PackageName"/>
|
<module name="PackageName"/>
|
||||||
<module name="ParameterName"/>
|
<module name="ParameterName"/>
|
||||||
<module name="StaticVariableName"/>
|
<module name="StaticVariableName"/>
|
||||||
|
|
|
@ -22,9 +22,7 @@ import java.util.Comparator;
|
||||||
import java.util.DoubleSummaryStatistics;
|
import java.util.DoubleSummaryStatistics;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.IntSummaryStatistics;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.LongSummaryStatistics;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
@ -34,8 +32,10 @@ import java.util.stream.Stream;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.teavm.junit.TeaVMTestRunner;
|
import org.teavm.junit.TeaVMTestRunner;
|
||||||
|
import org.teavm.junit.WholeClassCompilation;
|
||||||
|
|
||||||
@RunWith(TeaVMTestRunner.class)
|
@RunWith(TeaVMTestRunner.class)
|
||||||
|
@WholeClassCompilation
|
||||||
public class CollectorsTest {
|
public class CollectorsTest {
|
||||||
@Test
|
@Test
|
||||||
public void joining() {
|
public void joining() {
|
||||||
|
@ -120,15 +120,15 @@ public class CollectorsTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void summaryInt() {
|
public void summaryInt() {
|
||||||
assertEquals(Integer.valueOf(6), Stream.of("a", "bb", "ccc").collect(Collectors.summingInt(String::length)));
|
assertEquals(6L, (int) Stream.of("a", "bb", "ccc").collect(Collectors.summingInt(String::length)));
|
||||||
assertEquals(Double.valueOf(2.0), Stream.of("a", "bb", "ccc").collect(Collectors.averagingInt(String::length)));
|
assertEquals(2.0, Stream.of("a", "bb", "ccc").collect(Collectors.averagingInt(String::length)), 0.001);
|
||||||
IntSummaryStatistics statistics = Stream.of("a", "bb", "ccc").collect(Collectors.summarizingInt(String::length));
|
var statistics = Stream.of("a", "bb", "ccc").collect(Collectors.summarizingInt(String::length));
|
||||||
assertEquals(3L, statistics.getCount());
|
assertEquals(3L, statistics.getCount());
|
||||||
assertEquals(2.0, statistics.getAverage(), 0.0);
|
assertEquals(2.0, statistics.getAverage(), 0.0);
|
||||||
assertEquals(1, statistics.getMin());
|
assertEquals(1, statistics.getMin());
|
||||||
assertEquals(3, statistics.getMax());
|
assertEquals(3, statistics.getMax());
|
||||||
assertEquals(6L, statistics.getSum());
|
assertEquals(6L, statistics.getSum());
|
||||||
IntSummaryStatistics empty = Stream.<String>of().collect(Collectors.summarizingInt(String::length));
|
var empty = Stream.<String>of().collect(Collectors.summarizingInt(String::length));
|
||||||
assertEquals(0L, empty.getCount());
|
assertEquals(0L, empty.getCount());
|
||||||
assertEquals(0.0, empty.getAverage(), 0.0);
|
assertEquals(0.0, empty.getAverage(), 0.0);
|
||||||
assertEquals(Integer.MAX_VALUE, empty.getMin());
|
assertEquals(Integer.MAX_VALUE, empty.getMin());
|
||||||
|
@ -138,15 +138,15 @@ public class CollectorsTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void summaryLong() {
|
public void summaryLong() {
|
||||||
assertEquals(Long.valueOf(6L), Stream.of("a", "bb", "ccc").collect(Collectors.summingLong(String::length)));
|
assertEquals(6L, (long) Stream.of("a", "bb", "ccc").collect(Collectors.summingLong(String::length)));
|
||||||
assertEquals(Double.valueOf(2.0), Stream.of("a", "bb", "ccc").collect(Collectors.averagingLong(String::length)));
|
assertEquals(2.0, Stream.of("a", "bb", "ccc").collect(Collectors.averagingLong(String::length)), 0.001);
|
||||||
LongSummaryStatistics statistics = Stream.of("a", "bb", "ccc").collect(Collectors.summarizingLong(String::length));
|
var statistics = Stream.of("a", "bb", "ccc").collect(Collectors.summarizingLong(String::length));
|
||||||
assertEquals(3L, statistics.getCount());
|
assertEquals(3L, statistics.getCount());
|
||||||
assertEquals(2.0, statistics.getAverage(), 0.0);
|
assertEquals(2.0, statistics.getAverage(), 0.0);
|
||||||
assertEquals(1L, statistics.getMin());
|
assertEquals(1L, statistics.getMin());
|
||||||
assertEquals(3L, statistics.getMax());
|
assertEquals(3L, statistics.getMax());
|
||||||
assertEquals(6L, statistics.getSum());
|
assertEquals(6L, statistics.getSum());
|
||||||
LongSummaryStatistics empty = Stream.<String>of().collect(Collectors.summarizingLong(String::length));
|
var empty = Stream.<String>of().collect(Collectors.summarizingLong(String::length));
|
||||||
assertEquals(0L, empty.getCount());
|
assertEquals(0L, empty.getCount());
|
||||||
assertEquals(0.0, empty.getAverage(), 0.0);
|
assertEquals(0.0, empty.getAverage(), 0.0);
|
||||||
assertEquals(Long.MAX_VALUE, empty.getMin());
|
assertEquals(Long.MAX_VALUE, empty.getMin());
|
||||||
|
@ -156,9 +156,9 @@ public class CollectorsTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void summaryDouble() {
|
public void summaryDouble() {
|
||||||
assertEquals(Double.valueOf(6.0), Stream.of("a", "bb", "ccc").collect(Collectors.summingDouble(String::length)));
|
assertEquals(6.0, Stream.of("a", "bb", "ccc").collect(Collectors.summingDouble(String::length)), 0.001);
|
||||||
assertEquals(Double.valueOf(2.0), Stream.of("a", "bb", "ccc").collect(Collectors.averagingDouble(String::length)));
|
assertEquals(2.0, Stream.of("a", "bb", "ccc").collect(Collectors.averagingDouble(String::length)), 0.001);
|
||||||
DoubleSummaryStatistics statistics = Stream.of("a", "bb", "ccc").collect(Collectors.summarizingDouble(String::length));
|
var statistics = Stream.of("a", "bb", "ccc").collect(Collectors.summarizingDouble(String::length));
|
||||||
assertEquals(3L, statistics.getCount());
|
assertEquals(3L, statistics.getCount());
|
||||||
assertEquals(2.0, statistics.getAverage(), 0.0);
|
assertEquals(2.0, statistics.getAverage(), 0.0);
|
||||||
assertEquals(1.0, statistics.getMin(), 0.0);
|
assertEquals(1.0, statistics.getMin(), 0.0);
|
||||||
|
@ -174,7 +174,8 @@ public class CollectorsTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void teeing() {
|
public void teeing() {
|
||||||
assertEquals(Double.valueOf(3.0d), Stream.of("a", "bb", "ccc").collect(Collectors.teeing(Collectors.summingInt(String::length),
|
assertEquals(Double.valueOf(3.0d), Stream.of("a", "bb", "ccc")
|
||||||
|
.collect(Collectors.teeing(Collectors.summingInt(String::length),
|
||||||
Collectors.averagingInt(String::length), (sum, avg) -> sum / avg)));
|
Collectors.averagingInt(String::length), (sum, avg) -> sum / avg)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user