View Javadoc
1   /**
2    *    Copyright 2009-2015 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    *       http://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.reflection.factory;
17  
18  import java.util.List;
19  import java.util.Properties;
20  
21  /**
22   * MyBatis uses an ObjectFactory to create all needed new Objects.
23   * 
24   * @author Clinton Begin
25   */
26  public interface ObjectFactory {
27  
28    /**
29     * Sets configuration properties.
30     * @param properties configuration properties
31     */
32    void setProperties(Properties properties);
33  
34    /**
35     * Creates a new object with default constructor. 
36     * @param type Object type
37     * @return
38     */
39    <T> T create(Class<T> type);
40  
41    /**
42     * Creates a new object with the specified constructor and params.
43     * @param type Object type
44     * @param constructorArgTypes Constructor argument types
45     * @param constructorArgs Constructor argument values
46     * @return
47     */
48    <T> T create(Class<T> type, List<Class<?>> constructorArgTypes, List<Object> constructorArgs);
49    
50    /**
51     * Returns true if this object can have a set of other objects.
52     * It's main purpose is to support non-java.util.Collection objects like Scala collections.
53     * 
54     * @since 3.1.0
55     * @param type Object type
56     * @return whether it is a collection or not
57     */
58    <T> boolean isCollection(Class<T> type);
59  
60  }