org.apache.tinkerpop.gremlin.process.traversal.translator

## Class AnonymizingTypeTranslator

- java.lang.Object
- - org.apache.tinkerpop.gremlin.process.traversal.Translator.ScriptTranslator.AbstractTypeTranslator
  - - org.apache.tinkerpop.gremlin.process.traversal.translator.GroovyTranslator.DefaultTypeTranslator
    - - org.apache.tinkerpop.gremlin.process.traversal.translator.AnonymizingTypeTranslator

- All Implemented Interfaces:
    BiFunction<String,Object,Script>, Translator.ScriptTranslator.TypeTranslator

      public class AnonymizingTypeTranslator
      extends GroovyTranslator.DefaultTypeTranslator

  This Translator will translate `Bytecode` into a representation that has been stripped of any user data (anonymized). A default anonymizer is provided, but can be replaced with a custom anonymizer as needed. The default anonymizer replaces any String, Numeric, Date, Timestamp, or UUID with a type-based token. Identical values will receive the same token (e.g. if "foo" is assigned "string0" then all occurrences of "foo" will be replaced with "string0").

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static interface` | `AnonymizingTypeTranslator.Anonymizer` Customizable anonymizer interface.
    `static class` | `AnonymizingTypeTranslator.DefaultAnonymizer` This default implementation keeps a map from type (Java Class) to another map from instances to anonymized token.

  - ### Field Summary

    - ### Fields inherited from class org.apache.tinkerpop.gremlin.process.traversal.Translator.ScriptTranslator.AbstractTypeTranslator

      `ANONYMOUS_TRAVERSAL_PREFIX, script, withParameters`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AnonymizingTypeTranslator()` Default constructor creates a `AnonymizingTypeTranslator.DefaultAnonymizer` + withParameters=false.
    `AnonymizingTypeTranslator(AnonymizingTypeTranslator.Anonymizer anonymizer, boolean withParameters)`
    `AnonymizingTypeTranslator(boolean withParameters)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected String` | `getSyntax(Date o)` Take the `Date` argument and convert it to a string representation in the target language.
    `protected String` | `getSyntax(Number o)` Take the numeric argument and convert it to a string representation in the target language.
    `protected String` | `getSyntax(String o)` Take the string argument and convert it to a string representation in the target language (i.e.
    `protected String` | `getSyntax(Timestamp o)` Take the `Timestamp` argument and convert it to a string representation in the target language.
    `protected String` | `getSyntax(UUID o)` Take the `UUID` argument and convert it to a string representation in the target language.
    `protected Script` | `produceScript(Class<?> o)` Gets the string representation of a class with the default implementation simply checking to see if the `Class` is in `CoreImports` or not.

    - ### Methods inherited from class org.apache.tinkerpop.gremlin.process.traversal.translator.GroovyTranslator.DefaultTypeTranslator

      `getNullSyntax, getSyntax, getSyntax, getSyntax, getSyntax, getSyntax, produceScript, produceScript, produceScript, produceScript, produceScript, produceScript, produceScript, produceScript, produceScript, produceScript`

    - ### Methods inherited from class org.apache.tinkerpop.gremlin.process.traversal.Translator.ScriptTranslator.AbstractTypeTranslator

      `apply, convertToScript, getAnonymousTraversalPrefix`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface java.util.function.BiFunction

      `andThen`

- - ### Constructor Detail

    - #### AnonymizingTypeTranslator

          public AnonymizingTypeTranslator()

      Default constructor creates a `AnonymizingTypeTranslator.DefaultAnonymizer` + withParameters=false.

    - #### AnonymizingTypeTranslator

          public AnonymizingTypeTranslator(boolean withParameters)

    - #### AnonymizingTypeTranslator

          public AnonymizingTypeTranslator(AnonymizingTypeTranslator.Anonymizer anonymizer,
                                           boolean withParameters)

  - ### Method Detail

    - #### getSyntax

          protected String getSyntax(String o)

      Description copied from class: `Translator.ScriptTranslator.AbstractTypeTranslator`
      Take the string argument and convert it to a string representation in the target language (i.e. escape, enclose in appropriate quotes, etc.)
      Overrides:
        `getSyntax` in class `GroovyTranslator.DefaultTypeTranslator`

    - #### getSyntax

          protected String getSyntax(Date o)

      Description copied from class: `Translator.ScriptTranslator.AbstractTypeTranslator`
      Take the `Date` argument and convert it to a string representation in the target language.
      Overrides:
        `getSyntax` in class `GroovyTranslator.DefaultTypeTranslator`

    - #### getSyntax

          protected String getSyntax(Timestamp o)

      Description copied from class: `Translator.ScriptTranslator.AbstractTypeTranslator`
      Take the `Timestamp` argument and convert it to a string representation in the target language.
      Overrides:
        `getSyntax` in class `GroovyTranslator.DefaultTypeTranslator`

    - #### getSyntax

          protected String getSyntax(UUID o)

      Description copied from class: `Translator.ScriptTranslator.AbstractTypeTranslator`
      Take the `UUID` argument and convert it to a string representation in the target language.
      Overrides:
        `getSyntax` in class `GroovyTranslator.DefaultTypeTranslator`

    - #### getSyntax

          protected String getSyntax(Number o)

      Description copied from class: `Translator.ScriptTranslator.AbstractTypeTranslator`
      Take the numeric argument and convert it to a string representation in the target language. Languages that can discern differences in types of numbers will wish to further check the type of the `Number` instance itself (i.e. `Double`, `Integer`, etc.)
      Overrides:
        `getSyntax` in class `GroovyTranslator.DefaultTypeTranslator`

    - #### produceScript

          protected Script produceScript(Class<?> o)

      Description copied from class: `GroovyTranslator.DefaultTypeTranslator`
      Gets the string representation of a class with the default implementation simply checking to see if the `Class` is in `CoreImports` or not. If it is present that means it can be referenced using the simple name otherwise it uses the canonical name.

      Those building custom `ScriptTranslator` instances might override this if they have other classes that are not in `CoreImports` by default.
      Overrides:
        `produceScript` in class `GroovyTranslator.DefaultTypeTranslator`

Copyright © 2013–2022 Apache Software Foundation. All rights reserved.