@Override public int hashCode() { int hash = 7; hash = 31 * hash + Objects.hashCode(id); hash = 31 * hash + Objects.hashCode(name); hash = 31 * hash + Objects.hashCode(description); hash = 31 * hash + Objects.hashCode(defaultEnv); hash = 31 * hash + getCommands().hashCode(); hash = 31 * hash + getProjects().hashCode(); hash = 31 * hash + getEnvironments().hashCode(); hash = 31 * hash + getAttributes().hashCode(); return hash; }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof WorkspaceConfigImpl)) { return false; } final WorkspaceConfigImpl that = (WorkspaceConfigImpl) obj; return Objects.equals(id, that.id) && Objects.equals(name, that.name) && Objects.equals(description, that.description) && Objects.equals(defaultEnv, that.defaultEnv) && getCommands().equals(that.getCommands()) && getProjects().equals(that.getProjects()) && getEnvironments().equals(that.getEnvironments()) && getAttributes().equals(that.getAttributes()); }
private String getValidatedEnvironmentName(WorkspaceImpl workspace, @Nullable String envName) throws NotFoundException, ServerException { if (envName != null && !workspace.getConfig().getEnvironments().containsKey(envName)) { throw new NotFoundException( format( "Workspace '%s:%s' doesn't contain environment '%s'", workspace.getNamespace(), workspace.getConfig().getName(), envName)); } envName = firstNonNull(envName, workspace.getConfig().getDefaultEnv()); if (envName == null && SidecarToolingWorkspaceUtil.isSidecarBasedWorkspace( workspace.getConfig().getAttributes())) { // Sidecar-based workspaces are allowed not to have any environments return null; } // validate environment in advance if (envName == null) { throw new NotFoundException( format( "Workspace %s:%s can't use null environment", workspace.getNamespace(), workspace.getConfig().getName())); } try { runtimes.validate(workspace.getConfig().getEnvironments().get(envName)); } catch (InfrastructureException | ValidationException e) { throw new ServerException(e); } return envName; }