ProviderContext.java

  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. import java.lang.reflect.Method;

  18. /**
  19.  * The context object for sql provider method.
  20.  *
  21.  * @author Kazuki Shimizu
  22.  *
  23.  * @since 3.4.5
  24.  */
  25. public final class ProviderContext {

  26.   private final Class<?> mapperType;
  27.   private final Method mapperMethod;
  28.   private final String databaseId;

  29.   /**
  30.    * Constructor.
  31.    *
  32.    * @param mapperType
  33.    *          A mapper interface type that specified provider
  34.    * @param mapperMethod
  35.    *          A mapper method that specified provider
  36.    * @param databaseId
  37.    *          A database id
  38.    */
  39.   ProviderContext(Class<?> mapperType, Method mapperMethod, String databaseId) {
  40.     this.mapperType = mapperType;
  41.     this.mapperMethod = mapperMethod;
  42.     this.databaseId = databaseId;
  43.   }

  44.   /**
  45.    * Get a mapper interface type that specified provider.
  46.    *
  47.    * @return A mapper interface type that specified provider
  48.    */
  49.   public Class<?> getMapperType() {
  50.     return mapperType;
  51.   }

  52.   /**
  53.    * Get a mapper method that specified provider.
  54.    *
  55.    * @return A mapper method that specified provider
  56.    */
  57.   public Method getMapperMethod() {
  58.     return mapperMethod;
  59.   }

  60.   /**
  61.    * Get a database id that provided from {@link org.apache.ibatis.mapping.DatabaseIdProvider}.
  62.    *
  63.    * @return A database id
  64.    *
  65.    * @since 3.5.1
  66.    */
  67.   public String getDatabaseId() {
  68.     return databaseId;
  69.   }

  70. }