View Javadoc
1   /*
2    * MoneyWise: Finance Application
3    * Copyright 2012-2026. Tony Washer
4    *
5    * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6    * use this file except in compliance with the License.  You may obtain a copy
7    * of the License at
8    *
9    *   http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
14   * License for the specific language governing permissions and limitations under
15   * the License.
16   */
17  package io.github.tonywasher.joceanus.moneywise.quicken.file;
18  
19  import io.github.tonywasher.joceanus.moneywise.data.basic.MoneyWisePayee;
20  
21  /**
22   * Class representing a Payee.
23   *
24   * @author Tony Washer
25   */
26  public class MoneyWiseQIFPayee
27          implements Comparable<MoneyWiseQIFPayee> {
28      /**
29       * Payee name.
30       */
31      private final String theName;
32  
33      /**
34       * Constructor.
35       *
36       * @param pPayee the Payee
37       */
38      public MoneyWiseQIFPayee(final MoneyWisePayee pPayee) {
39          /* Store data */
40          theName = pPayee.getName();
41      }
42  
43      /**
44       * Constructor.
45       *
46       * @param pPayee the Payee
47       */
48      public MoneyWiseQIFPayee(final String pPayee) {
49          /* Store data */
50          theName = pPayee;
51      }
52  
53      /**
54       * Obtain the Name.
55       *
56       * @return the Name
57       */
58      public String getName() {
59          return theName;
60      }
61  
62      @Override
63      public String toString() {
64          return getName();
65      }
66  
67      @Override
68      public boolean equals(final Object pThat) {
69          /* Handle trivial cases */
70          if (this == pThat) {
71              return true;
72          }
73          if (pThat == null) {
74              return false;
75          }
76  
77          /* Check class */
78          if (!getClass().equals(pThat.getClass())) {
79              return false;
80          }
81  
82          /* Cast correctly */
83          final MoneyWiseQIFPayee myPayee = (MoneyWiseQIFPayee) pThat;
84  
85          /* Check date */
86          return theName.equals(myPayee.getName());
87      }
88  
89      @Override
90      public int hashCode() {
91          return theName.hashCode();
92      }
93  
94      @Override
95      public int compareTo(final MoneyWiseQIFPayee pThat) {
96          return theName.compareTo(pThat.getName());
97      }
98  }