View Javadoc
1   /*
2    *    Copyright 2009-2023 the original author or authors.
3    *
4    *    Licensed under the Apache License, Version 2.0 (the "License");
5    *    you may not use this file except in compliance with the License.
6    *    You may obtain a copy of the License at
7    *
8    *       https://www.apache.org/licenses/LICENSE-2.0
9    *
10   *    Unless required by applicable law or agreed to in writing, software
11   *    distributed under the License is distributed on an "AS IS" BASIS,
12   *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *    See the License for the specific language governing permissions and
14   *    limitations under the License.
15   */
16  package org.apache.ibatis.builder.annotation;
17  
18  import java.lang.reflect.Method;
19  
20  /**
21   * The context object for sql provider method.
22   *
23   * @author Kazuki Shimizu
24   *
25   * @since 3.4.5
26   */
27  public final class ProviderContext {
28  
29    private final Class<?> mapperType;
30    private final Method mapperMethod;
31    private final String databaseId;
32  
33    /**
34     * Constructor.
35     *
36     * @param mapperType
37     *          A mapper interface type that specified provider
38     * @param mapperMethod
39     *          A mapper method that specified provider
40     * @param databaseId
41     *          A database id
42     */
43    ProviderContext(Class<?> mapperType, Method mapperMethod, String databaseId) {
44      this.mapperType = mapperType;
45      this.mapperMethod = mapperMethod;
46      this.databaseId = databaseId;
47    }
48  
49    /**
50     * Get a mapper interface type that specified provider.
51     *
52     * @return A mapper interface type that specified provider
53     */
54    public Class<?> getMapperType() {
55      return mapperType;
56    }
57  
58    /**
59     * Get a mapper method that specified provider.
60     *
61     * @return A mapper method that specified provider
62     */
63    public Method getMapperMethod() {
64      return mapperMethod;
65    }
66  
67    /**
68     * Get a database id that provided from {@link org.apache.ibatis.mapping.DatabaseIdProvider}.
69     *
70     * @return A database id
71     *
72     * @since 3.5.1
73     */
74    public String getDatabaseId() {
75      return databaseId;
76    }
77  
78  }