/** * 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); } }
static Builder builder() { return new Builder(); } }
/** * Creates an immutable copy of a {@link Project} value. * Uses accessors to get values to initialize the new immutable instance. * If an instance is already immutable, it is returned as is. * @param instance The instance to copy * @return A copied immutable Project instance */ public static ImmutableProject copyOf(Project instance) { if (instance instanceof ImmutableProject) { return (ImmutableProject) instance; } return new Project.Builder() .from(instance) .build(); }
/** * 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; }
@Override public synchronized Project read() { try { final ImmutableProject.Builder projectBuilder = Project.builder().name(this.projectName); final List<File> projectFolders = getProjectFolders(); final int totalScriptNumber = projectFolders.size(); eventListener.startReadingScripts(totalScriptNumber); if (projectFolders.isEmpty()) { throw new IllegalStateException("No Load Runner project found."); } for (final File projectFolder : projectFolders) { readScript(projectBuilder, projectFolder); } projectBuilder.servers(currentProjectServers.values()); return projectBuilder.build(); } finally { eventListener.endReadingScripts(); } }
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"); }
/** * 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); }
/** * 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#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#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 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#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 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#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); }