Class 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 Details

  • Constructor Details

    • PhoneAnonymizer

      protected PhoneAnonymizer(String field)
  • Method Details

    • addCountryCode

      public Anonymizer.PhoneAnonymizer addCountryCode(String cc)
      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 that anonymize() set the value "3331111111". If we call this method after the anonymize
      anonymize().addCountryCode("+39")
      into the context we will find the value "+393331111111". If we call the same methods but in the reverse order
      addCountryCode("+39").anonymize()
      the context will be update with the value "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

      public Anonymizer.PhoneAnonymizer 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

      public Anonymizer.PhoneAnonymizer anonymize(int size)
      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

      protected Anonymizer.PhoneAnonymizer anonymize(Integer size)
    • validate

      protected void validate(String value)
      Overrides:
      validate in class Anonymizer.AbstractAnonymizer<String,Anonymizer.PhoneAnonymizer>