@Test public void supports_multi_level_flags_directory() { var archive = SystemFlagsDataArchive.fromDirectory(Paths.get("src/test/resources/system-flags-multi-level/")); assertFlagDataHasValue(archive, MY_TEST_FLAG, mainControllerTarget, "default"); }
public static SystemFlagsDataArchive fromDirectory(Path directory) { Path root = directory.toAbsolutePath(); Path flagsDirectory = directory.resolve("flags"); if (!Files.isDirectory(flagsDirectory)) { throw new IllegalArgumentException("Sub-directory 'flags' does not exist: " + flagsDirectory); } try (Stream<Path> directoryStream = Files.walk(root)) { Builder builder = new Builder(); directoryStream.forEach(absolutePath -> { Path relativePath = root.relativize(absolutePath); if (!Files.isDirectory(absolutePath) && relativePath.startsWith("flags")) { String rawData = uncheck(() -> Files.readString(absolutePath, StandardCharsets.UTF_8)); addFile(builder, rawData, relativePath); } }); return builder.build(); } catch (IOException e) { throw new UncheckedIOException(e); } }
SystemFlagsDataArchive { public static SystemFlagsDataArchive fromDirectory(Path directory) { Path root = directory.toAbsolutePath(); Path flagsDirectory = directory.resolve("flags"); if (!Files.isDirectory(flagsDirectory)) { throw new IllegalArgumentException("Sub-directory 'flags' does not exist: " + flagsDirectory); } try (Stream<Path> directoryStream = Files.walk(root)) { Builder builder = new Builder(); directoryStream.forEach(absolutePath -> { Path relativePath = root.relativize(absolutePath); if (!Files.isDirectory(absolutePath) && relativePath.startsWith("flags")) { String rawData = uncheck(() -> Files.readString(absolutePath, StandardCharsets.UTF_8)); addFile(builder, rawData, relativePath); } }); return builder.build(); } catch (IOException e) { throw new UncheckedIOException(e); } } }
SystemFlagsDataArchive { public static SystemFlagsDataArchive fromDirectory(Path directory) { Path root = directory.toAbsolutePath(); Path flagsDirectory = directory.resolve("flags"); if (!Files.isDirectory(flagsDirectory)) { throw new IllegalArgumentException("Sub-directory 'flags' does not exist: " + flagsDirectory); } try (Stream<Path> directoryStream = Files.walk(root)) { Builder builder = new Builder(); directoryStream.forEach(absolutePath -> { Path relativePath = root.relativize(absolutePath); if (!Files.isDirectory(absolutePath) && relativePath.startsWith("flags")) { String rawData = uncheck(() -> Files.readString(absolutePath, StandardCharsets.UTF_8)); addFile(builder, rawData, relativePath); } }); return builder.build(); } catch (IOException e) { throw new UncheckedIOException(e); } } private  SystemFlagsDataArchive(Map<FlagId, Map<String, FlagData>> files); }
SystemFlagsDataArchive { public static SystemFlagsDataArchive fromDirectory(Path directory) { Path root = directory.toAbsolutePath(); Path flagsDirectory = directory.resolve("flags"); if (!Files.isDirectory(flagsDirectory)) { throw new IllegalArgumentException("Sub-directory 'flags' does not exist: " + flagsDirectory); } try (Stream<Path> directoryStream = Files.walk(root)) { Builder builder = new Builder(); directoryStream.forEach(absolutePath -> { Path relativePath = root.relativize(absolutePath); if (!Files.isDirectory(absolutePath) && relativePath.startsWith("flags")) { String rawData = uncheck(() -> Files.readString(absolutePath, StandardCharsets.UTF_8)); addFile(builder, rawData, relativePath); } }); return builder.build(); } catch (IOException e) { throw new UncheckedIOException(e); } } private  SystemFlagsDataArchive(Map<FlagId, Map<String, FlagData>> files); static SystemFlagsDataArchive fromZip(InputStream rawIn); static SystemFlagsDataArchive fromDirectory(Path directory); void toZip(OutputStream out); Set<FlagData> flagData(FlagsTarget target); void validateAllFilesAreForTargets(SystemName currentSystem, Set<FlagsTarget> targets); }
SystemFlagsDataArchive { public static SystemFlagsDataArchive fromDirectory(Path directory) { Path root = directory.toAbsolutePath(); Path flagsDirectory = directory.resolve("flags"); if (!Files.isDirectory(flagsDirectory)) { throw new IllegalArgumentException("Sub-directory 'flags' does not exist: " + flagsDirectory); } try (Stream<Path> directoryStream = Files.walk(root)) { Builder builder = new Builder(); directoryStream.forEach(absolutePath -> { Path relativePath = root.relativize(absolutePath); if (!Files.isDirectory(absolutePath) && relativePath.startsWith("flags")) { String rawData = uncheck(() -> Files.readString(absolutePath, StandardCharsets.UTF_8)); addFile(builder, rawData, relativePath); } }); return builder.build(); } catch (IOException e) { throw new UncheckedIOException(e); } } private  SystemFlagsDataArchive(Map<FlagId, Map<String, FlagData>> files); static SystemFlagsDataArchive fromZip(InputStream rawIn); static SystemFlagsDataArchive fromDirectory(Path directory); void toZip(OutputStream out); Set<FlagData> flagData(FlagsTarget target); void validateAllFilesAreForTargets(SystemName currentSystem, Set<FlagsTarget> targets);  }