All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.wnameless.spring.bulkapi.BulkResponse Maven / Gradle / Ivy

Go to download

Add bulk operations support to any Spring RESTful API by a single annotation @EnableBulkApi.

The newest version!
/**
 *
 * @author Wei-Ming Wu
 *
 *
 * Copyright 2015 Wei-Ming Wu
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 *
 */
package com.github.wnameless.spring.bulkapi;

import java.util.ArrayList;
import java.util.List;

/**
 * 
 * {@link BulkResponse} contains all bulk results in one bulk response.
 *
 */
public final class BulkResponse {

  private List results = new ArrayList();

  /**
   * Creates a {@link BulkResponse}
   */
  public BulkResponse() {}

  /**
   * Creates a {@link BulkResponse} by given results.
   * 
   * @param results
   *          a list of {@link BulkResult}s
   */
  public BulkResponse(List results) {
    this.results = results;
  }

  /**
   * Returns all results in this {@link BulkResponse}.
   * 
   * @return a list of {@link BulkResult}s
   */
  public List getResults() {
    return results;
  }

  /**
   * Sets all results in this {@link BulkResponse}.
   * 
   * @param results
   *          a list of {@link BulkResult}s
   */
  public void setResults(List results) {
    this.results = results;
  }

  @Override
  public int hashCode() {
    int result = 27;

    result = 31 ^ result + ((results == null) ? 0 : results.hashCode());

    return result;
  }

  @Override
  public boolean equals(Object obj) {
    if (obj == this) return true;
    if (obj == null) return false;
    if (!(obj instanceof BulkResponse)) return false;

    BulkResponse o = (BulkResponse) obj;

    return results == null ? o.results == null : results.equals(o.results);
  }

  @Override
  public String toString() {
    return getClass().getSimpleName() + "{results=" + results + "}";
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy