/** * Sets or replaces all elements for {@link Project#getVariables() variables} list. * @param elements An iterable of variables elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("variables") @JsonIgnore public final Project.Builder variables(Iterable<? extends Variable> elements) { this.variables = ImmutableList.builder(); return addAllVariables(elements); }
private void readScript(final ImmutableProject.Builder projectBuilder, final File projectFolder) { try { currentScriptFolder = projectFolder; eventListener.startScript(currentScriptFolder.getName()); final ProjectFileReader projectFileReader = new ProjectFileReader(this, eventListener, projectFolder); final Map<String, String> actionsMap = projectFileReader.getAllActionsMap(); if (actionsMap.isEmpty()) { LOGGER.error("No action in the map. Ignore the script."); return; } final ParameterFileReader parameterFileReader = new ParameterFileReader(this, projectFileReader, projectFolder); final ImmutableUserPath.Builder userPathBuilder = ImmutableUserPath.builder(); final boolean hasAction = manageActions(projectFolder, projectFileReader, actionsMap, projectBuilder, userPathBuilder); final UserPath userPath = userPathBuilder.name(projectFileReader.getVirtualUserName()).build(); if (!hasAction) { LOGGER.error("No Init / Actions / End. Ignore the script."); return; } projectBuilder.addAllVariables(parameterFileReader.getAllVariables()).addUserPaths(userPath); } finally { eventListener.endScript(); } }
/** * 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; }