View Javadoc
1   /*
2    * AutoDAO - Generic DAO on steroids implementation for Java.
3    *
4    * Copyright 2008-2012  Marat Radchenko <slonopotamus@users.sourceforge.net>
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   * http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package net.sf.autodao.impl;
19  
20  import java.lang.reflect.Method;
21  import java.util.List;
22  import java.util.Map;
23  
24  import org.jetbrains.annotations.NotNull;
25  import org.jetbrains.annotations.Nullable;
26  
27  /**
28   * Implemented by AutoDAO implementations.
29   *
30   * <p>NOT FOR PUBLIC USE.
31   */
32  public interface FinderExecutor {
33  
34    @NotNull
35    <T> List<T> executeListFinder(@NotNull final Method method,
36                                  @NotNull final Map<String, ?> namedArgs,
37                                  @Nullable final Integer limit,
38                                  @Nullable final Integer offset);
39  
40    /**
41     * Execute a finder method with the appropriate arguments.
42     *
43     * @param method      query method.
44     * @param indexedArgs arguments for query method
45     * @param limit       query limit. Can be <code>null</code>. See {@link net.sf.autodao.Limit}.
46     * @param offset      query offset. Can be <code>null</code>. See {@link net.sf.autodao.Offset}.
47     * @return list of found objects or empty list.
48     */
49    @NotNull
50    <T> List<T> executeListFinder(@NotNull final Method method,
51                                  @NotNull final Object[] indexedArgs,
52                                  @Nullable final Integer limit,
53                                  @Nullable final Integer offset);
54  
55    @Nullable
56    <T> T executeSingleFinder(@NotNull final Method method, @NotNull final Map<String, ?> namedArgs);
57  
58    /**
59     * Same as {@link #executeListFinder(Method, Object[], Integer, Integer)} but for single result.
60     *
61     * @param method      query method.
62     * @param indexedArgs arguments for query method.
63     * @return found object or <code>null</code>
64     */
65    @Nullable
66    <T> T executeSingleFinder(@NotNull final Method method, @NotNull final Object[] indexedArgs);
67  }