Class SimpleId

java.lang.Object
com.peterphi.std.types.Id
com.peterphi.std.types.SimpleId
All Implemented Interfaces:
Serializable, Comparable<Id>

public final class SimpleId extends Id implements Serializable
A simple, untyped Id field; this is one step above having a String id
It is recommended that users extend Id themselves rather than using this type (as a SimpleId adds no discernable information about what the id is for)
See Also:
  • Field Summary

    Fields inherited from class com.peterphi.std.types.Id

    id, SANITY_CHECK
  • Constructor Summary

    Constructors
    Constructor
    Description
     
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static final String
    alphanumeric(int length)
    Generates a random sequence of alphanumeric characters of length length using a new pseudorandom number generator (new Random())
    static final String
    alphanumeric(String prefix, int totalLength)
    Generates a random sequence of alphanumeric characters, prefixed by prefix such that the total string is of length totalLength using a new pseudorandom number generator (new Random())
    static final String
    alphanumeric(Random random, int length)
    Generates a random sequence of alphanumeric characters of length length using the provided random number generator
    static SimpleId
    Return an Id which uses 32 random alphanumeric characters as its value

    Methods inherited from class com.peterphi.std.types.Id

    compareTo, equals, hashCode, toString

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • SimpleId

      public SimpleId(String id)
      Parameters:
      id -
    • SimpleId

      public SimpleId(UUID id)
  • Method Details

    • random

      public static SimpleId random()
      Return an Id which uses 32 random alphanumeric characters as its value
      Returns:
    • alphanumeric

      public static final String alphanumeric(int length)
      Generates a random sequence of alphanumeric characters of length length using a new pseudorandom number generator (new Random())
      Parameters:
      length - the length of the string to generate (must be > 0)
      Returns:
      a new random alphanumeric String of length length
    • alphanumeric

      public static final String alphanumeric(String prefix, int totalLength)
      Generates a random sequence of alphanumeric characters, prefixed by prefix such that the total string is of length totalLength using a new pseudorandom number generator (new Random())
      Parameters:
      totalLength - the length of the string to return (must be > the prefix length)
      Returns:
      a String of length length
    • alphanumeric

      public static final String alphanumeric(Random random, int length)
      Generates a random sequence of alphanumeric characters of length length using the provided random number generator
      Parameters:
      random - the random number generator to use (must not be null)
      length - the length of the string to generate (must be > 0)
      Returns:
      a new random alphanumeric String of length length