PomCondition Class — spring-boot Architecture
Architecture documentation for the PomCondition class in PomCondition.java from the spring-boot codebase.
Entity Profile
Source Code
build-plugin/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/PomCondition.java lines 36–110
class PomCondition extends Condition<File> {
private final Set<String> expectedContents;
private final Set<String> notExpectedContents;
PomCondition() {
this(new HashSet<>(), new HashSet<>());
}
private PomCondition(Set<String> expectedContents, Set<String> notExpectedContents) {
super(new TextDescription("Pom file containing %s and not containing %s", expectedContents,
notExpectedContents));
this.expectedContents = expectedContents;
this.notExpectedContents = notExpectedContents;
}
@Override
public boolean matches(File pom) {
try {
String contents = FileCopyUtils.copyToString(new FileReader(pom));
for (String expected : this.expectedContents) {
if (!contents.contains(expected)) {
return false;
}
}
for (String notExpected : this.notExpectedContents) {
if (contents.contains(notExpected)) {
return false;
}
}
}
catch (IOException ex) {
throw new RuntimeException(ex);
}
return true;
}
@Override
public Description description() {
return new TextDescription("Pom file containing %s and not containing %s", this.expectedContents,
this.notExpectedContents);
}
PomCondition groupId(String groupId) {
this.expectedContents.add(String.format("<groupId>%s</groupId>", groupId));
return this;
}
PomCondition artifactId(String artifactId) {
this.expectedContents.add(String.format("<artifactId>%s</artifactId>", artifactId));
return this;
}
PomCondition version(String version) {
this.expectedContents.add(String.format("<version>%s</version>", version));
return this;
}
PomCondition packaging(String packaging) {
this.expectedContents.add(String.format("<packaging>%s</packaging>", packaging));
return this;
}
PomCondition noDependencies() {
this.notExpectedContents.add("<dependencies>");
return this;
}
PomCondition noPackaging() {
this.notExpectedContents.add("<packaging>");
return this;
}
}
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free