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.util.Agent;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.actuate.metrics.CounterService;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.util.StringUtils;
|
||||
@ -39,7 +38,6 @@ public class ProjectGenerationMetricsListener {
|
||||
|
||||
private final CounterService counterService;
|
||||
|
||||
@Autowired
|
||||
public ProjectGenerationMetricsListener(CounterService counterService) {
|
||||
this.counterService = counterService;
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ public class InitializrMetadata {
|
||||
&& !repositories.containsKey(dependency.getRepository())) {
|
||||
throw new InvalidInitializrMetadataException("Dependency " + dependency
|
||||
+ "defines an invalid repository id " + dependency.getRepository()
|
||||
+ ", available repositores " + repositories);
|
||||
+ ", available repositories " + repositories);
|
||||
}
|
||||
}
|
||||
for (BillOfMaterials bom : boms.values()) {
|
||||
@ -190,7 +190,7 @@ public class InitializrMetadata {
|
||||
if (!repositories.containsKey(r)) {
|
||||
throw new InvalidInitializrMetadataException(
|
||||
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 {
|
||||
|
||||
@Rule
|
||||
public ExpectedException thrown = ExpectedException.none();
|
||||
public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@Test
|
||||
public void testStandardProperty() {
|
||||
|
@ -33,27 +33,13 @@ final class JsonFieldProcessor {
|
||||
|
||||
boolean hasField(JsonFieldPath fieldPath, Object payload) {
|
||||
final AtomicReference<Boolean> hasField = new AtomicReference<>(false);
|
||||
traverse(new ProcessingContext(payload, fieldPath), new MatchCallback() {
|
||||
|
||||
@Override
|
||||
public void foundMatch(Match match) {
|
||||
hasField.set(true);
|
||||
}
|
||||
|
||||
});
|
||||
traverse(new ProcessingContext(payload, fieldPath), match -> hasField.set(true));
|
||||
return hasField.get();
|
||||
}
|
||||
|
||||
Object extract(JsonFieldPath path, Object payload) {
|
||||
final List<Object> matches = new ArrayList<>();
|
||||
traverse(new ProcessingContext(payload, path), new MatchCallback() {
|
||||
|
||||
@Override
|
||||
public void foundMatch(Match match) {
|
||||
matches.add(match.getValue());
|
||||
}
|
||||
|
||||
});
|
||||
traverse(new ProcessingContext(payload, path), match -> matches.add(match.getValue()));
|
||||
if (matches.isEmpty()) {
|
||||
throw new IllegalArgumentException("Field does not exist: " + path);
|
||||
}
|
||||
@ -66,14 +52,7 @@ final class JsonFieldProcessor {
|
||||
}
|
||||
|
||||
void remove(final JsonFieldPath path, Object payload) {
|
||||
traverse(new ProcessingContext(payload, path), new MatchCallback() {
|
||||
|
||||
@Override
|
||||
public void foundMatch(Match match) {
|
||||
match.remove();
|
||||
}
|
||||
|
||||
});
|
||||
traverse(new ProcessingContext(payload, path), Match::remove);
|
||||
}
|
||||
|
||||
private void traverse(ProcessingContext context, MatchCallback matchCallback) {
|
||||
|
Loading…
Reference in New Issue
Block a user