org.nakedobjects.metamodel.commons.ensure
Class Ensure

java.lang.Object
  extended by org.nakedobjects.metamodel.commons.ensure.Ensure

public final class Ensure
extends java.lang.Object

Uses the Hamcrest API as a means of verifying arguments and so on.


Method Summary
static
<T> T
ensureThatArg(T object, org.hamcrest.Matcher<T> matcher)
          To ensure that the provided argument is correct.
static
<T> T
ensureThatArg(T arg, org.hamcrest.Matcher<T> matcher, java.lang.String message)
          To ensure that the provided argument is correct.
static
<T> T
ensureThatContext(T contextProperty, org.hamcrest.Matcher<T> matcher)
          To ensure that the current context (NakedObjectsContext) is correct.
static
<T> T
ensureThatContext(T contextProperty, org.hamcrest.Matcher<T> matcher, java.lang.String message)
          To ensure that the current context (NakedObjectsContext) is correct.
static
<T> T
ensureThatState(T field, org.hamcrest.Matcher<T> matcher)
          To ensure that the current state of this object (instance fields) is correct.
static
<T> T
ensureThatState(T field, org.hamcrest.Matcher<T> matcher, java.lang.String message)
          To ensure that the current state of this object (instance fields) is correct.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

ensureThatArg

public static <T> T ensureThatArg(T object,
                                  org.hamcrest.Matcher<T> matcher)
To ensure that the provided argument is correct.

Throws:
java.lang.IllegalArgumentException - if matcher does not match.
See Also:
#ensureThatArg(Object, Matcher,State), ensureThatState(Object, Matcher, String), ensureThatContext(Object, Matcher)

ensureThatArg

public static <T> T ensureThatArg(T arg,
                                  org.hamcrest.Matcher<T> matcher,
                                  java.lang.String message)
To ensure that the provided argument is correct.

Throws:
java.lang.IllegalArgumentException - if matcher does not match.
See Also:
ensureThatArg(Object, Matcher), ensureThatState(Object, Matcher, String), ensureThatContext(Object, Matcher)

ensureThatState

public static <T> T ensureThatState(T field,
                                    org.hamcrest.Matcher<T> matcher)
To ensure that the current state of this object (instance fields) is correct.

Throws:
java.lang.IllegalStateException - if matcher does not match.
See Also:
ensureThatArg(Object, Matcher), ensureThatContext(Object, Matcher), ensureThatState(Object, Matcher, String)

ensureThatState

public static <T> T ensureThatState(T field,
                                    org.hamcrest.Matcher<T> matcher,
                                    java.lang.String message)
To ensure that the current state of this object (instance fields) is correct.

Throws:
java.lang.IllegalStateException - if matcher does not match.
See Also:
ensureThatArg(Object, Matcher), ensureThatContext(Object, Matcher), ensureThatState(Object, Matcher)

ensureThatContext

public static <T> T ensureThatContext(T contextProperty,
                                      org.hamcrest.Matcher<T> matcher)
To ensure that the current context (NakedObjectsContext) is correct.

Throws:
java.lang.IllegalThreadStateException - if matcher does not match.
See Also:
ensureThatArg(Object, Matcher), ensureThatState(Object, Matcher), ensureThatContext(Object, Matcher, String)

ensureThatContext

public static <T> T ensureThatContext(T contextProperty,
                                      org.hamcrest.Matcher<T> matcher,
                                      java.lang.String message)
To ensure that the current context (NakedObjectsContext) is correct.

Throws:
java.lang.IllegalThreadStateException - if matcher does not match.
See Also:
ensureThatArg(Object, Matcher), ensureThatState(Object, Matcher), ensureThatContext(Object, Matcher, String)


Copyright © 2001-2009 Naked Objects Group Ltd.. All Rights Reserved.