View Javadoc
1   /*
2    * The Kuali Financial System, a comprehensive financial management system for higher education.
3    * 
4    * Copyright 2005-2014 The Kuali Foundation
5    * 
6    * This program is free software: you can redistribute it and/or modify
7    * it under the terms of the GNU Affero General Public License as
8    * published by the Free Software Foundation, either version 3 of the
9    * License, or (at your option) any later version.
10   * 
11   * This program is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   * GNU Affero General Public License for more details.
15   * 
16   * You should have received a copy of the GNU Affero General Public License
17   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18   */
19  package org.kuali.kfs.module.ar.businessobject;
20  
21  import java.util.Arrays;
22  import java.util.LinkedHashMap;
23  
24  import org.apache.commons.lang.StringUtils;
25  import org.kuali.kfs.module.ar.ArKeyConstants;
26  import org.kuali.kfs.module.ar.ArPropertyConstants;
27  import org.kuali.kfs.sys.KFSPropertyConstants;
28  import org.kuali.kfs.sys.ObjectUtil;
29  import org.kuali.kfs.sys.context.SpringContext;
30  import org.kuali.rice.core.api.config.property.ConfigurationService;
31  import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
32  import org.kuali.rice.krad.util.ObjectUtils;
33  
34  public class InvoiceSuspensionCategory extends PersistableBusinessObjectBase {
35  
36      private String documentNumber;
37      private String suspensionCategoryCode;
38  
39      public InvoiceSuspensionCategory() {
40          super();
41      }
42  
43      /**
44       * Constructor that uses document number and a suspension category code.
45       * @param documentNumber
46       * @param suspensionCategoryCode
47       */
48      public InvoiceSuspensionCategory(String documentNumber, String suspensionCategoryCode) {
49          this.documentNumber = documentNumber;
50          this.suspensionCategoryCode = suspensionCategoryCode;
51      }
52  
53      /**
54       * Gets the documentNumber attribute.
55       *
56       * @return Returns the documentNumber
57       */
58      public String getDocumentNumber() {
59          return documentNumber;
60      }
61  
62      /**
63       * Sets the documentNumber attribute value.
64       *
65       * @param documentNumber The documentNumber to set.
66       */
67      public void setDocumentNumber(String documentNumber) {
68          this.documentNumber = documentNumber;
69      }
70  
71      /**
72       * Gets the suspensionCategoryCode attribute.
73       *
74       * @return Returns the suspensionCategoryCode
75       */
76      public String getSuspensionCategoryCode() {
77          return suspensionCategoryCode;
78      }
79  
80      /**
81       * Sets the suspensionCategoryCode attribute value.
82       *
83       * @param suspensionCategoryCode The suspensionCategoryCode to set.
84       */
85      public void setSuspensionCategoryCode(String suspensionCategoryCode) {
86          this.suspensionCategoryCode = suspensionCategoryCode;
87      }
88  
89      /**
90       * Gets the suspensionCategoryDescription attribute.
91       *
92       * @return Returns the suspensionCategoryDescription
93       */
94      public String getSuspensionCategoryDescription() {
95          return SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(ArKeyConstants.INVOICE_DOCUMENT_SUSPENSION_CATEGORY + suspensionCategoryCode);
96      }
97  
98      /**
99       * @see java.lang.Object#equals(java.lang.Object)
100      */
101     @Override
102     public boolean equals(Object obj) {
103         if (ObjectUtils.isNotNull(obj)) {
104             if (this.getClass().equals(obj.getClass())) {
105                 InvoiceSuspensionCategory other = (InvoiceSuspensionCategory) obj;
106                 return (StringUtils.equalsIgnoreCase(this.documentNumber, other.documentNumber) &&
107                         StringUtils.equalsIgnoreCase(this.suspensionCategoryCode, other.suspensionCategoryCode));
108             }
109         }
110         return false;
111     }
112 
113     /**
114      * @see java.lang.Object#hashCode()
115      */
116     @Override
117     public int hashCode() {
118         return ObjectUtil.generateHashCode(this, Arrays.asList(KFSPropertyConstants.DOCUMENT_NUMBER, ArPropertyConstants.SuspensionCategoryReportFields.SUSPENSION_CATEGORY_CODE));
119     }
120 
121     /**
122      * @see org.kuali.rice.krad.bo.BusinessObjectBase#toStringMapper()
123      */
124     protected LinkedHashMap toStringMapper_RICE20_REFACTORME() {
125         LinkedHashMap m = new LinkedHashMap();
126         m.put(KFSPropertyConstants.DOCUMENT_NUMBER, getDocumentNumber());
127         m.put("suspensionCategoryCode", getSuspensionCategoryCode());
128         return m;
129     }
130 }