PropertyFile Class — spring-boot Architecture
Architecture documentation for the PropertyFile class in ConfigTreePropertySource.java from the spring-boot codebase.
Entity Profile
Relationship Graph
Source Code
core/spring-boot/src/main/java/org/springframework/boot/env/ConfigTreePropertySource.java lines 178–260
private static final class PropertyFile {
private static final Location START_OF_FILE = new Location(0, 0);
private final Path path;
private final FileSystemResource resource;
private final Origin origin;
private final @Nullable PropertyFileContent cachedContent;
private final boolean autoTrimTrailingNewLine;
private PropertyFile(Path path, Set<Option> options) {
this.path = path;
this.resource = new FileSystemResource(path);
this.origin = new TextResourceOrigin(this.resource, START_OF_FILE);
this.autoTrimTrailingNewLine = options.contains(Option.AUTO_TRIM_TRAILING_NEW_LINE);
this.cachedContent = options.contains(Option.ALWAYS_READ) ? null
: new PropertyFileContent(path, this.resource, this.origin, true, this.autoTrimTrailingNewLine);
}
PropertyFileContent getContent() {
if (this.cachedContent != null) {
return this.cachedContent;
}
return new PropertyFileContent(this.path, this.resource, this.origin, false, this.autoTrimTrailingNewLine);
}
Origin getOrigin() {
return this.origin;
}
static Map<String, PropertyFile> findAll(Path sourceDirectory, Set<Option> options) {
try {
Map<String, PropertyFile> propertyFiles = new TreeMap<>();
try (Stream<Path> pathStream = Files.find(sourceDirectory, MAX_DEPTH, PropertyFile::isPropertyFile,
FileVisitOption.FOLLOW_LINKS)) {
pathStream.forEach((path) -> {
String name = getName(sourceDirectory.relativize(path));
if (StringUtils.hasText(name)) {
if (options.contains(Option.USE_LOWERCASE_NAMES)) {
name = name.toLowerCase(Locale.getDefault());
}
propertyFiles.put(name, new PropertyFile(path, options));
}
});
}
return Collections.unmodifiableMap(propertyFiles);
}
catch (IOException ex) {
throw new IllegalStateException("Unable to find files in '" + sourceDirectory + "'", ex);
}
}
private static boolean isPropertyFile(Path path, BasicFileAttributes attributes) {
return !hasHiddenPathElement(path) && (attributes.isRegularFile() || attributes.isSymbolicLink());
}
private static boolean hasHiddenPathElement(Path path) {
for (Path element : path) {
if (element.toString().startsWith("..")) {
return true;
}
}
return false;
}
private static String getName(Path relativePath) {
int nameCount = relativePath.getNameCount();
if (nameCount == 1) {
return relativePath.toString();
}
StringBuilder name = new StringBuilder();
for (int i = 0; i < nameCount; i++) {
name.append((i != 0) ? "." : "");
name.append(relativePath.getName(i));
}
return name.toString();
}
}
Domain
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free