/** * Builds a new {@link ImmutableProject ImmutableProject}. * @return An immutable instance of Project * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableProject build() { return new ImmutableProject(this); } }
/** * This instance is equal to all instances of {@code ImmutableProject} that have equal attribute values. * @return {@code true} if {@code this} is equal to {@code another} instance */ @Override public boolean equals(@Nullable Object another) { if (this == another) return true; return another instanceof ImmutableProject && equalTo((ImmutableProject) another); }
private void changeBaseNameForCopiedVariables() { ImmutableProject tmpProject = (ImmutableProject) project; List<Variable> newVariableList = new ArrayList<>(); List<String> fileLst = new ArrayList<>(); if (fileToCopy == null || fileToCopy.size() == 0) { return; } fileToCopy.get("variables").forEach(var -> fileLst.add(var.getAbsolutePath())); tmpProject.getVariables().forEach(var -> { if (var instanceof FileVariable && ((FileVariable) var).getFileName().isPresent() && fileLst.contains(((FileVariable) var).getFileName().get())) { ImmutableFileVariable fileVar = (ImmutableFileVariable) var; newVariableList.add(fileVar.withFileName( FileVariableWriter.VARIABLE_DIRECTORY + File.separator + new File(fileVar.getFileName().get()).getName())); } else { newVariableList.add(var); } }); project = tmpProject.withVariables(newVariableList); }
/** * Copy the current immutable object with elements that replace the content of {@link Project#getPopulations() populations}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableProject withPopulations(Population... elements) { ImmutableList<Population> newValue = ImmutableList.copyOf(elements); return new ImmutableProject( this.name, this.sharedElements, this.userPaths, this.servers, this.variables, newValue, this.scenarios, this.projectSettings); }
/** * Copy the current immutable object with elements that replace the content of {@link Project#getUserPaths() userPaths}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableProject withUserPaths(UserPath... elements) { ImmutableList<UserPath> newValue = ImmutableList.copyOf(elements); return new ImmutableProject( this.name, this.sharedElements, newValue, this.servers, this.variables, this.populations, this.scenarios, this.projectSettings); }
/** * Copy the current immutable object with elements that replace the content of {@link Project#getScenarios() scenarios}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableProject withScenarios(Scenario... elements) { ImmutableList<Scenario> newValue = ImmutableList.copyOf(elements); return new ImmutableProject( this.name, this.sharedElements, this.userPaths, this.servers, this.variables, this.populations, newValue, this.projectSettings); }
/** * Copy the current immutable object with elements that replace the content of {@link Project#getSharedElements() sharedElements}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableProject withSharedElements(Container... elements) { ImmutableList<Container> newValue = ImmutableList.copyOf(elements); return new ImmutableProject( this.name, newValue, this.userPaths, this.servers, this.variables, this.populations, this.scenarios, this.projectSettings); }
/** * Copy the current immutable object with elements that replace the content of {@link Project#getServers() servers}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableProject withServers(Server... elements) { ImmutableList<Server> newValue = ImmutableList.copyOf(elements); return new ImmutableProject( this.name, this.sharedElements, this.userPaths, newValue, this.variables, this.populations, this.scenarios, this.projectSettings); }
/** * Copy the current immutable object with elements that replace the content of {@link Project#getVariables() variables}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableProject withVariables(Variable... elements) { ImmutableList<Variable> newValue = ImmutableList.copyOf(elements); return new ImmutableProject( this.name, this.sharedElements, this.userPaths, this.servers, newValue, this.populations, this.scenarios, this.projectSettings); }
/** * Copy the current immutable object with elements that replace the content of {@link Project#getUserPaths() userPaths}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of userPaths elements to set * @return A modified copy of {@code this} object */ public final ImmutableProject withUserPaths(Iterable<? extends UserPath> elements) { if (this.userPaths == elements) return this; ImmutableList<UserPath> newValue = ImmutableList.copyOf(elements); return new ImmutableProject( this.name, this.sharedElements, newValue, this.servers, this.variables, this.populations, this.scenarios, this.projectSettings); }
/** * Copy the current immutable object with elements that replace the content of {@link Project#getVariables() variables}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of variables elements to set * @return A modified copy of {@code this} object */ public final ImmutableProject withVariables(Iterable<? extends Variable> elements) { if (this.variables == elements) return this; ImmutableList<Variable> newValue = ImmutableList.copyOf(elements); return new ImmutableProject( this.name, this.sharedElements, this.userPaths, this.servers, newValue, this.populations, this.scenarios, this.projectSettings); }
/** * Copy the current immutable object with elements that replace the content of {@link Project#getSharedElements() sharedElements}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of sharedElements elements to set * @return A modified copy of {@code this} object */ public final ImmutableProject withSharedElements(Iterable<? extends Container> elements) { if (this.sharedElements == elements) return this; ImmutableList<Container> newValue = ImmutableList.copyOf(elements); return new ImmutableProject( this.name, newValue, this.userPaths, this.servers, this.variables, this.populations, this.scenarios, this.projectSettings); }
/** * Copy the current immutable object with elements that replace the content of {@link Project#getPopulations() populations}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of populations elements to set * @return A modified copy of {@code this} object */ public final ImmutableProject withPopulations(Iterable<? extends Population> elements) { if (this.populations == elements) return this; ImmutableList<Population> newValue = ImmutableList.copyOf(elements); return new ImmutableProject( this.name, this.sharedElements, this.userPaths, this.servers, this.variables, newValue, this.scenarios, this.projectSettings); }
/** * Copy the current immutable object with elements that replace the content of {@link Project#getServers() servers}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of servers elements to set * @return A modified copy of {@code this} object */ public final ImmutableProject withServers(Iterable<? extends Server> elements) { if (this.servers == elements) return this; ImmutableList<Server> newValue = ImmutableList.copyOf(elements); return new ImmutableProject( this.name, this.sharedElements, this.userPaths, newValue, this.variables, this.populations, this.scenarios, this.projectSettings); }
/** * Copy the current immutable object by replacing the {@link Project#getProjectSettings() projectSettings} map with the specified map. * Nulls are not permitted as keys or values. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param entries The entries to be added to the projectSettings map * @return A modified copy of {@code this} object */ public final ImmutableProject withProjectSettings(Map<String, ? extends String> entries) { if (this.projectSettings == entries) return this; ImmutableMap<String, String> newValue = ImmutableMap.copyOf(entries); return new ImmutableProject( this.name, this.sharedElements, this.userPaths, this.servers, this.variables, this.populations, this.scenarios, newValue); }
/** * Copy the current immutable object with elements that replace the content of {@link Project#getScenarios() scenarios}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of scenarios elements to set * @return A modified copy of {@code this} object */ public final ImmutableProject withScenarios(Iterable<? extends Scenario> elements) { if (this.scenarios == elements) return this; ImmutableList<Scenario> newValue = ImmutableList.copyOf(elements); return new ImmutableProject( this.name, this.sharedElements, this.userPaths, this.servers, this.variables, this.populations, newValue, this.projectSettings); }
/** * Copy the current immutable object by setting a value for the {@link Project#getName() name} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for name * @return A modified copy of the {@code this} object */ public final ImmutableProject withName(String value) { if (this.name.equals(value)) return this; String newValue = Objects.requireNonNull(value, "name"); return new ImmutableProject( newValue, this.sharedElements, this.userPaths, this.servers, this.variables, this.populations, this.scenarios, this.projectSettings); }