View Javadoc
1   /**
2    * Copyright 2005-2015 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.ken.service;
17  
18  import java.util.ArrayList;
19  import java.util.Collection;
20  import java.util.List;
21  
22  /**
23   * Encapsulates the number of successes and failures in a giving processing run
24   * @author Kuali Rice Team (rice.collab@kuali.org)
25   */
26  public class ProcessingResult {
27      /**
28       * List of failures
29       */
30      private List<Object> failures = new ArrayList<Object>();
31      /**
32       * List of successes
33       */
34      private List<Object> successes = new ArrayList<Object>();
35  
36      /**
37       * Returns the list of failures
38       * @return the list of failures
39       */
40      public List<?> getFailures() {
41          return failures;
42      }
43  
44      /**
45       * Returns the list of successes
46       * @return the list of successes
47       */
48      public List<?> getSuccesses() {
49          return successes;
50      }
51  
52      /**
53       * Adds a failure
54       * @param o an object representing a failure
55       */
56      public void addFailure(Object o) {
57          failures.add(o);
58      }
59  
60      /**
61       * Adds a collection of failures
62       * @param Collection a collection of failures
63       */
64      public void addAllFailures(Collection c) {
65          failures.addAll(c);
66      }
67  
68      /**
69       * Adds a success
70       * @param o an object representing a success
71       */
72      public void addSuccess(Object o) {
73          successes.add(o);
74      }
75      
76      /**
77       * Adds a collectin of successes
78       * @param Collection a collection of successes
79       */
80      public void addAllSuccesses(Collection c) {
81          successes.addAll(c);
82      }
83      
84      /**
85       * Adds the contents of the specified ProcessingResult to this ProcessingResult
86       * @param result the result to append to this result
87       */
88      public void add(ProcessingResult result) {
89          failures.addAll(result.getFailures());
90          successes.addAll(result.getSuccesses());
91      }
92      
93      /**
94       * Returns a string representation of this ProcessingResults object
95       * @see java.lang.Object#toString()
96       */
97      public String toString() {
98          return "[ProcessingResults: successes(" + successes.size() + ")=" + successes +
99                                   ", failures(" + failures.size() + ")=" + failures + "]";
100     }
101 }