private ImmutableProject(ImmutableProject.Builder builder) { this.sharedElements = builder.sharedElements.build(); this.userPaths = builder.userPaths.build(); this.servers = builder.servers.build(); this.variables = builder.variables.build(); this.populations = builder.populations.build(); this.scenarios = builder.scenarios.build(); this.projectSettings = builder.projectSettings.build(); this.name = builder.name != null ? builder.name : Objects.requireNonNull(Project.super.getName(), "name"); }
public void write(final boolean zipConfig, @Nullable final String projectVersion, @Nullable final String productVersion) { try { final File f = new File(nlProjectFolder); if (!f.exists()) { logger.info("Output folder does not exist, creating it."); Files.createDirectories(Paths.get(nlProjectFolder)); } else if (f.isFile()) { logger.error("The destination is not a directory, migration aborted."); return; } writeXML(zipConfig); final String safeProjectVersion = ofNullable(validateVersion(projectVersion, 2)).orElse(DEFAULT_PROJECT_VERSION); final String safeProductVersion = ofNullable(validateVersion(productVersion, 3)).orElse(DEFAULT_PRODUCT_VERSION); writeNLP(project.getName(), zipConfig, safeProjectVersion, safeProductVersion); logger.info("Project saved."); } catch (ParserConfigurationException | TransformerException | IOException e) { logger.error("Error writing project.", e); } }
/** * Fill a builder with attribute values from the provided {@code Project} instance. * Regular attribute values will be replaced with those from the given instance. * Absent optional values will not replace present values. * Collection elements and entries will be added, not replaced. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Project.Builder from(Project instance) { Objects.requireNonNull(instance, "instance"); name(instance.getName()); addAllSharedElements(instance.getSharedElements()); addAllUserPaths(instance.getUserPaths()); addAllServers(instance.getServers()); addAllVariables(instance.getVariables()); addAllPopulations(instance.getPopulations()); addAllScenarios(instance.getScenarios()); putAllProjectSettings(instance.getProjectSettings()); return (Project.Builder) this; }