1 /* 2 * Copyright 2009-2021 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 default void setProperties(Properties properties) { 33 // NOP 34 } 35 36 /** 37 * Creates a new object with default constructor. 38 * 39 * @param <T> 40 * the generic type 41 * @param type 42 * Object type 43 * @return the t 44 */ 45 <T> T create(Class<T> type); 46 47 /** 48 * Creates a new object with the specified constructor and params. 49 * 50 * @param <T> 51 * the generic type 52 * @param type 53 * Object type 54 * @param constructorArgTypes 55 * Constructor argument types 56 * @param constructorArgs 57 * Constructor argument values 58 * @return the t 59 */ 60 <T> T create(Class<T> type, List<Class<?>> constructorArgTypes, List<Object> constructorArgs); 61 62 /** 63 * Returns true if this object can have a set of other objects. 64 * It's main purpose is to support non-java.util.Collection objects like Scala collections. 65 * 66 * @param <T> 67 * the generic type 68 * @param type 69 * Object type 70 * @return whether it is a collection or not 71 * @since 3.1.0 72 */ 73 <T> boolean isCollection(Class<T> type); 74 75 }