Class BasicHubService.ClientIdGenerator

  • Enclosing class:
    BasicHubService

    private static class BasicHubService.ClientIdGenerator
    extends java.lang.Object
    Generates client public IDs. These must be unique, but don't need to be hard to guess.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Comparator comparator_  
      private int iseq_  
      private java.lang.String prefix_  
    • Constructor Summary

      Constructors 
      Constructor Description
      ClientIdGenerator​(java.lang.String prefix)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Comparator getComparator()
      Returns a comparator which will order the IDs generated by this object in generation sequence.
      private java.lang.Integer getIndex​(java.lang.String id)
      Returns an Integer giving the sequence index of the given id string.
      boolean hasUsed​(java.lang.String id)
      Indicates whether a given client ID has previously been dispensed by this object.
      java.lang.String next()
      Returns the next unused id.
      • Methods inherited from class java.lang.Object

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

      • iseq_

        private int iseq_
      • prefix_

        private final java.lang.String prefix_
      • comparator_

        private final java.util.Comparator comparator_
    • Constructor Detail

      • ClientIdGenerator

        public ClientIdGenerator​(java.lang.String prefix)
        Constructor.
        Parameters:
        prefix - prefix for all generated ids
    • Method Detail

      • next

        public java.lang.String next()
        Returns the next unused id.
        Returns:
        next id
      • hasUsed

        public boolean hasUsed​(java.lang.String id)
        Indicates whether a given client ID has previously been dispensed by this object.
        Parameters:
        id - id to test
        Returns:
        true iff id has been returned by a previous call of next
      • getIndex

        private java.lang.Integer getIndex​(java.lang.String id)
        Returns an Integer giving the sequence index of the given id string. If id does not look like a string generated by this object, null is returned.
        Parameters:
        id - identifier to test
        Returns:
        object containing sequence index of id, or null
      • getComparator

        public java.util.Comparator getComparator()
        Returns a comparator which will order the IDs generated by this object in generation sequence.
        Returns:
        id comparator