Exemple #1
0
        /**
         * Clears certain fields in {@code metadata} as defined by the {@code MetadataFilter} instance.
         * Note that this changes the mutable {@code metadata} object, and is not thread-safe. If this
         * method does not return successfully, do not assume {@code metadata} has not changed.
         *
         * @param metadata  The {@code PhoneMetadata} object to be filtered
         */
        internal void FilterMetadata(PhoneMetadata.Builder metadata)
        {
            // TODO: Consider clearing if the filtered PhoneNumberDesc is empty.
            if (metadata.HasFixedLine)
            {
                metadata.SetFixedLine(GetFiltered("fixedLine", metadata.FixedLine));
            }
            if (metadata.HasMobile)
            {
                metadata.SetMobile(GetFiltered("mobile", metadata.Mobile));
            }
            if (metadata.HasTollFree)
            {
                metadata.SetTollFree(GetFiltered("tollFree", metadata.TollFree));
            }
            if (metadata.HasPremiumRate)
            {
                metadata.SetPremiumRate(GetFiltered("premiumRate", metadata.PremiumRate));
            }
            if (metadata.HasSharedCost)
            {
                metadata.SetSharedCost(GetFiltered("sharedCost", metadata.SharedCost));
            }
            if (metadata.HasPersonalNumber)
            {
                metadata.SetPersonalNumber(GetFiltered("personalNumber", metadata.PersonalNumber));
            }
            if (metadata.HasVoip)
            {
                metadata.SetVoip(GetFiltered("voip", metadata.Voip));
            }
            if (metadata.HasPager)
            {
                metadata.SetPager(GetFiltered("pager", metadata.Pager));
            }
            if (metadata.HasUan)
            {
                metadata.SetUan(GetFiltered("uan", metadata.Uan));
            }
            if (metadata.HasEmergency)
            {
                metadata.SetEmergency(GetFiltered("emergency", metadata.Emergency));
            }
            if (metadata.HasVoicemail)
            {
                metadata.SetVoicemail(GetFiltered("voicemail", metadata.Voicemail));
            }
            if (metadata.HasShortCode)
            {
                metadata.SetShortCode(GetFiltered("shortCode", metadata.ShortCode));
            }
            if (metadata.HasStandardRate)
            {
                metadata.SetStandardRate(GetFiltered("standardRate", metadata.StandardRate));
            }
            if (metadata.HasCarrierSpecific)
            {
                metadata.SetCarrierSpecific(GetFiltered("carrierSpecific", metadata.CarrierSpecific));
            }
            if (metadata.HasSmsServices)
            {
                metadata.SetSmsServices(GetFiltered("smsServices", metadata.SmsServices));
            }
            if (metadata.HasNoInternationalDialling)
            {
                metadata.SetNoInternationalDialling(GetFiltered("noInternationalDialling",
                                                                metadata.NoInternationalDialling));
            }

            if (ShouldDrop("preferredInternationalPrefix"))
            {
                metadata.ClearPreferredInternationalPrefix();
            }
            if (ShouldDrop("nationalPrefix"))
            {
                metadata.ClearNationalPrefix();
            }
            if (ShouldDrop("preferredExtnPrefix"))
            {
                metadata.ClearPreferredExtnPrefix();
            }
            if (ShouldDrop("nationalPrefixTransformRule"))
            {
                metadata.ClearNationalPrefixTransformRule();
            }
            if (ShouldDrop("sameMobileAndFixedLinePattern"))
            {
                metadata.ClearSameMobileAndFixedLinePattern();
            }
            if (ShouldDrop("mainCountryForCode"))
            {
                metadata.ClearMainCountryForCode();
            }
            if (ShouldDrop("leadingZeroPossible"))
            {
                metadata.ClearLeadingZeroPossible();
            }
            if (ShouldDrop("mobileNumberPortableRegion"))
            {
                metadata.ClearMobileNumberPortableRegion();
            }
        }