Refine search
protected PersistedList(Collection<? extends T> initialList) { data.replaceBy(initialList); }
/** * Gets all the {@link Describable}s in an array. */ public <T> T[] toArray(T[] array) { return data.toArray(array); }
/** @deprecated Use {@link Extension} instead. */ @Deprecated public final void register() { Jenkins.getInstance().getSCMListeners().add(this); }
/** * A convenience method to replace a single item. * * This method shouldn't be used when you are replacing a lot of stuff * as copy-on-write semantics make this rather slow. */ public void replace(T from, T to) throws IOException { List<T> copy = new ArrayList<T>(data.getView()); for (int i=0; i<copy.size(); i++) { if (copy.get(i).equals(from)) copy.set(i,to); } data.replaceBy(copy); }
/** * @return list of cascading {@link JobProperty} instances. Includes {@link ParametersDefinitionProperty} and * children of {@link JobProperty} from external plugins. */ private CopyOnWriteList getCascadingJobProperties() { CopyOnWriteList result = new CopyOnWriteList(); CopyOnWriteList<ParametersDefinitionProperty> definitionProperties = getParameterDefinitionProperties(); if (null != cascadingJobProperties && !cascadingJobProperties.isEmpty()) { for (String key : cascadingJobProperties) { IProjectProperty projectProperty = CascadingUtil.getProjectProperty(this, key); Object value = projectProperty.getValue(); if (null != value) { result.add(value); } } } if (null != definitionProperties && !definitionProperties.isEmpty()) { result.addAll(definitionProperties.getView()); } return result; }
/** * {@inheritDoc} */ @Override public void configure(StaplerRequest req, JSONObject formData) throws IOException, ServletException, FormException { if (req.hasParameter(APIV2_ISSUE_KEY_PATTERN) && StringUtils.isNotBlank(req.getParameter(APIV2_ISSUE_KEY_PATTERN))) { issuesCache.setIssueKeyRegex(req.getParameter(APIV2_ISSUE_KEY_PATTERN)); IssueIndexingThread.invoke(); } String[] newPatterns = req.getParameterValues(APIV2_PATTERN_KEY); if (newPatterns != null && !Arrays.equals(newPatterns, patterns.toArray(new String[patterns.size()]))) { // TODO Also trigger a full index rescan patterns.replaceBy(newPatterns); save(); } }
public void replaceBy(Collection<? extends T> col) throws IOException { data.replaceBy(col); onModified(); }
/** * Returns the snapshot view of instances as list. */ public List<T> toList() { return data.getView(); }
/** * Migration logic from plaintext login and pass sites to sites using credentials<br> * Called by XStream each time just after unmarshaling fields from XML<br> * Jenkins by default will persist migrated sites on shutdown or after global config save. */ private Object readResolve() { boolean madeChanges = false; final List<CredentialsSSHSite> migratedCredentials = new ArrayList<CredentialsSSHSite>(sites.size()); for (CredentialsSSHSite site : sites) { try { final CredentialsSSHSite migrated = CredentialsSSHSite.migrateToCredentials(site); migratedCredentials.add(migrated); madeChanges = madeChanges || (migrated != site); } catch (InterruptedException e) { throw new IllegalStateException("Failed to migrate site: " + site, e); } catch (IOException e) { throw new IllegalStateException("Failed to migrate site: " + site, e); } } if (madeChanges) { sites.replaceBy(migratedCredentials); } return this; } }
public void removeAll(Class<? extends T> type) throws IOException { boolean modified=false; for (T t : data) { if(t.getClass()==type) { data.remove(t); modified=true; } } if(modified) onModified(); }
/** * Rebuilds the list of {@link UserDefinedGlobalVariable}s and update {@link ExtensionList} accordingly. */ public synchronized void rebuild() { File[] children = new File(repo.workspace,UserDefinedGlobalVariable.PREFIX).listFiles(); if (children==null) children = new File[0]; List<GlobalVariable> list = new ArrayList<GlobalVariable>(); for (File child : children) { if (!child.getName().endsWith(".groovy") || child.isDirectory()) continue; UserDefinedGlobalVariable uv = new UserDefinedGlobalVariable(repo,FilenameUtils.getBaseName(child.getName())); list.add(uv); } // first time, build the initial list if (ours==null) ours = new CopyOnWriteList<GlobalVariable>(); ours.replaceBy(list); }
public void addAll(Collection<? extends T> items) throws IOException { data.addAll(items); onModified(); }
@WithBridgeMethods(void.class) public boolean add(T item) { data.add(item); _onModified(); return true; }
/** * List of all {@link JobProperty} exposed primarily for the remoting API. * List contains cascadable {@link JobProperty} if any. * @since 2.2.0 */ @Exported(name = "property", inline = true) public List<JobProperty<? super JobT>> getAllProperties() { CopyOnWriteList cascadingJobProperties = getCascadingJobProperties(); List<JobProperty<? super JobT>> result = properties.getView(); if (null != cascadingJobProperties && !cascadingJobProperties.isEmpty()) { result = Collections.unmodifiableList(ListUtils.union(result, cascadingJobProperties.getView())); } return result; }
public int size() { return data.size(); }
public boolean isEmpty() { return data.isEmpty(); }
@SuppressWarnings("unchecked") public CopyOnWriteList unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { // read the items from xml into a list List items = new ArrayList(); while (reader.hasMoreChildren()) { reader.moveDown(); try { Object item = readItem(reader, context, items); items.add(item); } catch (CriticalXStreamException e) { throw e; } catch (XStreamException e) { RobustReflectionConverter.addErrorInContext(context, e); } catch (LinkageError e) { RobustReflectionConverter.addErrorInContext(context, e); } reader.moveUp(); } return new CopyOnWriteList(items,true); } }