/** * Format this AbstractResourceCollectionWrapper as a String. * @return a descriptive <code>String</code>. */ @Override public synchronized String toString() { if (isReference()) { return getCheckedRef().toString(); } if (isEmpty()) { return ""; } return stream().map(Object::toString) .collect(Collectors.joining(File.pathSeparator)); }
/** * Fulfill the ResourceCollection contract. * @return number of elements as int. */ @Override public synchronized int size() { if (isReference()) { return ((AbstractResourceCollectionWrapper) getCheckedRef()).size(); } dieOnCircularReference(); return getSize(); }
/** * Fulfill the ResourceCollection contract. * @return an Iterator of Resources. */ @Override public final synchronized Iterator<Resource> iterator() { if (isReference()) { return ((AbstractResourceCollectionWrapper) getCheckedRef()).iterator(); } dieOnCircularReference(); return new FailFast(this, createIterator()); }
/** * Overrides the version of DataType to recurse on all DataType * child elements that may have been added. * @param stk the stack of data types to use (recursively). * @param p the project to use to dereference the references. * @throws BuildException on error. */ protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) throws BuildException { if (isChecked()) { return; } if (isReference()) { super.dieOnCircularReference(stk, p); } else { if (rc instanceof DataType) { pushAndInvokeCircularReferenceCheck((DataType) rc, stk, p); } setChecked(true); } }
/** * Fulfill the ResourceCollection contract. * @return whether this is a filesystem-only resource collection. */ public synchronized boolean isFilesystemOnly() { if (isReference()) { return ((BaseResourceCollectionContainer) getCheckedRef()).isFilesystemOnly(); } dieOnCircularReference(); if (rc == null || rc.isFilesystemOnly()) { return true; } /* now check each Resource in case the child only lets through files from any children IT may have: */ for (Resource r : this) { if (r.as(FileProvider.class) == null) { return false; } } return true; }
/** * Add a ResourceCollection to the container. * @param c the ResourceCollection to add. * @throws BuildException on error. */ public synchronized void add(ResourceCollection c) throws BuildException { if (isReference()) { throw noChildrenAllowed(); } if (c == null) { return; } if (rc != null) { throw oneNested(); } rc = c; if (Project.getProject(rc) == null) { Project p = getProject(); if (p != null) { p.setProjectReference(rc); } } setChecked(false); }