parent
7a8aaeb634
commit
9fe9423b1d
@ -0,0 +1,42 @@
|
||||
package com.luoo.music.config;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class SaticScheduleTaskTest {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
Map<String, Set<String>> map1=new HashMap<>();
|
||||
map1.put("1", Arrays.asList("1","11").stream().collect(Collectors.toSet()));
|
||||
map1.put("2", Arrays.asList("2","22").stream().collect(Collectors.toSet()));
|
||||
|
||||
Map<String, Set<String>> map2=new HashMap<>();
|
||||
map2.put("1", Arrays.asList("2_1","2_11").stream().collect(Collectors.toSet()));
|
||||
map2.put("2", Arrays.asList("2_2","2_22").stream().collect(Collectors.toSet()));
|
||||
|
||||
Stream<Entry<String, Set<String>>> journalSongStream = map1.entrySet().stream();
|
||||
|
||||
Stream<Entry<String, Set<String>>> journalStream = map2.entrySet().stream();
|
||||
|
||||
Map<String, List<Entry<String, Set<String>>>> map = Stream.concat(journalSongStream, journalStream)
|
||||
.collect(Collectors.groupingBy(e -> e.getKey()));
|
||||
|
||||
map.entrySet().forEach(e -> {
|
||||
List<String> value = e.getValue().stream().flatMap(a -> a.getValue().stream()).distinct().sorted()
|
||||
.collect(Collectors.toList());
|
||||
System.out.println(value.stream().collect(Collectors.joining(",")));
|
||||
});
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue