Skip to content

Commit

Permalink
Polish some Map operations
Browse files Browse the repository at this point in the history
  • Loading branch information
dreis2211 authored and snicoll committed Nov 6, 2018
1 parent 804f647 commit 3e95af2
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -102,9 +102,9 @@ public Map<String, Integer> getStatusMapping() {
public int mapStatus(Status status) {
String code = getUniformValue(status.getCode());
if (code != null) {
return this.statusMapping.keySet().stream()
.filter((key) -> code.equals(getUniformValue(key)))
.map(this.statusMapping::get).findFirst()
return this.statusMapping.entrySet().stream()
.filter((entry) -> code.equals(getUniformValue(entry.getKey())))
.map(Map.Entry::getValue).findFirst()
.orElse(WebEndpointResponse.STATUS_OK);
}
return WebEndpointResponse.STATUS_OK;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ public static final class SessionsReport {
private final List<SessionDescriptor> sessions;

public SessionsReport(Map<String, ? extends Session> sessions) {
this.sessions = sessions.entrySet().stream()
.map((s) -> new SessionDescriptor(s.getValue()))
this.sessions = sessions.values().stream().map(SessionDescriptor::new)
.collect(Collectors.toList());
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -85,7 +85,7 @@ public void exceptionTranslationPostProcessorCanBeDisabled() {
this.context.refresh();
Map<String, PersistenceExceptionTranslationPostProcessor> beans = this.context
.getBeansOfType(PersistenceExceptionTranslationPostProcessor.class);
assertThat(beans.entrySet()).isEmpty();
assertThat(beans).isEmpty();
}

@Test(expected = IllegalArgumentException.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ private boolean hasKnownBindableProperties(ConfigurationPropertyName name,
private <T> boolean bind(BeanPropertyBinder propertyBinder, Bean<T> bean,
BeanSupplier<T> beanSupplier) {
boolean bound = false;
for (Map.Entry<String, BeanProperty> entry : bean.getProperties().entrySet()) {
bound |= bind(beanSupplier, propertyBinder, entry.getValue());
for (BeanProperty beanProperty : bean.getProperties().values()) {
bound |= bind(beanSupplier, propertyBinder, beanProperty);
}
return bound;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ public void bindToImmutableMapShouldReturnPopulatedMap() {
.withExistingValue(Collections.singletonMap("a", "b")))
.get();
assertThat(result).hasSize(3);
assertThat(result.entrySet()).containsExactly(entry("a", "b"), entry("c", "d"),
assertThat(result).containsExactly(entry("a", "b"), entry("c", "d"),
entry("e", "f"));
}

Expand Down

0 comments on commit 3e95af2

Please sign in to comment.