MyTetra Share
Делитесь знаниями!
Collectors
Время создания: 18.03.2021 00:38
Раздел: INFO - Development - GROOVY
Запись: wwwlir/Tetra/master/base/1615999117ow50jzcgwo/text.html на raw.githubusercontent.com

// String printSumForPeriod = sumForPeriod.entrySet().stream()

// .sorted{k1, k2-> k1.getKey().compareTo(k2.getKey())}

// .map{e-> e.getValue() as String}

// .collect(Collectors.toMap({Map.Entry::getKey}, {Map.Entry::getValue, (key, val) -> key, LinkedHashMap::new}))

//// .collect(Collectors.joining("|"))


def printSumForPeriod = sumForPeriod.entrySet().stream()

.sorted{k1, k2-> k1.getKey().compareTo(k2.getKey())}

.collect(Collectors.toMap(

{o1 -> (isFact?'факт ':'норматив ')+df.format(o1.getKey())},

{o2 -> o2.getValue()==null?"null":o2.getValue()},

{oldValue, newValue -> oldValue},

{new LinkedHashMap<>()}))


def test = Stream.of(["4"],["1", "2"], ["3"], ["4", "5"]).peek{e->_(e)}.collect({new ArrayList<>()}, {b, a->b.addAll(a)}, {b, a->b.addAll(a)}).toSet()

 
MyTetra Share v.0.59
Яндекс индекс цитирования