Class Account

  • All Implemented Interfaces:
    java.lang.Comparable<Account>

    public class Account
    extends java.lang.Object
    Account model represents an identity for the user with an issuer. It is possible for a user to have multiple accounts provided by a single issuer, however it is not possible to have multiple accounts from with same issuer for the same account name.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Account.AccountBuilder
      Builder class responsible for producing Accounts.
    • Constructor Summary

      Constructors 
      Constructor Description
      Account​(java.lang.String issuer, java.lang.String displayIssuer, java.lang.String accountName, java.lang.String displayAccountName, java.lang.String imageURL, java.lang.String backgroundColor, java.util.Calendar timeAdded)
      Creates Account object with given information.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static Account.AccountBuilder builder()
      Returns a builder for creating an Account.
      int compareTo​(Account another)  
      static Account deserialize​(java.lang.String jsonString)
      Deserializes the specified Json into an object of the Account object.
      boolean equals​(java.lang.Object o)  
      java.lang.String getAccountName()
      Returns the name of this account.
      java.lang.String getBackgroundColor()
      Gets the background color for the IDP that issued this account.
      java.lang.String getDisplayAccountName()
      Returns the name of this account.
      java.lang.String getDisplayIssuer()
      Gets the alternative name of the IDP that issued this account.
      java.lang.String getId()
      Gets the unique identifier for the Account.
      java.lang.String getImageURL()
      Gets the image URL for the IDP that issued this account.
      java.lang.String getIssuer()
      Gets the name of the IDP that issued this account.
      java.util.List<Mechanism> getMechanisms()
      Get the list of mechanisms associates with this account.
      java.util.Calendar getTimeAdded()
      Get the Date and Time this Account was stored.
      int hashCode()  
      boolean matches​(Account other)
      Returns true if the two objects would conflict if added to a storage system.
      void setDisplayAccountName​(java.lang.String accountName)
      Sets an alternative name for the account.
      void setDisplayIssuer​(java.lang.String issuer)
      Sets an alternative Issuer for this account.
      java.lang.String toJson()
      Creates a JSON string representation of ModelObject object.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Account

        public Account​(java.lang.String issuer,
                       java.lang.String displayIssuer,
                       java.lang.String accountName,
                       java.lang.String displayAccountName,
                       java.lang.String imageURL,
                       java.lang.String backgroundColor,
                       java.util.Calendar timeAdded)
        Creates Account object with given information.
        Parameters:
        issuer - String value of issuer
        displayIssuer - String alternative value of the issuer
        accountName - String value of accountName or username
        displayAccountName - String alternative value of the accountName
        imageURL - URL of account's logo image (optional)
        backgroundColor - String HEX code of account's background color (optional)
        timeAdded - Date and Time this Account was stored
    • Method Detail

      • builder

        public static Account.AccountBuilder builder()
        Returns a builder for creating an Account.
        Returns:
        The Account builder.
      • getId

        public java.lang.String getId()
        Gets the unique identifier for the Account.
        Returns:
        The unique identifier.
      • getIssuer

        public java.lang.String getIssuer()
        Gets the name of the IDP that issued this account.
        Returns:
        The name of the IDP.
      • getDisplayIssuer

        public java.lang.String getDisplayIssuer()
        Gets the alternative name of the IDP that issued this account. Returns original issuer if displayIssuer is not set.
        Returns:
        The name of the IDP.
      • setDisplayIssuer

        public void setDisplayIssuer​(@NonNull
                                     java.lang.String issuer)
        Sets an alternative Issuer for this account.
        Parameters:
        issuer - The new IDP name.
      • getDisplayAccountName

        public java.lang.String getDisplayAccountName()
        Returns the name of this account. Returns original accountName if displayAccountName is not set.
        Returns:
        The account name.
      • setDisplayAccountName

        public void setDisplayAccountName​(@NonNull
                                          java.lang.String accountName)
        Sets an alternative name for the account.
        Parameters:
        accountName - The new account name.
      • getAccountName

        public java.lang.String getAccountName()
        Returns the name of this account.
        Returns:
        The account name.
      • getImageURL

        public java.lang.String getImageURL()
        Gets the image URL for the IDP that issued this account.
        Returns:
        String representing the path to the image, or null if not assigned.
      • getBackgroundColor

        public java.lang.String getBackgroundColor()
        Gets the background color for the IDP that issued this account.
        Returns:
        A hex string including a prepending # symbol, representing the color (e.g. #aabbcc)
      • getTimeAdded

        public java.util.Calendar getTimeAdded()
        Get the Date and Time this Account was stored.
        Returns:
        when this account was stored.
      • getMechanisms

        public java.util.List<Mechanism> getMechanisms()
        Get the list of mechanisms associates with this account.
        Returns:
        List list of mechanisms
      • toJson

        public java.lang.String toJson()
        Creates a JSON string representation of ModelObject object. Sensitive information are not exposed.
        Returns:
        a JSON string object
      • deserialize

        public static Account deserialize​(java.lang.String jsonString)
        Deserializes the specified Json into an object of the Account object.
        Parameters:
        jsonString - the json string representing the object to be deserialized
        Returns:
        an Account object from the string. Returns null if jsonString is null, if jsonString is empty or not able to parse it.
      • matches

        public boolean matches​(Account other)
        Returns true if the two objects would conflict if added to a storage system.
        Parameters:
        other - The object to compare.
        Returns:
        True if key traits of the objects match, false otherwise.
      • compareTo

        public int compareTo​(Account another)
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object