Better format some stream usage

This commit is contained in:
Nik Everett 2015-09-24 13:53:05 -04:00
parent a4f709c6b8
commit f8fa00185f
2 changed files with 12 additions and 4 deletions

View File

@ -64,11 +64,15 @@ public class ClusterBlocks extends AbstractDiffable<ClusterBlocks> {
levelHolders = new ImmutableLevelHolder[ClusterBlockLevel.values().length];
for (final ClusterBlockLevel level : ClusterBlockLevel.values()) {
Predicate<ClusterBlock> containsLevel = block -> block.contains(level);
Set<ClusterBlock> newGlobal = unmodifiableSet(global.stream().filter(containsLevel).collect(toSet()));
Set<ClusterBlock> newGlobal = unmodifiableSet(global.stream()
.filter(containsLevel)
.collect(toSet()));
ImmutableMap.Builder<String, Set<ClusterBlock>> indicesBuilder = ImmutableMap.builder();
for (Map.Entry<String, Set<ClusterBlock>> entry : indicesBlocks.entrySet()) {
indicesBuilder.put(entry.getKey(), unmodifiableSet(entry.getValue().stream().filter(containsLevel).collect(toSet())));
indicesBuilder.put(entry.getKey(), unmodifiableSet(entry.getValue().stream()
.filter(containsLevel)
.collect(toSet())));
}
levelHolders[level.id()] = new ImmutableLevelHolder(newGlobal, indicesBuilder.build());
@ -187,7 +191,9 @@ public class ClusterBlocks extends AbstractDiffable<ClusterBlocks> {
return null;
}
Function<String, Stream<ClusterBlock>> blocksForIndexAtLevel = index -> blocksForIndex(level, index).stream();
Stream<ClusterBlock> blocks = concat(global(level).stream(), Stream.of(indices).flatMap(blocksForIndexAtLevel));
Stream<ClusterBlock> blocks = concat(
global(level).stream(),
Stream.of(indices).flatMap(blocksForIndexAtLevel));
return new ClusterBlockException(unmodifiableSet(blocks.collect(toSet())));
}

View File

@ -116,6 +116,8 @@ class MembersInjectorImpl<T> implements MembersInjector<T> {
}
public Set<InjectionPoint> getInjectionPoints() {
return unmodifiableSet(memberInjectors.stream().map(SingleMemberInjector::getInjectionPoint).collect(toSet()));
return unmodifiableSet(memberInjectors.stream()
.map(SingleMemberInjector::getInjectionPoint)
.collect(toSet()));
}
}