org.keycloak.models.map.storage

## Interface StringKeyConvertor<K>

- All Known Implementing Classes:
    StringKeyConvertor.StringKey, StringKeyConvertor.ULongKey, StringKeyConvertor.UUIDKey

      public interface StringKeyConvertor<K>

  Converts given storage key from and to `String` representation.
  Author:
    hmlnarik

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface and Description
    --- | ---
    `static class` | `StringKeyConvertor.StringKey`
    `static class` | `StringKeyConvertor.ULongKey`
    `static class` | `StringKeyConvertor.UUIDKey`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `K` | `fromString(String key)` Returns native representation of the key from String representation
    `default K` | `fromStringSafe(String key)` Exception-free variant of `fromString(java.lang.String)` method.
    `default String` | `keyToString(K key)` Returns String representation of the key from native representation
    `K` | `yieldNewUniqueKey()` Returns a new unique primary key for the storage that this `StringKeyConvertor` belongs to.

- - ### Method Detail

    - #### keyToString

          default String keyToString(K key)

      Returns String representation of the key from native representation
      Parameters:
        `key` -
      Returns:
        See above
      Throws:
        `IllegalArgumentException` - if the string format is not recognized
        `NullPointerException` - if the parameter is `null`

    - #### yieldNewUniqueKey

          K yieldNewUniqueKey()

      Returns a new unique primary key for the storage that this `StringKeyConvertor` belongs to. The uniqueness needs to be guaranteed by e.g. using database sequences or using a random value that is proved sufficiently improbable to be repeated.
      Returns:

    - #### fromString

          K fromString(String key)

      Returns native representation of the key from String representation
      Parameters:
        `key` -
      Returns:
        See above
      Throws:
        `IllegalArgumentException` - if the string format is not recognized
        `NullPointerException` - if the parameter is `null`

    - #### fromStringSafe

          default K fromStringSafe(String key)

      Exception-free variant of `fromString(java.lang.String)` method. Returns native representation of the key from String representation, or `null` if the `key` is either `null` or invalid.
      Parameters:
        `key` -
      Returns:
        See above

Copyright © 2021 JBoss by Red Hat. All rights reserved.