Interface ObjectFactory

  • All Known Implementing Classes:
    DefaultObjectFactory

    public interface ObjectFactory
    MyBatis uses an ObjectFactory to create all needed new Objects.
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      <T> T create​(java.lang.Class<T> type)
      Creates a new object with default constructor.
      <T> T create​(java.lang.Class<T> type, java.util.List<java.lang.Class<?>> constructorArgTypes, java.util.List<java.lang.Object> constructorArgs)
      Creates a new object with the specified constructor and params.
      <T> boolean isCollection​(java.lang.Class<T> type)
      Returns true if this object can have a set of other objects.
      default void setProperties​(java.util.Properties properties)
      Sets configuration properties.
    • Method Detail

      • setProperties

        default void setProperties​(java.util.Properties properties)
        Sets configuration properties.
        Parameters:
        properties - configuration properties
      • create

        <T> T create​(java.lang.Class<T> type)
        Creates a new object with default constructor.
        Type Parameters:
        T - the generic type
        Parameters:
        type - Object type
        Returns:
        the t
      • create

        <T> T create​(java.lang.Class<T> type,
                     java.util.List<java.lang.Class<?>> constructorArgTypes,
                     java.util.List<java.lang.Object> constructorArgs)
        Creates a new object with the specified constructor and params.
        Type Parameters:
        T - the generic type
        Parameters:
        type - Object type
        constructorArgTypes - Constructor argument types
        constructorArgs - Constructor argument values
        Returns:
        the t
      • isCollection

        <T> boolean isCollection​(java.lang.Class<T> type)
        Returns true if this object can have a set of other objects. It's main purpose is to support non-java.util.Collection objects like Scala collections.
        Type Parameters:
        T - the generic type
        Parameters:
        type - Object type
        Returns:
        whether it is a collection or not
        Since:
        3.1.0