net.sourceforge.domian.specification
Interface Specification<T>

All Known Subinterfaces:
CompositeSpecification<T>, LeafSpecification<T>, ValueBoundSpecification<T>
All Known Implementing Classes:
AbstractCompositeSpecification, AbstractValueBoundSpecification, AlwaysFalseSpecification, AlwaysTrueSpecification, BlankStringSpecification, CollectionSpecification, ConjuntionSpecification, DateStringSpecification, DefaultValueSpecification, DisjuntionSpecification, EnumNameStringSpecification, EqualIgnoreCaseStringSpecification, EqualSpecification, FieldParameterizedSpecification, GreaterThanOrEqualSpecification, GreaterThanSpecification, JointDenialSpecification, LessThanOrEqualSpecification, LessThanSpecification, MethodParameterizedSpecification, NotNullSpecification, ParameterizedSpecification, PartitionRepositoryInvocationHandler.PartitionAwareSpecification, RegularExpressionMatcherStringSpecification, WildcardExpressionMatcherIgnoreCaseStringSpecification, WildcardExpressionMatcherStringSpecification

public interface Specification<T>

Part of the Evans/Fowler Specifications pattern.

Note on type parameterization:
Domian specifications are typed. It is only relevant to send candidate objects of correct type to a Specification for approval. Generics should be used when creating specifications, making this specification type vs. candidate type a compile-time issue.

Since:
0.1
Author:
Eirik Torske
See Also:
The Specifications Pattern

Method Summary
 java.lang.Class<T> getType()
           
 java.lang.Boolean isGeneralizationOf(Specification<? extends T> specification)
          Specification subsumption.
 java.lang.Boolean isSatisfiedBy(T candidate)
          Specification satisfaction.
 java.lang.Boolean isSpecialCaseOf(Specification<? super T> specification)
          Specification subsumption.
 

Method Detail

getType

java.lang.Class<T> getType()
Returns:
the specification type

isSatisfiedBy

java.lang.Boolean isSatisfiedBy(T candidate)
Specification satisfaction.

Parameters:
candidate - The candidate object
Returns:
true only if this specification is satisfied by/approves the given candidate (null is never approved)

isGeneralizationOf

java.lang.Boolean isGeneralizationOf(Specification<? extends T> specification)
Specification subsumption.

Given:

  1. Set K consisting of candidates specified by specA : specA.isSatisfiedBy(candidate)
  2. Set L consisting of candidates specified by specB : specB.isSatisfiedBy(candidate)
Then:
if specA.isGeneralizationOf(specB) => Set K contains Set L [Set K UNION Set L = Set K]

Parameters:
specification - The candidate specification
Returns:
true only if this specification is a generalization of the given candidate specification
Throws:
java.lang.IllegalArgumentException - if parameter is null
Since:
0.3

isSpecialCaseOf

java.lang.Boolean isSpecialCaseOf(Specification<? super T> specification)
Specification subsumption.

Given:

  1. Set K consisting of candidates specified by specA : specA.isSatisfiedBy(candidate)
  2. Set L consisting of candidates specified by specB : specB.isSatisfiedBy(candidate)
Then:
if specA.isSpecializationOf(specB) => Set L contains Set K [Set K UNION Set L = Set L]

Parameters:
specification - The candidate specification
Returns:
true only if this specification is a special case of the given candidate specification
Throws:
java.lang.IllegalArgumentException - if parameter is null
Since:
0.3


Copyright © 2006-2009. All Rights Reserved.