Fix the boiler plate codes
[framework/osp/social.git] / src / FScl_PhoneNumberImpl.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Apache 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.apache.org/licenses/LICENSE-2.0
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 /**
17 * @file         FScl_PhoneNumberImpl.cpp
18 * @brief                This is the implementation for _PhoneNumberImpl class.
19 *
20 * This file contains definitions of @e _PhoneNumberImpl class.
21 */
22
23 #include <unique_ptr.h>
24 #include <FSclPhoneNumber.h>
25 #include <FBaseSysLog.h>
26 #include <FBase_StringConverter.h>
27 #include "FScl_PhoneNumberImpl.h"
28
29 using namespace Tizen::Base;
30
31 namespace Tizen { namespace Social
32 {
33
34 _PhoneNumberImpl::_PhoneNumberImpl(void)
35 : __recordId(-1)
36 , __type(PHONENUMBER_TYPE_HOME)
37 {
38
39 }
40
41 _PhoneNumberImpl::_PhoneNumberImpl(PhoneNumberType type, const String& number)
42 : __recordId(-1)
43 , __type(type)
44 , __number(number)
45 {
46
47 }
48
49 _PhoneNumberImpl::_PhoneNumberImpl(const _PhoneNumberImpl& rhs)
50 {
51         __recordId = rhs.__recordId;
52         __type = rhs.__type;
53         __label = rhs.__label;
54         __number = rhs.__number;
55 }       
56
57 _PhoneNumberImpl::~_PhoneNumberImpl(void)
58 {
59
60 }
61
62 _PhoneNumberImpl&
63 _PhoneNumberImpl::operator =(const _PhoneNumberImpl& rhs)
64 {
65         if (this == &rhs)
66         {
67                 return *this;
68         }
69
70         __recordId = rhs.__recordId;
71         __type = rhs.__type;
72         __label = rhs.__label;
73         __number = rhs.__number;
74
75         return *this;
76 }
77
78 bool
79 _PhoneNumberImpl::operator ==(const _PhoneNumberImpl& rhs) const
80 {
81         if (__type != rhs.__type || __label != rhs.__label || __number != rhs.__number)
82         {
83                 return false;
84         }
85         
86         return true;
87 }
88
89 bool
90 _PhoneNumberImpl::Equals(const Object& rhs) const
91 {
92         const _PhoneNumberImpl* pPhoneNumberImpl = dynamic_cast<const _PhoneNumberImpl*>(&rhs);
93
94         if (pPhoneNumberImpl == null)
95         {
96                 return false;
97         }
98
99         return (*this == *pPhoneNumberImpl);
100 }
101
102 int
103 _PhoneNumberImpl::GetHashCode(void) const
104 {
105         int hashCode = __recordId;
106         hashCode += __type;
107         hashCode += __number.GetHashCode();
108         hashCode += __label.GetHashCode();
109
110         return hashCode;
111 }
112
113 bool
114 _PhoneNumberImpl::operator !=(const _PhoneNumberImpl& rhs) const
115 {
116         return !(*this == rhs);
117 }
118
119 PhoneNumberType
120 _PhoneNumberImpl::GetType(void) const
121 {
122         return __type;
123 }
124
125 String
126 _PhoneNumberImpl::GetPhoneNumber(void) const
127 {
128         return __number;
129 }
130
131 void
132 _PhoneNumberImpl::SetType(PhoneNumberType type)
133 {
134         __type = type;
135 }
136
137 result
138 _PhoneNumberImpl::SetPhoneNumber(const String& number)
139 {
140         SysTryReturn(NID_SCL, !number.IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The phone number is empty.", GetErrorMessage(E_INVALID_ARG));
141
142         __number = number;
143
144         return E_SUCCESS;
145 }
146
147 void
148 _PhoneNumberImpl::SetLabel(const String& label)
149 {
150         __label = label;
151 }
152
153 String
154 _PhoneNumberImpl::GetLabel(void) const
155 {
156         return __label;
157 }
158
159 void
160 _PhoneNumberImpl::SetRecordId(int recordId)
161 {
162         __recordId = recordId;
163 }
164
165 int
166 _PhoneNumberImpl::GetRecordId(void) const
167 {
168         return __recordId;
169 }
170
171 bool
172 _PhoneNumberImpl::IsEmpty(void) const
173 {
174         return __number.IsEmpty();
175 }
176
177 _PhoneNumberImpl*
178 _PhoneNumberImpl::GetInstance(PhoneNumber& phoneNumber)
179 {
180         return phoneNumber.__pPhoneNumberImpl;
181 }
182
183 const _PhoneNumberImpl*
184 _PhoneNumberImpl::GetInstance(const PhoneNumber& phoneNumber)
185 {
186         return phoneNumber.__pPhoneNumberImpl;
187 }
188
189 }} // Tizen::Social