Java: added compiled metadata generation
This commit is contained in:
@@ -32,4 +32,4 @@ pub use phonenumberutil::{
|
||||
};
|
||||
pub use proto_gen::phonemetadata;
|
||||
pub use proto_gen::phonenumber;
|
||||
mod tests;
|
||||
mod tests;
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright (C) 2011 The Libphonenumber Authors
|
||||
* Copyright (C) 2025 Vladislav Kashin (modified)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
pub const METADATA: [u8; 201802] = [
|
||||
0x0A, 0xE9, 0x01, 0x0A, 0x1D, 0x12, 0x17, 0x28, 0x3F, 0x3A, 0x5B, 0x30, 0x31,
|
||||
@@ -15525,4 +15541,3 @@ pub const METADATA: [u8; 201802] = [
|
||||
0xFF, 0x01, 0xE2, 0x01, 0x0B, 0x48, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0x01
|
||||
];
|
||||
|
||||
3
src/phonenumberutil/generated/mod.rs
Normal file
3
src/phonenumberutil/generated/mod.rs
Normal file
@@ -0,0 +1,3 @@
|
||||
pub mod metadata;
|
||||
pub mod test_metadata;
|
||||
|
||||
@@ -1,5 +1,21 @@
|
||||
/*
|
||||
* Copyright (C) 2011 The Libphonenumber Authors
|
||||
* Copyright (C) 2025 Vladislav Kashin (modified)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
pub const METADATA: [u8; 13260] = [
|
||||
pub const TEST_METADATA: [u8; 13260] = [
|
||||
0x0A, 0xAD, 0x01, 0x0A, 0x09, 0x12, 0x05, 0x5C, 0x64, 0x7B, 0x36, 0x7D, 0x48,
|
||||
0x06, 0x12, 0x0F, 0x12, 0x05, 0x5C, 0x64, 0x7B, 0x36, 0x7D, 0x32, 0x06, 0x31,
|
||||
0x32, 0x33, 0x34, 0x35, 0x36, 0x1A, 0x0B, 0x48, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
@@ -1020,4 +1036,4 @@ pub const METADATA: [u8; 13260] = [
|
||||
0x48, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0xCA, 0x01,
|
||||
0x0B, 0x48, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0xE2,
|
||||
0x01, 0x0B, 0x48, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01
|
||||
];
|
||||
];
|
||||
@@ -1,5 +1,3 @@
|
||||
mod helper_constants;
|
||||
mod metadata;
|
||||
|
||||
pub(super) use helper_constants::{*};
|
||||
pub(super) use metadata::METADATA;
|
||||
|
||||
@@ -4,18 +4,17 @@ use protobuf::Message;
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
use crate::{
|
||||
interfaces::MatcherApi,
|
||||
proto_gen::{
|
||||
interfaces::MatcherApi, phonenumberutil::generated::metadata::METADATA, proto_gen::{
|
||||
phonemetadata::{PhoneMetadata, PhoneMetadataCollection, PhoneNumberDesc},
|
||||
phonenumber::PhoneNumber,
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
use super::{
|
||||
PhoneNumberFormat, PhoneNumberType, ValidNumberLenType,
|
||||
errors::ValidationResultErr,
|
||||
helper_constants::{
|
||||
METADATA, OPTIONAL_EXT_SUFFIX, PLUS_SIGN, POSSIBLE_CHARS_AFTER_EXT_LABEL,
|
||||
OPTIONAL_EXT_SUFFIX, PLUS_SIGN, POSSIBLE_CHARS_AFTER_EXT_LABEL,
|
||||
POSSIBLE_SEPARATORS_BETWEEN_NUMBER_AND_EXT_LABEL, RFC3966_EXTN_PREFIX, RFC3966_PREFIX,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -6,6 +6,7 @@ pub mod phonenumberutil;
|
||||
mod phone_number_regexps_and_mappings;
|
||||
pub(self) mod helper_types;
|
||||
pub(self) mod comparisons;
|
||||
pub(crate) mod generated;
|
||||
|
||||
use std::sync::LazyLock;
|
||||
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
mod tests;
|
||||
mod test_metadata;
|
||||
@@ -10,13 +10,13 @@ use protobuf::Message;
|
||||
|
||||
use crate::{errors::ParseError, phonemetadata::PhoneMetadataCollection, phonenumber::PhoneNumber, PhoneNumberUtil};
|
||||
|
||||
use super::test_metadata::METADATA;
|
||||
use crate::phonenumberutil::generated::test_metadata::TEST_METADATA;
|
||||
|
||||
|
||||
|
||||
// This setup function simulates getting the PhoneNumberUtil instance for each test.
|
||||
fn get_phone_util() -> PhoneNumberUtil {
|
||||
let metadata = PhoneMetadataCollection::parse_from_bytes(&METADATA)
|
||||
let metadata = PhoneMetadataCollection::parse_from_bytes(&TEST_METADATA)
|
||||
.expect("Metadata should be valid");
|
||||
// In a real scenario, this would likely return a singleton instance.
|
||||
return PhoneNumberUtil::new_for_metadata(metadata);
|
||||
|
||||
Reference in New Issue
Block a user