18b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira/*
28b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * Copyright (C) 2000 Google Inc.
38b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira *
48b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * Licensed under the Apache License, Version 2.0 (the "License");
58b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * you may not use this file except in compliance with the License.
68b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * You may obtain a copy of the License at
78b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira *
88b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * http://www.apache.org/licenses/LICENSE-2.0
98b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira *
108b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * Unless required by applicable law or agreed to in writing, software
118b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * distributed under the License is distributed on an "AS IS" BASIS,
128b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
138b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * See the License for the specific language governing permissions and
148b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * limitations under the License.
158b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira */
168b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira
1730e2c24b056542f3b1b438aeb798305d1226d0c8Andy Huangpackage com.android.mail.lib.base;
188b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira
198b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira/**
208b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * A utility class that contains some very widely used functionality.
218b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * This class is named "X" just to get a short name that can be typed
228b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * everywhere without cluttering up the code.  For example, it
238b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * seems a lot less verbose to say: "X.assertTrue(empty())" instead of
248b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * "Assert.assertTrue(empty())".
258b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira *
268b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * <p>Consider using {@link Preconditions} instead though.
278b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira *
288b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * <p>If your application is using JDK 1.4, feel free to use the built-in
298b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * assert() methods instead. <b>NOTE:</b> Except remember that JDK assertions
308b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * are not normally enabled unless you pass the -ea flag to the jvm.
318b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira */
328b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereirapublic final class X {
338b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira
348b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira  /**
358b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira   * This class should not be instantiated. It provides static methods
368b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira   * only.
378b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira   */
388b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira  private X() {}
398b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira
408b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira  /**
418b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira   * Raise a runtime exception if the supplied argument is false (note: if you
428b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira   * are checking a precondition, please use {@link Preconditions} instead).
438b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira   */
448b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira  public static void assertTrue(boolean b) {
458b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira    if (!b)
468b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira      throw new RuntimeException("Assertion failed");
478b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira  }
488b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira
498b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira  /**
508b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira   * Raise a runtime exception if the supplied argument is false and print
518b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira   * out the error message (note: if you are checking a precondition, please use
528b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira   * {@link Preconditions} instead).
538b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira   */
548b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira  public static void assertTrue(boolean b, String msg) {
558b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira    if (!b)
568b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira      throw new RuntimeException("Assertion failed: " + msg);
578b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira  }
588b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira}