View Javadoc
1   /*
2    * Copyright (c) 2011-2024 PrimeFaces Extensions
3    *
4    *  Permission is hereby granted, free of charge, to any person obtaining a copy
5    *  of this software and associated documentation files (the "Software"), to deal
6    *  in the Software without restriction, including without limitation the rights
7    *  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    *  copies of the Software, and to permit persons to whom the Software is
9    *  furnished to do so, subject to the following conditions:
10   *
11   *  The above copyright notice and this permission notice shall be included in
12   *  all copies or substantial portions of the Software.
13   *
14   *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   *  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   *  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20   *  THE SOFTWARE.
21   */
22  package org.primefaces.extensions.model.inputphone;
23  
24  import java.io.Serializable;
25  import java.util.Objects;
26  
27  /**
28   * Model object for country handling of InputPhone.
29   *
30   * @author Jasper de Vries <jepsar@gmail.com>
31   * @since 7.0
32   */
33  public class Country implements Serializable {
34  
35      private static final long serialVersionUID = 1L;
36  
37      private final String name;
38      private final String iso2;
39      private final String dialCode;
40  
41      public Country(String name, String iso2, String dialCode) {
42          this.name = name;
43          this.iso2 = iso2;
44          this.dialCode = dialCode;
45      }
46  
47      public String getName() {
48          return name;
49      }
50  
51      public String getIso2() {
52          return iso2;
53      }
54  
55      public String getDialCode() {
56          return dialCode;
57      }
58  
59      @Override
60      public int hashCode() {
61          return Objects.hash(name, iso2, dialCode);
62      }
63  
64      @Override
65      public boolean equals(Object obj) {
66          if (this == obj) {
67              return true;
68          }
69          if (obj == null) {
70              return false;
71          }
72          if (getClass() != obj.getClass()) {
73              return false;
74          }
75          final Country other = (Country) obj;
76          if (!Objects.equals(name, other.getName())) {
77              return false;
78          }
79          if (!Objects.equals(iso2, other.getIso2())) {
80              return false;
81          }
82          return Objects.equals(dialCode, other.getDialCode());
83      }
84  
85      @Override
86      public String toString() {
87          return "Country{" + "name=" + name + ", iso2=" + iso2 + ", dialCode=" + dialCode + '}';
88      }
89  
90  }