通過返回第一個
public static LoggingSystem get(ClassLoader classLoader) {
String loggingSystem = System.getProperty(SYSTEM_PROPERTY);
if (StringUtils.hasLength(loggingSystem)) {
if (NONE.equals(loggingSystem)) {
return new NoOpLoggingSystem();
}
return get(classLoader, loggingSystem);
}
return SYSTEMS.entrySet()
.stream()
.filter((entry) -> ClassUtils.isPresent(entry.getKey(), classLoader))
.map((entry) -> get(classLoader, entry.getValue()))
.findFirst()
.orElseThrow(() -> new IllegalStateException("No suitable logging system located"));
}
@Override
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
MutablePropertySources propertySources = environment.getPropertySources();
propertySources.stream()
.map(JsonPropertyValue::get)
.filter(Objects::nonNull)
.findFirst()
.ifPresent((v) -> processJson(environment, v));
}
通過拼接
private Object convert(Collection<?> source, TypeDescriptor sourceType, TypeDescriptor targetType) {
if (source.isEmpty()) {
return "";
}
return source.stream()
.map((element) -> convertElement(element, sourceType, targetType))
.collect(Collectors.joining(getDelimiter(sourceType)));
}
判斷布爾值
private boolean consumesRequestBody(Method method) {
return Stream.of(method.getParameters())
.anyMatch((parameter) -> parameter.getAnnotation(Selector.class) == null);
}