Class ErrorCode

    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected ErrorCode​(java.lang.String category, long code)
      Creates a new ErrorCode with the given category and code.
      protected ErrorCode​(java.lang.String category, long code, boolean performUniquenessCheck)
      Creates a new ErrorCode with the given category and code, optionally ensuring the ErrorCode is unique.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object o)
      java.lang.String formatError​(java.util.Locale locale, java.lang.String... context)
      Format a contextual error message.
      java.lang.String getCategory()  
      long getCode()  
      static ErrorCode getErrorCode​(java.lang.String category, long code)
      Get an ErrorCode given its category and number.
      int hashCode()
      protected java.lang.Object readResolve()
      Need to implement readResolve() in order to ensure == works for serialized error codes.
      java.lang.String toString()
      • Methods inherited from class java.lang.Object

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

      • ErrorCode

        protected ErrorCode​(java.lang.String category,
                            long code)
        Creates a new ErrorCode with the given category and code. Makes sure it is unique. This method must be used by statically initialized error code constructors.
        Parameters:
        category -
        code -
      • ErrorCode

        protected ErrorCode​(java.lang.String category,
                            long code,
                            boolean performUniquenessCheck)
        Creates a new ErrorCode with the given category and code, optionally ensuring the ErrorCode is unique. performUniquenessCheck=false is intended to be used only by serialization code that creates error codes on deserialization.
        Parameters:
        category -
        code -
        performUniquenessCheck -
    • Method Detail

      • getCategory

        public java.lang.String getCategory()
      • getCode

        public long getCode()
      • formatError

        public java.lang.String formatError​(java.util.Locale locale,
                                            java.lang.String... context)
        Format a contextual error message.
      • getErrorCode

        public static ErrorCode getErrorCode​(java.lang.String category,
                                             long code)
        Get an ErrorCode given its category and number.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • 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
      • readResolve

        protected java.lang.Object readResolve()
        Need to implement readResolve() in order to ensure == works for serialized error codes.

        NOTE: needs to be protected to ensure all error codes use this read resolve.