mirror of
https://gitee.com/dcren/initializr.git
synced 2025-04-05 17:38:06 +08:00
Polish
This commit is contained in:
parent
b835bf4ff4
commit
363eb25138
@ -24,7 +24,6 @@ import io.spring.initializr.generator.ProjectRequest;
|
|||||||
import io.spring.initializr.metadata.Dependency;
|
import io.spring.initializr.metadata.Dependency;
|
||||||
import io.spring.initializr.util.Agent;
|
import io.spring.initializr.util.Agent;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.boot.actuate.metrics.CounterService;
|
import org.springframework.boot.actuate.metrics.CounterService;
|
||||||
import org.springframework.context.event.EventListener;
|
import org.springframework.context.event.EventListener;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
@ -39,7 +38,6 @@ public class ProjectGenerationMetricsListener {
|
|||||||
|
|
||||||
private final CounterService counterService;
|
private final CounterService counterService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public ProjectGenerationMetricsListener(CounterService counterService) {
|
public ProjectGenerationMetricsListener(CounterService counterService) {
|
||||||
this.counterService = counterService;
|
this.counterService = counterService;
|
||||||
}
|
}
|
||||||
|
@ -167,7 +167,7 @@ public class InitializrMetadata {
|
|||||||
&& !repositories.containsKey(dependency.getRepository())) {
|
&& !repositories.containsKey(dependency.getRepository())) {
|
||||||
throw new InvalidInitializrMetadataException("Dependency " + dependency
|
throw new InvalidInitializrMetadataException("Dependency " + dependency
|
||||||
+ "defines an invalid repository id " + dependency.getRepository()
|
+ "defines an invalid repository id " + dependency.getRepository()
|
||||||
+ ", available repositores " + repositories);
|
+ ", available repositories " + repositories);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (BillOfMaterials bom : boms.values()) {
|
for (BillOfMaterials bom : boms.values()) {
|
||||||
@ -190,7 +190,7 @@ public class InitializrMetadata {
|
|||||||
if (!repositories.containsKey(r)) {
|
if (!repositories.containsKey(r)) {
|
||||||
throw new InvalidInitializrMetadataException(
|
throw new InvalidInitializrMetadataException(
|
||||||
m + " of " + bom + "defines an invalid repository id " + r
|
m + " of " + bom + "defines an invalid repository id " + r
|
||||||
+ ", available repositores " + repositories);
|
+ ", available repositories " + repositories);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
public class VersionPropertyTests {
|
public class VersionPropertyTests {
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public ExpectedException thrown = ExpectedException.none();
|
public final ExpectedException thrown = ExpectedException.none();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStandardProperty() {
|
public void testStandardProperty() {
|
||||||
|
@ -33,27 +33,13 @@ final class JsonFieldProcessor {
|
|||||||
|
|
||||||
boolean hasField(JsonFieldPath fieldPath, Object payload) {
|
boolean hasField(JsonFieldPath fieldPath, Object payload) {
|
||||||
final AtomicReference<Boolean> hasField = new AtomicReference<>(false);
|
final AtomicReference<Boolean> hasField = new AtomicReference<>(false);
|
||||||
traverse(new ProcessingContext(payload, fieldPath), new MatchCallback() {
|
traverse(new ProcessingContext(payload, fieldPath), match -> hasField.set(true));
|
||||||
|
|
||||||
@Override
|
|
||||||
public void foundMatch(Match match) {
|
|
||||||
hasField.set(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
return hasField.get();
|
return hasField.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
Object extract(JsonFieldPath path, Object payload) {
|
Object extract(JsonFieldPath path, Object payload) {
|
||||||
final List<Object> matches = new ArrayList<>();
|
final List<Object> matches = new ArrayList<>();
|
||||||
traverse(new ProcessingContext(payload, path), new MatchCallback() {
|
traverse(new ProcessingContext(payload, path), match -> matches.add(match.getValue()));
|
||||||
|
|
||||||
@Override
|
|
||||||
public void foundMatch(Match match) {
|
|
||||||
matches.add(match.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
if (matches.isEmpty()) {
|
if (matches.isEmpty()) {
|
||||||
throw new IllegalArgumentException("Field does not exist: " + path);
|
throw new IllegalArgumentException("Field does not exist: " + path);
|
||||||
}
|
}
|
||||||
@ -66,14 +52,7 @@ final class JsonFieldProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void remove(final JsonFieldPath path, Object payload) {
|
void remove(final JsonFieldPath path, Object payload) {
|
||||||
traverse(new ProcessingContext(payload, path), new MatchCallback() {
|
traverse(new ProcessingContext(payload, path), Match::remove);
|
||||||
|
|
||||||
@Override
|
|
||||||
public void foundMatch(Match match) {
|
|
||||||
match.remove();
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void traverse(ProcessingContext context, MatchCallback matchCallback) {
|
private void traverse(ProcessingContext context, MatchCallback matchCallback) {
|
||||||
|
Loading…
Reference in New Issue
Block a user