content: // Copyright (c) 2019 Alibaba Group. All rights reserved.
  // Use of this source code is governed by a MIT license that can be
  // found in the LICENSE file.
  
  package com.idlefish.flutterboost;
  
  import java.lang.AssertionError;
  
  /**
   * A set of assert methods.  Messages are only displayed when an assert fails.
   *
   */
  public class Assert {
      /**
       * Protect constructor since it is a static only class
       */
      protected Assert() {
      }
  
      /**
       * Asserts that a condition is true. If it isn't it throws
       * an AssertionError with the given message.
       */
      static public void assertTrue(String message, boolean condition) {
          if (!condition) {
              fail(message);
          }
      }
  
      /**
       * Asserts that a condition is true. If it isn't it throws
       * an AssertionError.
       */
      static public void assertTrue(boolean condition) {
          assertTrue(null, condition);
      }
  
      /**
       * Asserts that a condition is false. If it isn't it throws
       * an AssertionError with the given message.
       */
      static public void assertFalse(String message, boolean condition) {
          assertTrue(message, !condition);
      }
  
      /**
       * Asserts that a condition is false. If it isn't it throws
       * an AssertionError.
       */
      static public void assertFalse(boolean condition) {
          assertFalse(null, condition);
      }
  
      /**
       * Fails a test with the given message.
       */
      static public void fail(String message) {
          if (message == null) {
              throw new AssertionError();
          }
          throw new AssertionError(message);
      }
  
      /**
       * Fails a test with no message.
       */
      static public void fail() {
          fail(null);
      }
  
      /**
       * Asserts that an object isn't null.
       */
      static public void assertNotNull(Object object) {
          assertNotNull(null, object);
      }
  
      /**
       * Asserts that an object isn't null. If it is
       * an AssertionError is thrown with the given message.
       */
      static public void assertNotNull(String message, Object object) {
          assertTrue(message, object != null);
      }
  
      /**
       * Asserts that an object is null. If it isn't an {@link AssertionError} is
       * thrown.
       * Message contains: Expected: <null> but was: object
       *
       * @param object Object to check or <code>null</code>
       */
      static public void assertNull(Object object) {
          if (object != null) {
              assertNull("Expected: <null> but was: " + object.toString(), object);
          }
      }
  
      /**
       * Asserts that an object is null.  If it is not
       * an AssertionError is thrown with the given message.
       */
      static public void assertNull(String message, Object object) {
          assertTrue(message, object == null);
      }
  }