Class IdGenerator

java.lang.Object
ch.rasc.wamp2spring.util.IdGenerator

public class IdGenerator extends Object
Id generator, that generates WAMP compliant identification numbers.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final long
     
    static final long
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static long
    Creates new linear identification number from the provided parameter.
    static long
    newRandomId(Set<Long> existingIds)
    Creates a new random generated identification number, that does not collide with an existing ids in the provided Set.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • IdGenerator

      public IdGenerator()
  • Method Details

    • newRandomId

      public static long newRandomId(@Nullable Set<Long> existingIds)
      Creates a new random generated identification number, that does not collide with an existing ids in the provided Set.

      Used for global scope messages

      Parameters:
      existingIds - a collection of existing ids.
      Returns:
      a new random identification number
    • newLinearId

      public static long newLinearId(AtomicLong longValue)
      Creates new linear identification number from the provided parameter.

      Used for session scope and router scope ids

      Parameters:
      longValue - start address of the identification number. Next number will be this value plus 1
      Returns:
      new id