]> git.mxchange.org Git - jcontacts-business-core.git/blob - src/org/mxchange/jcontactsbusiness/model/basicdata/BasicDataUtils.java
Updated copyright year
[jcontacts-business-core.git] / src / org / mxchange / jcontactsbusiness / model / basicdata / BasicDataUtils.java
1 /*
2  * Copyright (C) 2020 Free Software Foundation
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 package org.mxchange.jcontactsbusiness.model.basicdata;
18
19 import java.io.Serializable;
20 import java.util.Objects;
21
22 /**
23  * An utilities class for basic company data
24  * <p>
25  * @author Roland Häder<roland@mxchange.org>
26  */
27 public class BasicDataUtils implements Serializable {
28
29         /**
30          * Serial number
31          */
32         private static final long serialVersionUID = 159_847_673_672_091L;
33
34         /**
35          * Compares both basic company data instances. This method returns -1 if
36          * second instance is null.
37          * <p>
38          * @param basicData1 Basic company data instance 1
39          * @param basicData2 Basic company data instance 2
40          * <p>
41          * @return Comparison value
42          */
43         public static int compare (final BasicData basicData1, final BasicData basicData2) {
44                 // Check euqality, then at least first must be given
45                 if (Objects.equals(basicData1, basicData2)) {
46                         // Both are same
47                         return 0;
48                 } else if (null == basicData1) {
49                         // First is null
50                         return -1;
51                 } else if (null == basicData2) {
52                         // Second is null
53                         return 1;
54                 }
55
56                 // Invoke compareTo() method
57                 return basicData1.compareTo(basicData2);
58         }
59
60         /**
61          * Utility classes should not have instances
62          */
63         private BasicDataUtils () {
64                 // Private constructor
65         }
66
67 }