Package overit.geocall.basic.anonymizer
Class Anonymizer.PhoneAnonymizer
java.lang.Object
overit.geocall.basic.anonymizer.Anonymizer.AbstractAnonymizer<String,Anonymizer.PhoneAnonymizer>
overit.geocall.basic.anonymizer.Anonymizer.PhoneAnonymizer
- Enclosing class:
Anonymizer
public class Anonymizer.PhoneAnonymizer
extends Anonymizer.AbstractAnonymizer<String,Anonymizer.PhoneAnonymizer>
Anonymizer used to obfuscate a fields containing string values which respect the phone number format.
If the context doesn't contains the field assigned to this instance, all'the method of this class will not change the context.
-
Field Summary
FieldsFields inherited from class overit.geocall.basic.anonymizer.Anonymizer.AbstractAnonymizer
_field -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddCountryCode(String cc) Add a country code to the current field's value.Set a random phone number as value of the field assigned to this instance.anonymize(int size) Set a random phone number as value of the field assigned to this instance.protected Anonymizer.PhoneAnonymizerprotected voidMethods inherited from class overit.geocall.basic.anonymizer.Anonymizer.AbstractAnonymizer
setValue
-
Field Details
-
PHONE_REGEXP
- See Also:
-
-
Constructor Details
-
PhoneAnonymizer
-
-
Method Details
-
addCountryCode
Add a country code to the current field's value. Pay attention to call this method after the anonymize, otherwise the country code value will be overwritten. For example, we assume thatanonymize()set the value "3331111111". If we call this method after the anonymize
into the context we will find the valueanonymize().addCountryCode("+39")"+393331111111". If we call the same methods but in the reverse order
the context will be update with the valueaddCountryCode("+39").anonymize()"3331111111"; that's why the second method has overwritten the changes made by the first one.- Parameters:
cc- string, representing the country code, that will be appended before the current value.- Returns:
- a reference of this object.
- Throws:
IllegalArgumentException- if the country code contains characters not allowed by the phone number standard format.
-
anonymize
Set a random phone number as value of the field assigned to this instance. The length of the generated number will be the same as the original one.- Returns:
- a reference of this object.
-
anonymize
Set a random phone number as value of the field assigned to this instance. The length of the generated phone number will be the same as the one specified by the size parameter.- Parameters:
size- positive number indicating length of the generated string.- Returns:
- a reference of this object.
- Throws:
overit.geocall.asserts.AssertsException- if size is negative.
-
anonymize
-
validate
- Overrides:
validatein classAnonymizer.AbstractAnonymizer<String,Anonymizer.PhoneAnonymizer>
-