class AttachmentProcessingHelper {

    public static void setDataToFileResourcesList(List<ResourceReference> references, Map<String, InputStream> parts, String partNamePrefix)
            throws MandatoryParameterNotFoundException, IllegalParameterValueException {
        if (references != null) {
            for (int i = 0; i < references.size(); i++) {
                final ResourceReference currentReference = references.get(i);
                final String attachmentName = String.format(partNamePrefix + "[%d]", i);
                if (currentReference.isLocal() || parts.get(attachmentName) != null) {
                    setDataToFileResourceWithValidation(parts != null ? parts.get(attachmentName) : null, currentReference, attachmentName);
                }
            }
        }
    }

}