Class Anonymizer.TextAnonymizer

Enclosing class:
Anonymizer

public class Anonymizer.TextAnonymizer extends Anonymizer.AbstractAnonymizer<String,Anonymizer.TextAnonymizer>
Anonymizer used to obfuscate a fields containg string values. If the context doesn't contains the field assigned to this instance, all'the method of this class will not change the context.
  • Constructor Details

    • TextAnonymizer

      protected TextAnonymizer(String field)
  • Method Details

    • addPrefix

      public Anonymizer.TextAnonymizer addPrefix(String prefix)
      Add a prefix to the current field's value. Pay attention to call this method after the anonymize, otherwise the prefixed value will be overwritten. For example, we assume that anonymize(RandomToken.LOWERCASE) set the value "abcdefg". If we call this method after the anonymize
      anonymize(RandomToken.LOWERCASE).addPrefix("UNKNOWN_")
      into the context we will find the value "UNKNOWN_abcdefg". If we call the same methods but in the reverse order
      addPrefix("UNKNOWN_").anonymize(RandomToken.LOWERCASE)
      the context will be update with the value "abcdefg"; that's why the second method has overwritten the changes made by the first one.
      Parameters:
      prefix - string that will be appended before the current value
      Returns:
      a reference of this object.
    • anonymize

      public Anonymizer.TextAnonymizer anonymize(String alphabet)
      Set a random string as value of the field assigned to this instance. The length of the generated string will be the same as the original one.
      Parameters:
      alphabet - String containing the characters that will be used to generate the random string. Typically you can use these predefined set of alphabet:
      Returns:
      a reference of this object.
      Throws:
      overit.geocall.asserts.AssertsException - if the alphabet is null or empty.
    • anonymize

      public Anonymizer.TextAnonymizer anonymize(String alphabet, int size)
      Set a random string as value of the field assigned to this instance. The length of the generated string will be the same as the one specified by the size parameter.
      Parameters:
      alphabet - String containing the characters that will be used to generate the random string. Typically you can use these predefined set of alphabet:
      size - positive number indicating length of the generated string.
      Returns:
      a reference of this object.
      Throws:
      overit.geocall.asserts.AssertsException - if the alphabet is null or empty, or if the size is negative.
    • anonymize

      protected Anonymizer.TextAnonymizer anonymize(String alphabet, Integer size)