Class Contracts

java.lang.Object
org.apache.hadoop.metrics2.util.Contracts

@Private public class Contracts extends Object
Additional helpers (besides guava Preconditions) for programming by contract
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    checkArg(double arg, boolean expression, Object msg)
    Check an argument for false conditions
    static float
    checkArg(float arg, boolean expression, Object msg)
    Check an argument for false conditions
    static int
    checkArg(int arg, boolean expression, Object msg)
    Check an argument for false conditions
    static long
    checkArg(long arg, boolean expression, Object msg)
    Check an argument for false conditions
    static <T> T
    checkArg(T arg, boolean expression, Object msg)
    Check an argument for false conditions

    Methods inherited from class java.lang.Object

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

    • checkArg

      public static <T> T checkArg(T arg, boolean expression, Object msg)
      Check an argument for false conditions
      Type Parameters:
      T - type of the argument
      Parameters:
      arg - the argument to check
      expression - the boolean expression for the condition
      msg - the error message if expression is false
      Returns:
      the argument for convenience
    • checkArg

      public static int checkArg(int arg, boolean expression, Object msg)
      Check an argument for false conditions
      Parameters:
      arg - the argument to check
      expression - the boolean expression for the condition
      msg - the error message if expression is false
      Returns:
      the argument for convenience
    • checkArg

      public static long checkArg(long arg, boolean expression, Object msg)
      Check an argument for false conditions
      Parameters:
      arg - the argument to check
      expression - the boolean expression for the condition
      msg - the error message if expression is false
      Returns:
      the argument for convenience
    • checkArg

      public static float checkArg(float arg, boolean expression, Object msg)
      Check an argument for false conditions
      Parameters:
      arg - the argument to check
      expression - the boolean expression for the condition
      msg - the error message if expression is false
      Returns:
      the argument for convenience
    • checkArg

      public static double checkArg(double arg, boolean expression, Object msg)
      Check an argument for false conditions
      Parameters:
      arg - the argument to check
      expression - the boolean expression for the condition
      msg - the error message if expression is false
      Returns:
      the argument for convenience