/** * {@inheritDoc} */ @Override public int size() { if (isReference()) { return getCheckedRef().size(); } checkInitialized(); return cacheCollection().size(); }
private void checkInitialized() { if (nested == null) { throw new BuildException( "A nested resource collection element is required", getLocation()); } dieOnCircularReference(); }
private synchronized Collection<Resource> cacheCollection() { if (cachedColl == null || !cache) { cachedColl = getCollection(); } return cachedColl; }
/** * {@inheritDoc} */ @Override public boolean isFilesystemOnly() { if (isReference()) { return getCheckedRef().isFilesystemOnly(); } checkInitialized(); return false; }
/** * {@inheritDoc} */ @Override public Iterator<Resource> iterator() { if (isReference()) { return getCheckedRef().iterator(); } checkInitialized(); return cacheCollection().iterator(); }
/** * Adds the required nested ResourceCollection. * @param c the ResourceCollection to add. * @throws BuildException on error. */ public synchronized void add(ResourceCollection c) throws BuildException { if (isReference()) { throw noChildrenAllowed(); } if (nested != null) { throw new BuildException("Only one resource collection can be" + " nested into mappedresources", getLocation()); } setChecked(false); cachedColl = null; nested = c; }
/** * 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. */ @Override protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) throws BuildException { if (isChecked()) { return; } if (isReference()) { super.dieOnCircularReference(stk, p); } else { checkInitialized(); if (mapper != null) { pushAndInvokeCircularReferenceCheck(mapper, stk, p); } if (nested instanceof DataType) { pushAndInvokeCircularReferenceCheck((DataType) nested, stk, p); } setChecked(true); } }
/** * Format this resource collection as a String. * @return a descriptive <code>String</code>. */ @Override public String toString() { if (isReference()) { return getCheckedRef().toString(); } return isEmpty() ? "" : stream().map(Object::toString) .collect(Collectors.joining(File.pathSeparator)); }
zfs.setIncludes("WEB-INF/classes/"); MappedResourceCollection mapper = new MappedResourceCollection(); mapper.add(zfs); mapper.add(gm);
/** * Add a nested filenamemapper. * @param fileNameMapper the mapper to add. * @since Ant 1.6.3 */ public void add(FileNameMapper fileNameMapper) { createMapper().add(fileNameMapper); }
/** * Define the mapper to map source to destination files. * @return a mapper to be configured. * @exception BuildException if more than one mapper is defined. */ public Mapper createMapper() throws BuildException { if (isReference()) { throw noChildrenAllowed(); } if (mapper != null) { throw new BuildException("Cannot define more than one mapper", getLocation()); } setChecked(false); mapper = new Mapper(getProject()); cachedColl = null; return mapper; }
zfs.setIncludes("WEB-INF/classes/"); MappedResourceCollection mapper = new MappedResourceCollection(); mapper.add(zfs); mapper.add(gm);