Committed by
Gerrit Code Review
Stop using explicit Optional#get()
Change-Id: Ifd14b02fad398d9a84c95328fcd0e8367d63cf33
Showing
2 changed files
with
2 additions
and
7 deletions
| ... | @@ -205,9 +205,7 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour | ... | @@ -205,9 +205,7 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour |
| 205 | // Extract Discrete instances from resources | 205 | // Extract Discrete instances from resources |
| 206 | List<Resource> resources = ids.stream() | 206 | List<Resource> resources = ids.stream() |
| 207 | .filter(x -> x.parent().isPresent()) | 207 | .filter(x -> x.parent().isPresent()) |
| 208 | - .map(x -> lookup(childTxMap, x)) | 208 | + .flatMap(x -> Tools.stream(lookup(childTxMap, x))) |
| 209 | - .filter(Optional::isPresent) | ||
| 210 | - .map(Optional::get) | ||
| 211 | .collect(Collectors.toList()); | 209 | .collect(Collectors.toList()); |
| 212 | // the order is preserved by LinkedHashMap | 210 | // the order is preserved by LinkedHashMap |
| 213 | Map<DiscreteResourceId, List<Resource>> resourceMap = resources.stream() | 211 | Map<DiscreteResourceId, List<Resource>> resourceMap = resources.stream() | ... | ... |
| ... | @@ -21,7 +21,6 @@ import static org.slf4j.LoggerFactory.getLogger; | ... | @@ -21,7 +21,6 @@ import static org.slf4j.LoggerFactory.getLogger; |
| 21 | import java.io.File; | 21 | import java.io.File; |
| 22 | import java.util.List; | 22 | import java.util.List; |
| 23 | import java.util.Map; | 23 | import java.util.Map; |
| 24 | -import java.util.Optional; | ||
| 25 | import java.util.Set; | 24 | import java.util.Set; |
| 26 | import java.util.concurrent.CompletableFuture; | 25 | import java.util.concurrent.CompletableFuture; |
| 27 | import java.util.stream.Collectors; | 26 | import java.util.stream.Collectors; |
| ... | @@ -150,9 +149,7 @@ public class PartitionManager extends AbstractListenerManager<PartitionEvent, Pa | ... | @@ -150,9 +149,7 @@ public class PartitionManager extends AbstractListenerManager<PartitionEvent, Pa |
| 150 | public List<PartitionInfo> partitionInfo() { | 149 | public List<PartitionInfo> partitionInfo() { |
| 151 | return partitions.values() | 150 | return partitions.values() |
| 152 | .stream() | 151 | .stream() |
| 153 | - .map(StoragePartition::info) | 152 | + .flatMap(x -> Tools.stream(x.info())) |
| 154 | - .filter(Optional::isPresent) | ||
| 155 | - .map(Optional::get) | ||
| 156 | .collect(Collectors.toList()); | 153 | .collect(Collectors.toList()); |
| 157 | } | 154 | } |
| 158 | } | 155 | } | ... | ... |
-
Please register or login to post a comment