Use lambdas for map entry iteration where possible
See gh-12626
This commit is contained in:
committed by
Phillip Webb
parent
78a94cafe1
commit
69bc19e0ca
@@ -123,15 +123,14 @@ public class ConditionsReportEndpoint {
|
|||||||
this.negativeMatches = new LinkedHashMap<>();
|
this.negativeMatches = new LinkedHashMap<>();
|
||||||
this.exclusions = report.getExclusions();
|
this.exclusions = report.getExclusions();
|
||||||
this.unconditionalClasses = report.getUnconditionalClasses();
|
this.unconditionalClasses = report.getUnconditionalClasses();
|
||||||
for (Map.Entry<String, ConditionAndOutcomes> entry : report
|
report.getConditionAndOutcomesBySource().forEach((key, value) -> {
|
||||||
.getConditionAndOutcomesBySource().entrySet()) {
|
if (value.isFullMatch()) {
|
||||||
if (entry.getValue().isFullMatch()) {
|
add(this.positiveMatches, key, value);
|
||||||
add(this.positiveMatches, entry.getKey(), entry.getValue());
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
add(this.negativeMatches, entry.getKey(), entry.getValue());
|
add(this.negativeMatches, key, value);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
this.parentId = context.getParent() == null ? null
|
this.parentId = context.getParent() == null ? null
|
||||||
: context.getParent().getId();
|
: context.getParent().getId();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,10 +44,7 @@ public abstract class CompositeHealthIndicatorConfiguration<H extends HealthIndi
|
|||||||
}
|
}
|
||||||
CompositeHealthIndicator composite = new CompositeHealthIndicator(
|
CompositeHealthIndicator composite = new CompositeHealthIndicator(
|
||||||
this.healthAggregator);
|
this.healthAggregator);
|
||||||
for (Map.Entry<String, S> entry : beans.entrySet()) {
|
beans.forEach((key, value) -> composite.addHealthIndicator(key, createHealthIndicator(value)));
|
||||||
composite.addHealthIndicator(entry.getKey(),
|
|
||||||
createHealthIndicator(entry.getValue()));
|
|
||||||
}
|
|
||||||
return composite;
|
return composite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,10 +43,7 @@ public abstract class CompositeReactiveHealthIndicatorConfiguration<H extends Re
|
|||||||
}
|
}
|
||||||
CompositeReactiveHealthIndicator composite = new CompositeReactiveHealthIndicator(
|
CompositeReactiveHealthIndicator composite = new CompositeReactiveHealthIndicator(
|
||||||
this.healthAggregator);
|
this.healthAggregator);
|
||||||
for (Map.Entry<String, S> entry : beans.entrySet()) {
|
beans.forEach((key, value) -> composite.addHealthIndicator(key, createHealthIndicator(value)));
|
||||||
composite.addHealthIndicator(entry.getKey(),
|
|
||||||
createHealthIndicator(entry.getValue()));
|
|
||||||
}
|
|
||||||
return composite;
|
return composite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -84,11 +84,11 @@ public class DataSourceHealthIndicatorAutoConfiguration extends
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Map<String, DataSource> dataSources = new LinkedHashMap<>();
|
Map<String, DataSource> dataSources = new LinkedHashMap<>();
|
||||||
for (Map.Entry<String, DataSource> entry : candidates.entrySet()) {
|
candidates.forEach((key, value) -> {
|
||||||
if (!(entry.getValue() instanceof AbstractRoutingDataSource)) {
|
if (!(value instanceof AbstractRoutingDataSource)) {
|
||||||
dataSources.put(entry.getKey(), entry.getValue());
|
dataSources.put(key, value);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
return dataSources;
|
return dataSources;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -120,13 +120,10 @@ public class EnvironmentEndpoint {
|
|||||||
|
|
||||||
private PropertySummaryDescriptor getPropertySummaryDescriptor(
|
private PropertySummaryDescriptor getPropertySummaryDescriptor(
|
||||||
Map<String, PropertyValueDescriptor> descriptors) {
|
Map<String, PropertyValueDescriptor> descriptors) {
|
||||||
for (Map.Entry<String, PropertyValueDescriptor> entry : descriptors.entrySet()) {
|
return descriptors.entrySet().stream().
|
||||||
if (entry.getValue() != null) {
|
filter((entry) -> entry.getValue() != null).
|
||||||
return new PropertySummaryDescriptor(entry.getKey(),
|
map((entry) -> new PropertySummaryDescriptor(entry.getKey(), entry.getValue().getValue())).
|
||||||
entry.getValue().getValue());
|
findFirst().orElse(null);
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, PropertyValueDescriptor> getPropertySourceDescriptors(
|
private Map<String, PropertyValueDescriptor> getPropertySourceDescriptors(
|
||||||
|
|||||||
@@ -142,12 +142,11 @@ class AutoConfigurationSorter {
|
|||||||
public Set<String> getClassesRequestedAfter(String className) {
|
public Set<String> getClassesRequestedAfter(String className) {
|
||||||
Set<String> rtn = new LinkedHashSet<>();
|
Set<String> rtn = new LinkedHashSet<>();
|
||||||
rtn.addAll(get(className).getAfter());
|
rtn.addAll(get(className).getAfter());
|
||||||
for (Map.Entry<String, AutoConfigurationClass> entry : this.classes
|
this.classes.forEach((key, value) -> {
|
||||||
.entrySet()) {
|
if (value.getBefore().contains(className)) {
|
||||||
if (entry.getValue().getBefore().contains(className)) {
|
rtn.add(key);
|
||||||
rtn.add(entry.getKey());
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
return rtn;
|
return rtn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -74,9 +74,9 @@ class ImportAutoConfigurationImportSelector extends AutoConfigurationImportSelec
|
|||||||
AnnotationAttributes attributes) {
|
AnnotationAttributes attributes) {
|
||||||
List<String> candidates = new ArrayList<>();
|
List<String> candidates = new ArrayList<>();
|
||||||
Map<Class<?>, List<Annotation>> annotations = getAnnotations(metadata);
|
Map<Class<?>, List<Annotation>> annotations = getAnnotations(metadata);
|
||||||
for (Map.Entry<Class<?>, List<Annotation>> entry : annotations.entrySet()) {
|
annotations.forEach((key, value) -> {
|
||||||
collectCandidateConfigurations(entry.getKey(), entry.getValue(), candidates);
|
collectCandidateConfigurations(key, value, candidates);
|
||||||
}
|
});
|
||||||
return candidates;
|
return candidates;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,13 +57,10 @@ final class CacheConfigurations {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static CacheType getType(String configurationClassName) {
|
public static CacheType getType(String configurationClassName) {
|
||||||
for (Map.Entry<CacheType, Class<?>> entry : MAPPINGS.entrySet()) {
|
return MAPPINGS.entrySet().stream().filter((entry) ->
|
||||||
if (entry.getValue().getName().equals(configurationClassName)) {
|
entry.getValue().getName().equals(configurationClassName)).
|
||||||
return entry.getKey();
|
map(Map.Entry::getKey).findFirst().
|
||||||
}
|
orElseThrow(() -> new IllegalStateException("Unknown configuration class " + configurationClassName));
|
||||||
}
|
|
||||||
throw new IllegalStateException(
|
|
||||||
"Unknown configuration class " + configurationClassName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -159,13 +159,8 @@ public abstract class AbstractNestedCondition extends SpringBootCondition
|
|||||||
|
|
||||||
public List<ConditionOutcome> getMatchOutcomes() {
|
public List<ConditionOutcome> getMatchOutcomes() {
|
||||||
List<ConditionOutcome> outcomes = new ArrayList<>();
|
List<ConditionOutcome> outcomes = new ArrayList<>();
|
||||||
for (Map.Entry<AnnotationMetadata, List<Condition>> entry : this.memberConditions
|
this.memberConditions.forEach((metadata, conditions) ->
|
||||||
.entrySet()) {
|
outcomes.add(new MemberOutcomes(this.context, metadata, conditions).getUltimateOutcome()));
|
||||||
AnnotationMetadata metadata = entry.getKey();
|
|
||||||
List<Condition> conditions = entry.getValue();
|
|
||||||
outcomes.add(new MemberOutcomes(this.context, metadata, conditions)
|
|
||||||
.getUltimateOutcome());
|
|
||||||
}
|
|
||||||
return Collections.unmodifiableList(outcomes);
|
return Collections.unmodifiableList(outcomes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import java.util.Iterator;
|
|||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
@@ -112,13 +113,9 @@ final class BeanTypeRegistry implements SmartInitializingSingleton {
|
|||||||
*/
|
*/
|
||||||
Set<String> getNamesForType(Class<?> type) {
|
Set<String> getNamesForType(Class<?> type) {
|
||||||
updateTypesIfNecessary();
|
updateTypesIfNecessary();
|
||||||
Set<String> matches = new LinkedHashSet<>();
|
return this.beanTypes.entrySet().stream().filter((entry) -> entry.getValue() != null &&
|
||||||
for (Map.Entry<String, Class<?>> entry : this.beanTypes.entrySet()) {
|
type.isAssignableFrom(entry.getValue())).
|
||||||
if (entry.getValue() != null && type.isAssignableFrom(entry.getValue())) {
|
map(Map.Entry::getKey).collect(Collectors.toCollection(LinkedHashSet::new));
|
||||||
matches.add(entry.getKey());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return matches;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -132,14 +129,9 @@ final class BeanTypeRegistry implements SmartInitializingSingleton {
|
|||||||
*/
|
*/
|
||||||
Set<String> getNamesForAnnotation(Class<? extends Annotation> annotation) {
|
Set<String> getNamesForAnnotation(Class<? extends Annotation> annotation) {
|
||||||
updateTypesIfNecessary();
|
updateTypesIfNecessary();
|
||||||
Set<String> matches = new LinkedHashSet<>();
|
return this.beanTypes.entrySet().stream().filter((entry) -> entry.getValue() != null &&
|
||||||
for (Map.Entry<String, Class<?>> entry : this.beanTypes.entrySet()) {
|
AnnotationUtils.findAnnotation(entry.getValue(), annotation) != null).
|
||||||
if (entry.getValue() != null && AnnotationUtils
|
map(Map.Entry::getKey).collect(Collectors.toCollection(LinkedHashSet::new));
|
||||||
.findAnnotation(entry.getValue(), annotation) != null) {
|
|
||||||
matches.add(entry.getKey());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return matches;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import java.util.Iterator;
|
|||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.SortedMap;
|
import java.util.SortedMap;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
@@ -112,12 +111,11 @@ public final class ConditionEvaluationReport {
|
|||||||
*/
|
*/
|
||||||
public Map<String, ConditionAndOutcomes> getConditionAndOutcomesBySource() {
|
public Map<String, ConditionAndOutcomes> getConditionAndOutcomesBySource() {
|
||||||
if (!this.addedAncestorOutcomes) {
|
if (!this.addedAncestorOutcomes) {
|
||||||
for (Map.Entry<String, ConditionAndOutcomes> entry : this.outcomes
|
this.outcomes.forEach((key, value) -> {
|
||||||
.entrySet()) {
|
if (!value.isFullMatch()) {
|
||||||
if (!entry.getValue().isFullMatch()) {
|
addNoMatchOutcomeToAncestors(key);
|
||||||
addNoMatchOutcomeToAncestors(entry.getKey());
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
this.addedAncestorOutcomes = true;
|
this.addedAncestorOutcomes = true;
|
||||||
}
|
}
|
||||||
return Collections.unmodifiableMap(this.outcomes);
|
return Collections.unmodifiableMap(this.outcomes);
|
||||||
@@ -125,13 +123,13 @@ public final class ConditionEvaluationReport {
|
|||||||
|
|
||||||
private void addNoMatchOutcomeToAncestors(String source) {
|
private void addNoMatchOutcomeToAncestors(String source) {
|
||||||
String prefix = source + "$";
|
String prefix = source + "$";
|
||||||
for (Entry<String, ConditionAndOutcomes> entry : this.outcomes.entrySet()) {
|
this.outcomes.forEach((key, value) -> {
|
||||||
if (entry.getKey().startsWith(prefix)) {
|
if (key.startsWith(prefix)) {
|
||||||
ConditionOutcome outcome = ConditionOutcome.noMatch(ConditionMessage
|
ConditionOutcome outcome = ConditionOutcome.noMatch(ConditionMessage
|
||||||
.forCondition("Ancestor " + source).because("did not match"));
|
.forCondition("Ancestor " + source).because("did not match"));
|
||||||
entry.getValue().add(ANCESTOR_CONDITION, outcome);
|
value.add(ANCESTOR_CONDITION, outcome);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -190,16 +188,15 @@ public final class ConditionEvaluationReport {
|
|||||||
|
|
||||||
public ConditionEvaluationReport getDelta(ConditionEvaluationReport previousReport) {
|
public ConditionEvaluationReport getDelta(ConditionEvaluationReport previousReport) {
|
||||||
ConditionEvaluationReport delta = new ConditionEvaluationReport();
|
ConditionEvaluationReport delta = new ConditionEvaluationReport();
|
||||||
for (Entry<String, ConditionAndOutcomes> entry : this.outcomes.entrySet()) {
|
this.outcomes.forEach((key, value) -> {
|
||||||
ConditionAndOutcomes previous = previousReport.outcomes.get(entry.getKey());
|
ConditionAndOutcomes previous = previousReport.outcomes.get(key);
|
||||||
if (previous == null
|
if (previous == null
|
||||||
|| previous.isFullMatch() != entry.getValue().isFullMatch()) {
|
|| previous.isFullMatch() != value.isFullMatch()) {
|
||||||
entry.getValue()
|
value.forEach((conditionAndOutcome) -> delta.recordConditionEvaluation(
|
||||||
.forEach((conditionAndOutcome) -> delta.recordConditionEvaluation(
|
key, conditionAndOutcome.getCondition(),
|
||||||
entry.getKey(), conditionAndOutcome.getCondition(),
|
|
||||||
conditionAndOutcome.getOutcome()));
|
conditionAndOutcome.getOutcome()));
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
List<String> newExclusions = new ArrayList<>(this.exclusions);
|
List<String> newExclusions = new ArrayList<>(this.exclusions);
|
||||||
newExclusions.removeAll(previousReport.getExclusions());
|
newExclusions.removeAll(previousReport.getExclusions());
|
||||||
delta.recordExclusions(newExclusions);
|
delta.recordExclusions(newExclusions);
|
||||||
|
|||||||
@@ -166,18 +166,18 @@ class OnBeanCondition extends SpringBootCondition implements ConfigurationCondit
|
|||||||
private void appendMessageForMatches(StringBuilder reason,
|
private void appendMessageForMatches(StringBuilder reason,
|
||||||
Map<String, Collection<String>> matches, String description) {
|
Map<String, Collection<String>> matches, String description) {
|
||||||
if (!matches.isEmpty()) {
|
if (!matches.isEmpty()) {
|
||||||
for (Map.Entry<String, Collection<String>> match : matches.entrySet()) {
|
matches.forEach((key, value) -> {
|
||||||
if (reason.length() > 0) {
|
if (reason.length() > 0) {
|
||||||
reason.append(" and ");
|
reason.append(" and ");
|
||||||
}
|
}
|
||||||
reason.append("found beans ");
|
reason.append("found beans ");
|
||||||
reason.append(description);
|
reason.append(description);
|
||||||
reason.append(" '");
|
reason.append(" '");
|
||||||
reason.append(match.getKey());
|
reason.append(key);
|
||||||
reason.append("' ");
|
reason.append("' ");
|
||||||
reason.append(
|
reason.append(
|
||||||
StringUtils.collectionToDelimitedString(match.getValue(), ", "));
|
StringUtils.collectionToDelimitedString(value, ", "));
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionMessage.Style;
|
import org.springframework.boot.autoconfigure.condition.ConditionMessage.Style;
|
||||||
import org.springframework.context.annotation.Condition;
|
import org.springframework.context.annotation.Condition;
|
||||||
@@ -69,8 +68,8 @@ class OnPropertyCondition extends SpringBootCondition {
|
|||||||
private List<AnnotationAttributes> annotationAttributesFromMultiValueMap(
|
private List<AnnotationAttributes> annotationAttributesFromMultiValueMap(
|
||||||
MultiValueMap<String, Object> multiValueMap) {
|
MultiValueMap<String, Object> multiValueMap) {
|
||||||
List<Map<String, Object>> maps = new ArrayList<>();
|
List<Map<String, Object>> maps = new ArrayList<>();
|
||||||
for (Entry<String, List<Object>> entry : multiValueMap.entrySet()) {
|
multiValueMap.forEach((key, value) -> {
|
||||||
for (int i = 0; i < entry.getValue().size(); i++) {
|
for (int i = 0; i < value.size(); i++) {
|
||||||
Map<String, Object> map;
|
Map<String, Object> map;
|
||||||
if (i < maps.size()) {
|
if (i < maps.size()) {
|
||||||
map = maps.get(i);
|
map = maps.get(i);
|
||||||
@@ -79,9 +78,9 @@ class OnPropertyCondition extends SpringBootCondition {
|
|||||||
map = new HashMap<>();
|
map = new HashMap<>();
|
||||||
maps.add(map);
|
maps.add(map);
|
||||||
}
|
}
|
||||||
map.put(entry.getKey(), entry.getValue().get(i));
|
map.put(key, value.get(i));
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
List<AnnotationAttributes> annotationAttributes = new ArrayList<>(maps.size());
|
List<AnnotationAttributes> annotationAttributes = new ArrayList<>(maps.size());
|
||||||
for (Map<String, Object> map : maps) {
|
for (Map<String, Object> map : maps) {
|
||||||
annotationAttributes.add(AnnotationAttributes.fromMap(map));
|
annotationAttributes.add(AnnotationAttributes.fromMap(map));
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
|||||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionEvaluationReport;
|
import org.springframework.boot.autoconfigure.condition.ConditionEvaluationReport;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionEvaluationReport.ConditionAndOutcome;
|
import org.springframework.boot.autoconfigure.condition.ConditionEvaluationReport.ConditionAndOutcome;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionEvaluationReport.ConditionAndOutcomes;
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
|
import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
|
||||||
import org.springframework.boot.diagnostics.FailureAnalysis;
|
import org.springframework.boot.diagnostics.FailureAnalysis;
|
||||||
import org.springframework.boot.diagnostics.analyzer.AbstractInjectionFailureAnalyzer;
|
import org.springframework.boot.diagnostics.analyzer.AbstractInjectionFailureAnalyzer;
|
||||||
@@ -124,10 +123,8 @@ class NoSuchBeanDefinitionFailureAnalyzer
|
|||||||
|
|
||||||
private void collectReportedConditionOutcomes(NoSuchBeanDefinitionException cause,
|
private void collectReportedConditionOutcomes(NoSuchBeanDefinitionException cause,
|
||||||
List<AutoConfigurationResult> results) {
|
List<AutoConfigurationResult> results) {
|
||||||
for (Map.Entry<String, ConditionAndOutcomes> entry : this.report
|
this.report.getConditionAndOutcomesBySource().forEach((key, conditionAndOutcomes) -> {
|
||||||
.getConditionAndOutcomesBySource().entrySet()) {
|
Source source = new Source(key);
|
||||||
Source source = new Source(entry.getKey());
|
|
||||||
ConditionAndOutcomes conditionAndOutcomes = entry.getValue();
|
|
||||||
if (!conditionAndOutcomes.isFullMatch()) {
|
if (!conditionAndOutcomes.isFullMatch()) {
|
||||||
BeanMethods methods = new BeanMethods(source, cause);
|
BeanMethods methods = new BeanMethods(source, cause);
|
||||||
for (ConditionAndOutcome conditionAndOutcome : conditionAndOutcomes) {
|
for (ConditionAndOutcome conditionAndOutcome : conditionAndOutcomes) {
|
||||||
@@ -139,7 +136,7 @@ class NoSuchBeanDefinitionFailureAnalyzer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void collectExcludedAutoConfiguration(NoSuchBeanDefinitionException cause,
|
private void collectExcludedAutoConfiguration(NoSuchBeanDefinitionException cause,
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ package org.springframework.boot.autoconfigure.jersey;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import javax.servlet.DispatcherType;
|
import javax.servlet.DispatcherType;
|
||||||
@@ -181,9 +180,7 @@ public class JerseyAutoConfiguration implements ServletContextAware {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addInitParameters(DynamicRegistrationBean<?> registration) {
|
private void addInitParameters(DynamicRegistrationBean<?> registration) {
|
||||||
for (Entry<String, String> entry : this.jersey.getInit().entrySet()) {
|
this.jersey.getInit().forEach(registration::addInitParameter);
|
||||||
registration.addInitParameter(entry.getKey(), entry.getValue());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String findApplicationPath(ApplicationPath annotation) {
|
private static String findApplicationPath(ApplicationPath annotation) {
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package org.springframework.boot.autoconfigure.session;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.EnumMap;
|
import java.util.EnumMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import org.springframework.boot.WebApplicationType;
|
import org.springframework.boot.WebApplicationType;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
@@ -82,18 +83,12 @@ final class SessionStoreMappings {
|
|||||||
|
|
||||||
static StoreType getType(WebApplicationType webApplicationType,
|
static StoreType getType(WebApplicationType webApplicationType,
|
||||||
String configurationClassName) {
|
String configurationClassName) {
|
||||||
for (Map.Entry<StoreType, Map<WebApplicationType, Class<?>>> storeEntry : MAPPINGS
|
return MAPPINGS.entrySet().stream().map(entry ->
|
||||||
.entrySet()) {
|
entry.getValue().entrySet().stream().filter(webAppEntry -> webAppEntry.getKey() == webApplicationType
|
||||||
for (Map.Entry<WebApplicationType, Class<?>> entry : storeEntry.getValue()
|
&& webAppEntry.getValue().getName().equals(configurationClassName)).
|
||||||
.entrySet()) {
|
map(webAppEntry -> entry.getKey()).findFirst().orElse(null)).filter(Objects::nonNull).
|
||||||
if (entry.getKey() == webApplicationType
|
findFirst().orElseThrow(() ->
|
||||||
&& entry.getValue().getName().equals(configurationClassName)) {
|
new IllegalStateException("Unknown configuration class " + configurationClassName));
|
||||||
return storeEntry.getKey();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw new IllegalStateException(
|
|
||||||
"Unknown configuration class " + configurationClassName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ListIterator;
|
import java.util.ListIterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import javax.servlet.Servlet;
|
import javax.servlet.Servlet;
|
||||||
@@ -236,9 +235,7 @@ public class WebMvcAutoConfiguration {
|
|||||||
}
|
}
|
||||||
Map<String, MediaType> mediaTypes = this.mvcProperties.getContentnegotiation()
|
Map<String, MediaType> mediaTypes = this.mvcProperties.getContentnegotiation()
|
||||||
.getMediaTypes();
|
.getMediaTypes();
|
||||||
for (Entry<String, MediaType> mediaType : mediaTypes.entrySet()) {
|
mediaTypes.forEach(configurer::mediaType);
|
||||||
configurer.mediaType(mediaType.getKey(), mediaType.getValue());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ package org.springframework.boot.autoconfigure.webservices;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.springframework.beans.BeansException;
|
import org.springframework.beans.BeansException;
|
||||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||||
@@ -83,9 +82,7 @@ public class WebServicesAutoConfiguration {
|
|||||||
servlet, urlMapping);
|
servlet, urlMapping);
|
||||||
WebServicesProperties.Servlet servletProperties = this.properties.getServlet();
|
WebServicesProperties.Servlet servletProperties = this.properties.getServlet();
|
||||||
registration.setLoadOnStartup(servletProperties.getLoadOnStartup());
|
registration.setLoadOnStartup(servletProperties.getLoadOnStartup());
|
||||||
for (Map.Entry<String, String> entry : servletProperties.getInit().entrySet()) {
|
servletProperties.getInit().forEach(registration::addInitParameter);
|
||||||
registration.addInitParameter(entry.getKey(), entry.getValue());
|
|
||||||
}
|
|
||||||
return registration;
|
return registration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import java.net.URI;
|
|||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -423,14 +422,7 @@ class ProjectGenerationRequest {
|
|||||||
|
|
||||||
private static void filter(Map<String, ProjectType> projects, String tag,
|
private static void filter(Map<String, ProjectType> projects, String tag,
|
||||||
String tagValue) {
|
String tagValue) {
|
||||||
for (Iterator<Map.Entry<String, ProjectType>> it = projects.entrySet()
|
projects.entrySet().removeIf((entry) -> !tagValue.equals(entry.getValue().getTags().get(tag)));
|
||||||
.iterator(); it.hasNext();) {
|
|
||||||
Map.Entry<String, ProjectType> entry = it.next();
|
|
||||||
String value = entry.getValue().getTags().get(tag);
|
|
||||||
if (!tagValue.equals(value)) {
|
|
||||||
it.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ package org.springframework.boot.cli.compiler;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.codehaus.groovy.ast.ASTNode;
|
import org.codehaus.groovy.ast.ASTNode;
|
||||||
@@ -68,14 +67,8 @@ public abstract class AnnotatedNodeASTTransformation implements ASTTransformatio
|
|||||||
for (ImportNode importNode : module.getStarImports()) {
|
for (ImportNode importNode : module.getStarImports()) {
|
||||||
visitAnnotatedNode(importNode, annotationNodes);
|
visitAnnotatedNode(importNode, annotationNodes);
|
||||||
}
|
}
|
||||||
for (Map.Entry<String, ImportNode> entry : module.getStaticImports()
|
module.getStaticImports().forEach((key, value) -> visitAnnotatedNode(value, annotationNodes));
|
||||||
.entrySet()) {
|
module.getStaticStarImports().forEach((key, value) -> visitAnnotatedNode(value, annotationNodes));
|
||||||
visitAnnotatedNode(entry.getValue(), annotationNodes);
|
|
||||||
}
|
|
||||||
for (Map.Entry<String, ImportNode> entry : module.getStaticStarImports()
|
|
||||||
.entrySet()) {
|
|
||||||
visitAnnotatedNode(entry.getValue(), annotationNodes);
|
|
||||||
}
|
|
||||||
for (ClassNode classNode : module.getClasses()) {
|
for (ClassNode classNode : module.getClasses()) {
|
||||||
visitAnnotatedNode(classNode, annotationNodes);
|
visitAnnotatedNode(classNode, annotationNodes);
|
||||||
classNode.visitContents(classVisitor);
|
classNode.visitContents(classVisitor);
|
||||||
|
|||||||
@@ -63,13 +63,13 @@ public class DevToolsSettings {
|
|||||||
|
|
||||||
private Map<String, Pattern> getPatterns(Map<?, ?> properties, String prefix) {
|
private Map<String, Pattern> getPatterns(Map<?, ?> properties, String prefix) {
|
||||||
Map<String, Pattern> patterns = new LinkedHashMap<>();
|
Map<String, Pattern> patterns = new LinkedHashMap<>();
|
||||||
for (Map.Entry<?, ?> entry : properties.entrySet()) {
|
properties.forEach((key, value) -> {
|
||||||
String name = String.valueOf(entry.getKey());
|
String name = String.valueOf(key);
|
||||||
if (name.startsWith(prefix)) {
|
if (name.startsWith(prefix)) {
|
||||||
Pattern pattern = Pattern.compile((String) entry.getValue());
|
Pattern pattern = Pattern.compile((String) value);
|
||||||
patterns.put(name, pattern);
|
patterns.put(name, pattern);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
return patterns;
|
return patterns;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,13 +18,13 @@ package org.springframework.boot.autoconfigureprocessor;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import javax.annotation.processing.AbstractProcessor;
|
import javax.annotation.processing.AbstractProcessor;
|
||||||
import javax.annotation.processing.RoundEnvironment;
|
import javax.annotation.processing.RoundEnvironment;
|
||||||
@@ -34,7 +34,6 @@ import javax.lang.model.element.AnnotationMirror;
|
|||||||
import javax.lang.model.element.AnnotationValue;
|
import javax.lang.model.element.AnnotationValue;
|
||||||
import javax.lang.model.element.Element;
|
import javax.lang.model.element.Element;
|
||||||
import javax.lang.model.element.ElementKind;
|
import javax.lang.model.element.ElementKind;
|
||||||
import javax.lang.model.element.ExecutableElement;
|
|
||||||
import javax.lang.model.element.TypeElement;
|
import javax.lang.model.element.TypeElement;
|
||||||
import javax.lang.model.type.DeclaredType;
|
import javax.lang.model.type.DeclaredType;
|
||||||
import javax.lang.model.type.TypeMirror;
|
import javax.lang.model.type.TypeMirror;
|
||||||
@@ -158,23 +157,19 @@ public class AutoConfigureAnnotationProcessor extends AbstractProcessor {
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private List<Object> getValues(AnnotationMirror annotation) {
|
private List<Object> getValues(AnnotationMirror annotation) {
|
||||||
List<Object> result = new ArrayList<>();
|
return annotation .getElementValues().entrySet().stream().filter(entry -> {
|
||||||
for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : annotation
|
|
||||||
.getElementValues().entrySet()) {
|
|
||||||
String attributeName = entry.getKey().getSimpleName().toString();
|
String attributeName = entry.getKey().getSimpleName().toString();
|
||||||
if ("name".equals(attributeName) || "value".equals(attributeName)) {
|
return "name".equals(attributeName) || "value".equals(attributeName);
|
||||||
Object value = entry.getValue().getValue();
|
}).map((entry) -> {
|
||||||
if (value instanceof List) {
|
Object value = entry.getValue().getValue();
|
||||||
for (AnnotationValue annotationValue : (List<AnnotationValue>) value) {
|
if (value instanceof List) {
|
||||||
result.add(processValue(annotationValue.getValue()));
|
return ((List<AnnotationValue>) value).stream().
|
||||||
}
|
map(annotationValue -> processValue(annotationValue.getValue())).collect(Collectors.toList());
|
||||||
}
|
|
||||||
else {
|
|
||||||
result.add(processValue(value));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
else {
|
||||||
return result;
|
return Collections.singletonList(processValue(value));
|
||||||
|
}
|
||||||
|
}).flatMap(List::stream).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object processValue(Object value) {
|
private Object processValue(Object value) {
|
||||||
|
|||||||
@@ -93,17 +93,9 @@ public class SimpleConfigurationMetadataRepository
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Merge properties
|
// Merge properties
|
||||||
for (Map.Entry<String, ConfigurationMetadataProperty> entry : group
|
group.getProperties().forEach((key, value) -> putIfAbsent(existingGroup.getProperties(), key, value));
|
||||||
.getProperties().entrySet()) {
|
|
||||||
putIfAbsent(existingGroup.getProperties(), entry.getKey(),
|
|
||||||
entry.getValue());
|
|
||||||
}
|
|
||||||
// Merge sources
|
// Merge sources
|
||||||
for (Map.Entry<String, ConfigurationMetadataSource> entry : group
|
group.getSources().forEach((key, value) -> putIfAbsent(existingGroup.getSources(), key, value));
|
||||||
.getSources().entrySet()) {
|
|
||||||
putIfAbsent(existingGroup.getSources(), entry.getKey(),
|
|
||||||
entry.getValue());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ import javax.annotation.processing.RoundEnvironment;
|
|||||||
import javax.annotation.processing.SupportedAnnotationTypes;
|
import javax.annotation.processing.SupportedAnnotationTypes;
|
||||||
import javax.lang.model.SourceVersion;
|
import javax.lang.model.SourceVersion;
|
||||||
import javax.lang.model.element.AnnotationMirror;
|
import javax.lang.model.element.AnnotationMirror;
|
||||||
import javax.lang.model.element.AnnotationValue;
|
|
||||||
import javax.lang.model.element.Element;
|
import javax.lang.model.element.Element;
|
||||||
import javax.lang.model.element.ElementKind;
|
import javax.lang.model.element.ElementKind;
|
||||||
import javax.lang.model.element.ExecutableElement;
|
import javax.lang.model.element.ExecutableElement;
|
||||||
@@ -282,10 +281,7 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
|
|||||||
private void processSimpleTypes(String prefix, TypeElement element,
|
private void processSimpleTypes(String prefix, TypeElement element,
|
||||||
ExecutableElement source, TypeElementMembers members,
|
ExecutableElement source, TypeElementMembers members,
|
||||||
Map<String, Object> fieldValues) {
|
Map<String, Object> fieldValues) {
|
||||||
for (Map.Entry<String, ExecutableElement> entry : members.getPublicGetters()
|
members.getPublicGetters().forEach((name, getter) -> {
|
||||||
.entrySet()) {
|
|
||||||
String name = entry.getKey();
|
|
||||||
ExecutableElement getter = entry.getValue();
|
|
||||||
TypeMirror returnType = getter.getReturnType();
|
TypeMirror returnType = getter.getReturnType();
|
||||||
ExecutableElement setter = members.getPublicSetter(name, returnType);
|
ExecutableElement setter = members.getPublicSetter(name, returnType);
|
||||||
VariableElement field = members.getFields().get(name);
|
VariableElement field = members.getFields().get(name);
|
||||||
@@ -305,7 +301,7 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
|
|||||||
dataType, sourceType, null, description, defaultValue,
|
dataType, sourceType, null, description, defaultValue,
|
||||||
(deprecated ? getItemDeprecation(getter) : null)));
|
(deprecated ? getItemDeprecation(getter) : null)));
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private ItemDeprecation getItemDeprecation(ExecutableElement getter) {
|
private ItemDeprecation getItemDeprecation(ExecutableElement getter) {
|
||||||
@@ -325,11 +321,9 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
|
|||||||
private void processSimpleLombokTypes(String prefix, TypeElement element,
|
private void processSimpleLombokTypes(String prefix, TypeElement element,
|
||||||
ExecutableElement source, TypeElementMembers members,
|
ExecutableElement source, TypeElementMembers members,
|
||||||
Map<String, Object> fieldValues) {
|
Map<String, Object> fieldValues) {
|
||||||
for (Map.Entry<String, VariableElement> entry : members.getFields().entrySet()) {
|
members.getFields().forEach((name, field) -> {
|
||||||
String name = entry.getKey();
|
|
||||||
VariableElement field = entry.getValue();
|
|
||||||
if (!isLombokField(field, element)) {
|
if (!isLombokField(field, element)) {
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
TypeMirror returnType = field.asType();
|
TypeMirror returnType = field.asType();
|
||||||
Element returnTypeElement = this.processingEnv.getTypeUtils()
|
Element returnTypeElement = this.processingEnv.getTypeUtils()
|
||||||
@@ -348,32 +342,27 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
|
|||||||
dataType, sourceType, null, description, defaultValue,
|
dataType, sourceType, null, description, defaultValue,
|
||||||
(deprecated ? new ItemDeprecation() : null)));
|
(deprecated ? new ItemDeprecation() : null)));
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processNestedTypes(String prefix, TypeElement element,
|
private void processNestedTypes(String prefix, TypeElement element,
|
||||||
ExecutableElement source, TypeElementMembers members) {
|
ExecutableElement source, TypeElementMembers members) {
|
||||||
for (Map.Entry<String, ExecutableElement> entry : members.getPublicGetters()
|
members.getPublicGetters().forEach((name, getter) -> {
|
||||||
.entrySet()) {
|
|
||||||
String name = entry.getKey();
|
|
||||||
ExecutableElement getter = entry.getValue();
|
|
||||||
VariableElement field = members.getFields().get(name);
|
VariableElement field = members.getFields().get(name);
|
||||||
processNestedType(prefix, element, source, name, getter, field,
|
processNestedType(prefix, element, source, name, getter, field,
|
||||||
getter.getReturnType());
|
getter.getReturnType());
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processNestedLombokTypes(String prefix, TypeElement element,
|
private void processNestedLombokTypes(String prefix, TypeElement element,
|
||||||
ExecutableElement source, TypeElementMembers members) {
|
ExecutableElement source, TypeElementMembers members) {
|
||||||
for (Map.Entry<String, VariableElement> entry : members.getFields().entrySet()) {
|
members.getFields().forEach((name, field) -> {
|
||||||
String name = entry.getKey();
|
|
||||||
VariableElement field = entry.getValue();
|
|
||||||
if (isLombokField(field, element)) {
|
if (isLombokField(field, element)) {
|
||||||
ExecutableElement getter = members.getPublicGetter(name, field.asType());
|
ExecutableElement getter = members.getPublicGetter(name, field.asType());
|
||||||
processNestedType(prefix, element, source, name, getter, field,
|
processNestedType(prefix, element, source, name, getter, field,
|
||||||
field.asType());
|
field.asType());
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isLombokField(VariableElement field, TypeElement element) {
|
private boolean isLombokField(VariableElement field, TypeElement element) {
|
||||||
@@ -544,11 +533,8 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
|
|||||||
|
|
||||||
private Map<String, Object> getAnnotationElementValues(AnnotationMirror annotation) {
|
private Map<String, Object> getAnnotationElementValues(AnnotationMirror annotation) {
|
||||||
Map<String, Object> values = new LinkedHashMap<>();
|
Map<String, Object> values = new LinkedHashMap<>();
|
||||||
for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : annotation
|
annotation.getElementValues().forEach((key, value) ->
|
||||||
.getElementValues().entrySet()) {
|
values.put(key.getSimpleName().toString(), value.getValue()));
|
||||||
values.put(entry.getKey().getSimpleName().toString(),
|
|
||||||
entry.getValue().getValue());
|
|
||||||
}
|
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -78,13 +78,11 @@ class TypeElementMembers {
|
|||||||
processField(field);
|
processField(field);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Map<String, Object> fieldValues = this.fieldValuesParser
|
this.fieldValuesParser.getFieldValues(element).forEach((key, value) -> {
|
||||||
.getFieldValues(element);
|
if (!this.fieldValues.containsKey(key)) {
|
||||||
for (Map.Entry<String, Object> entry : fieldValues.entrySet()) {
|
this.fieldValues.put(key, value);
|
||||||
if (!this.fieldValues.containsKey(entry.getKey())) {
|
|
||||||
this.fieldValues.put(entry.getKey(), entry.getValue());
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
// continue
|
// continue
|
||||||
|
|||||||
@@ -62,9 +62,7 @@ class TypeUtils {
|
|||||||
|
|
||||||
static {
|
static {
|
||||||
Map<String, TypeKind> primitives = new HashMap<>();
|
Map<String, TypeKind> primitives = new HashMap<>();
|
||||||
for (Map.Entry<TypeKind, Class<?>> entry : PRIMITIVE_WRAPPERS.entrySet()) {
|
PRIMITIVE_WRAPPERS.forEach((key, value) -> primitives.put(value.getName(), key));
|
||||||
primitives.put(entry.getValue().getName(), entry.getKey());
|
|
||||||
}
|
|
||||||
WRAPPER_TO_PRIMITIVE = primitives;
|
WRAPPER_TO_PRIMITIVE = primitives;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
import org.gradle.api.Action;
|
import org.gradle.api.Action;
|
||||||
import org.gradle.api.Project;
|
import org.gradle.api.Project;
|
||||||
@@ -110,9 +109,7 @@ public class BuildInfo extends ConventionTask {
|
|||||||
|
|
||||||
private Map<String, String> coerceToStringValues(Map<String, Object> input) {
|
private Map<String, String> coerceToStringValues(Map<String, Object> input) {
|
||||||
Map<String, String> output = new HashMap<>();
|
Map<String, String> output = new HashMap<>();
|
||||||
for (Entry<String, Object> entry : input.entrySet()) {
|
input.forEach((key, value) -> output.put(key, value.toString()));
|
||||||
output.put(entry.getKey(), entry.getValue().toString());
|
|
||||||
}
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import java.io.IOException;
|
|||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -79,10 +78,7 @@ public final class BuildPropertiesWriter {
|
|||||||
DateTimeFormatter.ISO_INSTANT.format(project.getTime()));
|
DateTimeFormatter.ISO_INSTANT.format(project.getTime()));
|
||||||
}
|
}
|
||||||
if (project.getAdditionalProperties() != null) {
|
if (project.getAdditionalProperties() != null) {
|
||||||
for (Map.Entry<String, String> entry : project.getAdditionalProperties()
|
project.getAdditionalProperties().forEach((key, value) -> properties.put("build." + key, value));
|
||||||
.entrySet()) {
|
|
||||||
properties.put("build." + entry.getKey(), entry.getValue());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
@@ -118,11 +114,11 @@ public final class BuildPropertiesWriter {
|
|||||||
private static void validateAdditionalProperties(
|
private static void validateAdditionalProperties(
|
||||||
Map<String, String> additionalProperties) {
|
Map<String, String> additionalProperties) {
|
||||||
if (additionalProperties != null) {
|
if (additionalProperties != null) {
|
||||||
for (Entry<String, String> property : additionalProperties.entrySet()) {
|
additionalProperties.forEach((key, value) -> {
|
||||||
if (property.getValue() == null) {
|
if (value == null) {
|
||||||
throw new NullAdditionalPropertyValueException(property.getKey());
|
throw new NullAdditionalPropertyValueException(key);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ package org.springframework.boot.maven;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.jar.JarEntry;
|
import java.util.jar.JarEntry;
|
||||||
import java.util.jar.JarOutputStream;
|
import java.util.jar.JarOutputStream;
|
||||||
@@ -64,13 +63,13 @@ public class PropertiesMergingResourceTransformer implements ResourceTransformer
|
|||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
properties.load(is);
|
properties.load(is);
|
||||||
is.close();
|
is.close();
|
||||||
for (Entry<Object, Object> entry : properties.entrySet()) {
|
properties.forEach((key, valueObject) -> {
|
||||||
String name = (String) entry.getKey();
|
String name = (String) key;
|
||||||
String value = (String) entry.getValue();
|
String value = (String) valueObject;
|
||||||
String existing = this.data.getProperty(name);
|
String existing = this.data.getProperty(name);
|
||||||
this.data.setProperty(name,
|
this.data.setProperty(name,
|
||||||
existing == null ? value : existing + "," + value);
|
existing == null ? value : existing + "," + value);
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -140,13 +140,10 @@ public final class Verify {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ZipEntry getEntryStartingWith(String entryName) {
|
private ZipEntry getEntryStartingWith(String entryName) {
|
||||||
for (Map.Entry<String, ZipEntry> entry : this.content.entrySet()) {
|
return this.content.entrySet().stream().
|
||||||
if (entry.getKey().startsWith(entryName)) {
|
filter(entry -> entry.getKey().startsWith(entryName)).
|
||||||
return entry.getValue();
|
map(Map.Entry::getValue).findFirst().orElseThrow(() ->
|
||||||
}
|
new IllegalStateException("Unable to find entry starting with " + entryName));
|
||||||
}
|
|
||||||
throw new IllegalStateException(
|
|
||||||
"Unable to find entry starting with " + entryName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasEntry(String entry) {
|
public boolean hasEntry(String entry) {
|
||||||
|
|||||||
@@ -156,12 +156,10 @@ public abstract class LoggingSystem {
|
|||||||
}
|
}
|
||||||
return get(classLoader, loggingSystem);
|
return get(classLoader, loggingSystem);
|
||||||
}
|
}
|
||||||
for (Map.Entry<String, String> entry : SYSTEMS.entrySet()) {
|
return SYSTEMS.entrySet().stream().
|
||||||
if (ClassUtils.isPresent(entry.getKey(), classLoader)) {
|
filter((entry) -> ClassUtils.isPresent(entry.getKey(), classLoader)).
|
||||||
return get(classLoader, entry.getValue());
|
map(entry -> get(classLoader, entry.getValue())).
|
||||||
}
|
findFirst().orElseThrow(() -> new IllegalStateException("No suitable logging system located"));
|
||||||
}
|
|
||||||
throw new IllegalStateException("No suitable logging system located");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static LoggingSystem get(ClassLoader classLoader, String loggingSystemClass) {
|
private static LoggingSystem get(ClassLoader classLoader, String loggingSystemClass) {
|
||||||
|
|||||||
Reference in New Issue
Block a user