net.sourceforge.domian.specification
Class SpecificationUtils

java.lang.Object
  extended by net.sourceforge.domian.specification.SpecificationUtils

public final class SpecificationUtils
extends java.lang.Object

Methods that should ideally be part of the Specification interface, or AbstractSpecification or something.... Maybe they will in the future, but until then, they reside here.

Since:
0.4
Author:
Eirik Torske

Constructor Summary
SpecificationUtils()
           
 
Method Summary
static
<T extends Entity>
Specification<T>
createUniqueSpecificationFor(T entity)
           
static java.lang.Boolean typeSafeIsSatisfiedBy(Specification specification, java.lang.Object candidate)
          Raw, yet type-safe version of Specification.isSatisfiedBy().
static
<T extends Entity>
void
updateEntityState(T entity, Specification<?> deltaSpecification)
          Updates given entity with given value bound specifications.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpecificationUtils

public SpecificationUtils()
Method Detail

typeSafeIsSatisfiedBy

public static java.lang.Boolean typeSafeIsSatisfiedBy(Specification specification,
                                                      java.lang.Object candidate)
Raw, yet type-safe version of Specification.isSatisfiedBy(). This is a hack, needed when, by runtime, it is unclear whether candidate object is within specification bounds. Implemented just to avoid boiler-plate code... The methods uses raw parameters to avoid redundant casting...


createUniqueSpecificationFor

public static <T extends Entity> Specification<T> createUniqueSpecificationFor(T entity)
Returns:
a unique specification based on equality to the given entity's ID

updateEntityState

public static <T extends Entity> void updateEntityState(T entity,
                                                        Specification<?> deltaSpecification)
Updates given entity with given value bound specifications.

Type Parameters:
T - the entity type
Parameters:
entity - the entity
deltaSpecification - a specification specifying the differences this update will have compared to the previously retrieved entity version. The specification should be a conjuction of field bound equality specifications only, or null if optimistic locking usage is completely out of scope


Copyright © 2006-2010. All Rights Reserved.