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;
19  
20  import org.jetbrains.annotations.NotNull;
21  
22  /**
23   * Pluggable mechanism for query argument transformation.
24   *
25   * <p>See <a href="http://autodao.sourceforge.net/guide.html#Custom_query_argument_transformation">Custom query argument
26   * transformation</a> for usage.
27   *
28   * @param <F> input argument type this transformer can process.
29   * @param <T> output argument type this transformer produces.
30   * @since AutoDAO 0.6
31   */
32  public interface QueryArgumentTransformer<F, T> {
33    /**
34     * Performs query argument transformation.
35     *
36     * @param argument initial argument that was passed to DAO.
37     * @return transformed argument that'll be passed to underlying ORM.
38     */
39    @NotNull
40    T transform(@NotNull F argument);
41  
42    /** @return output argument type this transformer produces. */
43    @NotNull
44    Class<T> getTargetType();
45  }