View Javadoc
1   /*
2    *    Copyright 2009-2026 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.mapping;
17  
18  import java.util.List;
19  
20  import org.apache.ibatis.session.Configuration;
21  
22  /**
23   * @author Clinton Begin
24   */
25  public class ParameterMap {
26  
27    private String id;
28    private Class<?> type;
29    private List<ParameterMapping> parameterMappings;
30  
31    private ParameterMap() {
32    }
33  
34    public static ParameterMap buildEmpty(String statementId, Class<?> parameterType) {
35      ParameterMap emptyParameterMap = new ParameterMap();
36      emptyParameterMap.id = statementId;
37      emptyParameterMap.type = parameterType;
38      emptyParameterMap.parameterMappings = List.of();
39      return emptyParameterMap;
40    }
41  
42    public static class Builder {
43      private final ParameterMap parameterMap = new ParameterMap();
44  
45      public Builder(Configuration configuration, String id, Class<?> type, List<ParameterMapping> parameterMappings) {
46        parameterMap.id = id;
47        parameterMap.type = type;
48        parameterMap.parameterMappings = parameterMappings;
49      }
50  
51      public Class<?> type() {
52        return parameterMap.type;
53      }
54  
55      public ParameterMap build() {
56        // lock down collections
57        parameterMap.parameterMappings = List.copyOf(parameterMap.parameterMappings);
58        return parameterMap;
59      }
60    }
61  
62    public String getId() {
63      return id;
64    }
65  
66    public Class<?> getType() {
67      return type;
68    }
69  
70    public List<ParameterMapping> getParameterMappings() {
71      return parameterMappings;
72    }
73  
74  }