org.grails.datastore.gorm.finders
Class DynamicFinder
java.lang.Object
org.grails.datastore.gorm.finders.AbstractFinder
org.grails.datastore.gorm.finders.DynamicFinder
- All Implemented Interfaces:
- FinderMethod, QueryBuildingFinder
- Direct Known Subclasses:
- AbstractFindByFinder, CountByFinder, FindAllByFinder
public abstract class DynamicFinder
- extends AbstractFinder
- implements QueryBuildingFinder
Abstract base class for dynamic finders.
|
Constructor Summary |
protected |
DynamicFinder(java.util.regex.Pattern pattern,
java.lang.String[] operators,
org.grails.datastore.mapping.core.Datastore datastore)
|
|
Method Summary |
static void |
applyDetachedCriteria(org.grails.datastore.mapping.query.Query q,
grails.gorm.DetachedCriteria detachedCriteria)
|
protected void |
configureQueryWithArguments(java.lang.Class clazz,
org.grails.datastore.mapping.query.Query query,
java.lang.Object[] arguments)
|
DynamicFinderInvocation |
createFinderInvocation(java.lang.Class clazz,
java.lang.String methodName,
groovy.lang.Closure additionalCriteria,
java.lang.Object[] arguments)
|
protected abstract java.lang.Object |
doInvokeInternal(DynamicFinderInvocation invocation)
|
protected MethodExpression |
findMethodExpression(java.lang.Class clazz,
java.lang.String expression)
|
static javax.persistence.FetchType |
getFetchMode(java.lang.Object object)
Retrieves the fetch mode for the specified instance; otherwise returns the default FetchMode. |
java.lang.Object |
invoke(java.lang.Class clazz,
java.lang.String methodName,
groovy.lang.Closure additionalCriteria,
java.lang.Object[] arguments)
Invokes the method |
java.lang.Object |
invoke(java.lang.Class clazz,
java.lang.String methodName,
grails.gorm.DetachedCriteria detachedCriteria,
java.lang.Object[] arguments)
|
java.lang.Object |
invoke(java.lang.Class clazz,
java.lang.String methodName,
java.lang.Object[] arguments)
Invokes the method |
boolean |
isMethodMatch(java.lang.String methodName)
Whether the given method name matches this finder |
static void |
populateArgumentsForCriteria(java.lang.Class<?> targetClass,
org.grails.datastore.mapping.query.Query q,
java.util.Map argMap)
|
static void |
registerNewMethodExpression(java.lang.Class methodExpression)
Registers a new method expression. |
void |
setPattern(java.lang.String pattern)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ARGUMENT_MAX
public static final java.lang.String ARGUMENT_MAX
- See Also:
- Constant Field Values
ARGUMENT_OFFSET
public static final java.lang.String ARGUMENT_OFFSET
- See Also:
- Constant Field Values
ARGUMENT_ORDER
public static final java.lang.String ARGUMENT_ORDER
- See Also:
- Constant Field Values
ARGUMENT_SORT
public static final java.lang.String ARGUMENT_SORT
- See Also:
- Constant Field Values
ORDER_DESC
public static final java.lang.String ORDER_DESC
- See Also:
- Constant Field Values
ORDER_ASC
public static final java.lang.String ORDER_ASC
- See Also:
- Constant Field Values
ARGUMENT_FETCH
public static final java.lang.String ARGUMENT_FETCH
- See Also:
- Constant Field Values
ARGUMENT_IGNORE_CASE
public static final java.lang.String ARGUMENT_IGNORE_CASE
- See Also:
- Constant Field Values
ARGUMENT_CACHE
public static final java.lang.String ARGUMENT_CACHE
- See Also:
- Constant Field Values
ARGUMENT_LOCK
public static final java.lang.String ARGUMENT_LOCK
- See Also:
- Constant Field Values
pattern
protected java.util.regex.Pattern pattern
DynamicFinder
protected DynamicFinder(java.util.regex.Pattern pattern,
java.lang.String[] operators,
org.grails.datastore.mapping.core.Datastore datastore)
registerNewMethodExpression
public static void registerNewMethodExpression(java.lang.Class methodExpression)
- Registers a new method expression. The Class must extends from the class
MethodExpression and provide
a constructor that accepts a Class parameter and a String parameter.
- Parameters:
methodExpression - A class that extends from MethodExpression
setPattern
public void setPattern(java.lang.String pattern)
- Specified by:
setPattern in interface FinderMethod
- Parameters:
pattern - A regular expression
isMethodMatch
public boolean isMethodMatch(java.lang.String methodName)
- Description copied from interface:
FinderMethod
- Whether the given method name matches this finder
- Specified by:
isMethodMatch in interface FinderMethod
- Parameters:
methodName - The method name
- Returns:
- true if it does
invoke
public java.lang.Object invoke(java.lang.Class clazz,
java.lang.String methodName,
groovy.lang.Closure additionalCriteria,
java.lang.Object[] arguments)
- Description copied from interface:
FinderMethod
- Invokes the method
- Specified by:
invoke in interface FinderMethod
- Parameters:
clazz - The classmethodName - The method nameadditionalCriteria - additional criteria closurearguments - The arguments
- Returns:
- The return value
invoke
public java.lang.Object invoke(java.lang.Class clazz,
java.lang.String methodName,
grails.gorm.DetachedCriteria detachedCriteria,
java.lang.Object[] arguments)
createFinderInvocation
public DynamicFinderInvocation createFinderInvocation(java.lang.Class clazz,
java.lang.String methodName,
groovy.lang.Closure additionalCriteria,
java.lang.Object[] arguments)
findMethodExpression
protected MethodExpression findMethodExpression(java.lang.Class clazz,
java.lang.String expression)
doInvokeInternal
protected abstract java.lang.Object doInvokeInternal(DynamicFinderInvocation invocation)
invoke
public java.lang.Object invoke(java.lang.Class clazz,
java.lang.String methodName,
java.lang.Object[] arguments)
- Description copied from interface:
FinderMethod
- Invokes the method
- Specified by:
invoke in interface FinderMethod
- Parameters:
clazz - The classmethodName - The method namearguments - The arguments
- Returns:
- The return value
populateArgumentsForCriteria
public static void populateArgumentsForCriteria(java.lang.Class<?> targetClass,
org.grails.datastore.mapping.query.Query q,
java.util.Map argMap)
getFetchMode
public static javax.persistence.FetchType getFetchMode(java.lang.Object object)
- Retrieves the fetch mode for the specified instance; otherwise returns the default FetchMode.
- Parameters:
object - The object, converted to a string
- Returns:
- The FetchMode
configureQueryWithArguments
protected void configureQueryWithArguments(java.lang.Class clazz,
org.grails.datastore.mapping.query.Query query,
java.lang.Object[] arguments)
applyDetachedCriteria
public static void applyDetachedCriteria(org.grails.datastore.mapping.query.Query q,
grails.gorm.DetachedCriteria detachedCriteria)