-
Notifications
You must be signed in to change notification settings - Fork 148
/
metadata_util.go
42 lines (38 loc) · 1.1 KB
/
metadata_util.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package phonenumbers
// merge merges two number formats
func (nf *NumberFormat) merge(other *NumberFormat) {
if other.Pattern != nil {
nf.Pattern = other.Pattern
}
if other.Format != nil {
nf.Format = other.Format
}
for i := 0; i < len(other.LeadingDigitsPattern); i++ {
nf.LeadingDigitsPattern = append(nf.LeadingDigitsPattern, other.LeadingDigitsPattern[i])
}
if other.NationalPrefixFormattingRule != nil {
nf.NationalPrefixFormattingRule = other.NationalPrefixFormattingRule
}
if other.DomesticCarrierCodeFormattingRule != nil {
nf.DomesticCarrierCodeFormattingRule = other.DomesticCarrierCodeFormattingRule
}
if other.NationalPrefixOptionalWhenFormatting != nil {
nf.NationalPrefixOptionalWhenFormatting = other.NationalPrefixOptionalWhenFormatting
}
}
func (pd *PhoneNumberDesc) hasPossibleLength(length int32) bool {
for _, l := range pd.PossibleLength {
if l == length {
return true
}
}
return false
}
func (pd *PhoneNumberDesc) hasPossibleLengthLocalOnly(length int32) bool {
for _, l := range pd.PossibleLengthLocalOnly {
if l == length {
return true
}
}
return false
}