Contracts (Hadoop 1.2.1 API)
Date: 2013-07-22

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.hadoop.metrics2.util
Class Contracts

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

    public class Contracts

extends Object

Utilities for programming by contract (preconditions, postconditions etc.)

Method Summary
`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
`static
`<T> T`
` | `checkNotNull(T ref, Object msg)` Check that a reference is not null.
`static void` | `checkState(boolean expression, Object msg)` Check the state expression for false conditions

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### checkNotNull

    public static <T> T checkNotNull(T ref,
                                     Object msg)

  Check that a reference is not null.

  Type Parameters:
    `T` - type of the reference
  Parameters:
    `ref` - the reference to check
    `msg` - the error message
  Returns:
    the checked reference for convenience
  Throws:
    `NullPointerException` - if `ref` is null

### checkState

    public static void checkState(boolean expression,
                                  Object msg)

  Check the state expression for false conditions

  Parameters:
    `expression` - the boolean expression to check
    `msg` - the error message if `expression` is false
  Throws:
    `IllegalStateException` - if `expression` is false

### 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

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2009 The Apache Software Foundation