001/*
002 * Copyright 2012-2016 UnboundID Corp.
003 *
004 * This program is free software; you can redistribute it and/or modify
005 * it under the terms of the GNU General Public License (GPLv2 only)
006 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
007 * as published by the Free Software Foundation.
008 *
009 * This program is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012 * GNU General Public License for more details.
013 *
014 * You should have received a copy of the GNU General Public License
015 * along with this program; if not, see <http://www.gnu.org/licenses>.
016 */
017
018package com.unboundid.scim.sdk;
019
020import com.unboundid.scim.marshal.Marshaller;
021
022import java.io.OutputStream;
023import java.util.ArrayList;
024import java.util.Iterator;
025import java.util.List;
026
027
028
029/**
030 * This class represents the response to a bulk request.
031 */
032public class BulkResponse implements SCIMResponse, Iterable<BulkOperation>
033{
034  private final List<BulkOperation> operations;
035
036
037
038  /**
039   * Create a new bulk response.
040   *
041   * @param operations  The operations responses.
042   */
043  public BulkResponse(final List<BulkOperation> operations)
044  {
045    this.operations = new ArrayList<BulkOperation>(operations);
046  }
047
048
049
050  /**
051   * {@inheritDoc}
052   */
053  public void marshal(final Marshaller marshaller,
054                      final OutputStream outputStream)
055      throws Exception
056  {
057    marshaller.bulkMarshal(outputStream, -1, operations);
058  }
059
060
061
062  /**
063   * {@inheritDoc}
064   */
065  public Iterator<BulkOperation> iterator()
066  {
067    return operations.iterator();
068  }
069}