Package 

Class Preconditions.NoThrow


  • 
    public final class Preconditions.NoThrow
    
                        

    Preconditions checks that avoid throwing and exception in release mode. These versions returna boolean which the caller should check.

    • Method Summary

      Modifier and Type Method Description
      static void setStrictMode(boolean strictMode) Enables or disables strict mode.In strict mode, this class will throw anyway.
      static boolean checkArgument(boolean expression) Ensures the truth of an expression.
      static boolean checkArgument(boolean expression, String errorMessage) Ensures the truth of an expression, with an error message.
      static boolean checkArgument(boolean expression, String errorMessageTemplate, Array<Object> errorMessageArgs) Ensures the truth of an expression, with an error message that takes arguments.
      static boolean checkState(boolean expression) Ensures the truth of an expression involving the state of the caller.
      static boolean checkState(boolean expression, String errorMessage) Ensures the truth of an expression involving the state of the caller, with an errormessage.
      static boolean checkState(boolean expression, String errorMessageTemplate, Array<Object> errorMessageArgs) Ensures the truth of an expression involving the state of the caller, with an errormessage that takes arguments.
      static boolean checkNotNull(Object reference) Ensures that an object reference is not null.
      static boolean checkNotNull(Object reference, String errorMessage) Ensures that an object reference is not null, with an error message.
      static boolean checkNotNull(Object reference, String errorMessageTemplate, Array<Object> errorMessageArgs) Ensures that an object reference is not null, with an error message that takesarguments.
      static boolean checkUiThread() Ensures that the current thread is the UI thread.
      static boolean checkUiThread(String errorMessage) Ensures that the current thread is the UI thread, with an error message.
      static boolean checkUiThread(String errorMessageTemplate, Array<Object> errorMessageArgs) Ensures that the current thread is the UI thread, with an error message that takesarguments.
      • Methods inherited from class java.lang.Object

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

      • setStrictMode

         static void setStrictMode(boolean strictMode)

        Enables or disables strict mode.In strict mode, this class will throw anyway. For example, you could set strict mode toBuildConfig.DEBUG to always get exceptions when in the IDE.

        Parameters:
        strictMode - Whether to use strict mode.
      • checkArgument

         static boolean checkArgument(boolean expression)

        Ensures the truth of an expression.

      • checkArgument

         static boolean checkArgument(boolean expression, String errorMessage)

        Ensures the truth of an expression, with an error message.

      • checkArgument

         static boolean checkArgument(boolean expression, String errorMessageTemplate, Array<Object> errorMessageArgs)

        Ensures the truth of an expression, with an error message that takes arguments.

      • checkState

         static boolean checkState(boolean expression)

        Ensures the truth of an expression involving the state of the caller.

      • checkState

         static boolean checkState(boolean expression, String errorMessage)

        Ensures the truth of an expression involving the state of the caller, with an errormessage.

      • checkState

         static boolean checkState(boolean expression, String errorMessageTemplate, Array<Object> errorMessageArgs)

        Ensures the truth of an expression involving the state of the caller, with an errormessage that takes arguments.

      • checkNotNull

         static boolean checkNotNull(Object reference)

        Ensures that an object reference is not null.

      • checkNotNull

         static boolean checkNotNull(Object reference, String errorMessage)

        Ensures that an object reference is not null, with an error message.

      • checkNotNull

         static boolean checkNotNull(Object reference, String errorMessageTemplate, Array<Object> errorMessageArgs)

        Ensures that an object reference is not null, with an error message that takesarguments.

      • checkUiThread

         static boolean checkUiThread()

        Ensures that the current thread is the UI thread.

      • checkUiThread

         static boolean checkUiThread(String errorMessage)

        Ensures that the current thread is the UI thread, with an error message.

      • checkUiThread

         static boolean checkUiThread(String errorMessageTemplate, Array<Object> errorMessageArgs)

        Ensures that the current thread is the UI thread, with an error message that takesarguments.