mirror of
https://gitee.com/dcren/initializr.git
synced 2026-02-26 05:32:58 +08:00
Use Java 17 constructs
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2022 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.
|
||||
@@ -17,8 +17,6 @@
|
||||
package io.spring.initializr.metadata;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
@@ -74,8 +72,8 @@ public class Dependency extends MetadataElement implements Describable {
|
||||
/**
|
||||
* All scope types.
|
||||
*/
|
||||
public static final List<String> SCOPE_ALL = Collections.unmodifiableList(Arrays.asList(SCOPE_COMPILE,
|
||||
SCOPE_RUNTIME, SCOPE_COMPILE_ONLY, SCOPE_ANNOTATION_PROCESSOR, SCOPE_PROVIDED, SCOPE_TEST));
|
||||
public static final List<String> SCOPE_ALL = List.of(SCOPE_COMPILE, SCOPE_RUNTIME, SCOPE_COMPILE_ONLY,
|
||||
SCOPE_ANNOTATION_PROCESSOR, SCOPE_PROVIDED, SCOPE_TEST);
|
||||
|
||||
private List<String> aliases = new ArrayList<>();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2022 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.
|
||||
@@ -85,13 +85,11 @@ public class SingleSelectCapability extends ServiceCapability<List<DefaultMetada
|
||||
|
||||
@Override
|
||||
public void merge(List<DefaultMetadataElement> otherContent) {
|
||||
withWritableContent((content) -> {
|
||||
otherContent.forEach((it) -> {
|
||||
if (get(it.getId()) == null) {
|
||||
this.content.add(it);
|
||||
}
|
||||
});
|
||||
});
|
||||
withWritableContent((content) -> otherContent.forEach((it) -> {
|
||||
if (get(it.getId()) == null) {
|
||||
this.content.add(it);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
private <T> T withReadableContent(Function<List<DefaultMetadataElement>, T> consumer) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 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.
|
||||
@@ -51,21 +51,15 @@ public final class MetadataBuildItemMapper {
|
||||
}
|
||||
|
||||
private static DependencyScope toDependencyScope(String scope) {
|
||||
switch (scope) {
|
||||
case Dependency.SCOPE_ANNOTATION_PROCESSOR:
|
||||
return DependencyScope.ANNOTATION_PROCESSOR;
|
||||
case Dependency.SCOPE_COMPILE:
|
||||
return DependencyScope.COMPILE;
|
||||
case Dependency.SCOPE_RUNTIME:
|
||||
return DependencyScope.RUNTIME;
|
||||
case Dependency.SCOPE_COMPILE_ONLY:
|
||||
return DependencyScope.COMPILE_ONLY;
|
||||
case Dependency.SCOPE_PROVIDED:
|
||||
return DependencyScope.PROVIDED_RUNTIME;
|
||||
case Dependency.SCOPE_TEST:
|
||||
return DependencyScope.TEST_COMPILE;
|
||||
}
|
||||
return null;
|
||||
return switch (scope) {
|
||||
case Dependency.SCOPE_ANNOTATION_PROCESSOR -> DependencyScope.ANNOTATION_PROCESSOR;
|
||||
case Dependency.SCOPE_COMPILE -> DependencyScope.COMPILE;
|
||||
case Dependency.SCOPE_RUNTIME -> DependencyScope.RUNTIME;
|
||||
case Dependency.SCOPE_COMPILE_ONLY -> DependencyScope.COMPILE_ONLY;
|
||||
case Dependency.SCOPE_PROVIDED -> DependencyScope.PROVIDED_RUNTIME;
|
||||
case Dependency.SCOPE_TEST -> DependencyScope.TEST_COMPILE;
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user