org.nakedobjects.applib.spec
Class AbstractSpecification<T>

java.lang.Object
  extended by org.nakedobjects.applib.spec.AbstractSpecification<T>
All Implemented Interfaces:
Specification

public abstract class AbstractSpecification<T>
extends java.lang.Object
implements Specification

Adapter to make it easy to write Specifications.

Provides two main features:

Implementation note: inspired by (borrowed code from) Hamcrest's TypeSafeMatcher.


Nested Class Summary
static class AbstractSpecification.Nullability
           
static class AbstractSpecification.TypeChecking
           
 
Constructor Summary
protected AbstractSpecification()
           
protected AbstractSpecification(AbstractSpecification.Nullability nullability, AbstractSpecification.TypeChecking typeChecking)
           
 
Method Summary
 java.lang.String satisfies(java.lang.Object obj)
          Checks not null and is correct type, and delegates to satisfiesSafely(Object).
abstract  java.lang.String satisfiesSafely(T obj)
          If null then satisfied, otherwise is reason why the specification is not satisfied.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractSpecification

protected AbstractSpecification()

AbstractSpecification

protected AbstractSpecification(AbstractSpecification.Nullability nullability,
                                AbstractSpecification.TypeChecking typeChecking)
Method Detail

satisfies

public final java.lang.String satisfies(java.lang.Object obj)
Checks not null and is correct type, and delegates to satisfiesSafely(Object).

Specified by:
satisfies in interface Specification

satisfiesSafely

public abstract java.lang.String satisfiesSafely(T obj)
If null then satisfied, otherwise is reason why the specification is not satisfied.

Subclasses should implement this. The item will already have been checked for the specific type and will never be null.



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