001 /** 002 * Copyright 2005-2013 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.rice.ken.service; 017 018 import java.util.ArrayList; 019 import java.util.Collection; 020 import java.util.List; 021 022 /** 023 * Encapsulates the number of successes and failures in a giving processing run 024 * @author Kuali Rice Team (rice.collab@kuali.org) 025 */ 026 public class ProcessingResult { 027 /** 028 * List of failures 029 */ 030 private List<Object> failures = new ArrayList<Object>(); 031 /** 032 * List of successes 033 */ 034 private List<Object> successes = new ArrayList<Object>(); 035 036 /** 037 * Returns the list of failures 038 * @return the list of failures 039 */ 040 public List<?> getFailures() { 041 return failures; 042 } 043 044 /** 045 * Returns the list of successes 046 * @return the list of successes 047 */ 048 public List<?> getSuccesses() { 049 return successes; 050 } 051 052 /** 053 * Adds a failure 054 * @param o an object representing a failure 055 */ 056 public void addFailure(Object o) { 057 failures.add(o); 058 } 059 060 /** 061 * Adds a collection of failures 062 * @param Collection a collection of failures 063 */ 064 public void addAllFailures(Collection c) { 065 failures.addAll(c); 066 } 067 068 /** 069 * Adds a success 070 * @param o an object representing a success 071 */ 072 public void addSuccess(Object o) { 073 successes.add(o); 074 } 075 076 /** 077 * Adds a collectin of successes 078 * @param Collection a collection of successes 079 */ 080 public void addAllSuccesses(Collection c) { 081 successes.addAll(c); 082 } 083 084 /** 085 * Adds the contents of the specified ProcessingResult to this ProcessingResult 086 * @param result the result to append to this result 087 */ 088 public void add(ProcessingResult result) { 089 failures.addAll(result.getFailures()); 090 successes.addAll(result.getSuccesses()); 091 } 092 093 /** 094 * Returns a string representation of this ProcessingResults object 095 * @see java.lang.Object#toString() 096 */ 097 public String toString() { 098 return "[ProcessingResults: successes(" + successes.size() + ")=" + successes + 099 ", failures(" + failures.size() + ")=" + failures + "]"; 100 } 101 }