Class LeaderInformationRegister


  • public class LeaderInformationRegister
    extends Object
    A register containing the LeaderInformation for multiple contenders based on their componentId. No empty LeaderInformation is stored physically. No entry and an entry with an empty LeaderInformation are, therefore, semantically the same.
    • Constructor Detail

      • LeaderInformationRegister

        public LeaderInformationRegister​(Map<String,​LeaderInformation> leaderInformationPerComponentId)
        Creates a LeaderInformationRegister based on the passed leader information.
    • Method Detail

      • merge

        public static LeaderInformationRegister merge​(@Nullable
                                                      LeaderInformationRegister leaderInformationRegister,
                                                      String componentId,
                                                      LeaderInformation leaderInformation)
        Merges another LeaderInformationRegister with additional leader information into a new LeaderInformationRegister instance. Any existing LeaderInformation for the passed componentId will be overwritten.

        Empty LeaderInformation results in the removal of the corresponding entry (if it exists).

      • clear

        public static LeaderInformationRegister clear​(@Nullable
                                                      LeaderInformationRegister leaderInformationRegister,
                                                      String componentId)
        Creates a new LeaderInformationRegister that matches the passed LeaderInformationRegister except for the entry of componentId which is removed if it existed.
      • forComponentIdOrEmpty

        public LeaderInformation forComponentIdOrEmpty​(String componentId)
        Returns a LeaderInformation which is empty if no LeaderInformation is stored for the passed componentId.
      • getRegisteredComponentIds

        public Iterable<String> getRegisteredComponentIds()
        Returns the componentIds for which leader information is stored.
      • hasLeaderInformation

        public boolean hasLeaderInformation​(String componentId)
        Checks whether the register holds non-empty LeaderInformation for the passed componentId.
      • hasNoLeaderInformation

        public boolean hasNoLeaderInformation()
        Checks that no non-empty LeaderInformation is stored.
        Returns:
        true, if there is no entry that refers to a non-empty LeaderInformation; otherwise false (i.e. either no information is stored under any componentId or there are entries for certain componentIds that refer to an empty LeaderInformation record).