net.sourceforge.domian.specification
Class SpecificationUtils
java.lang.Object
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
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SpecificationUtils
public SpecificationUtils()
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 entitydeltaSpecification
- 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.