当前位置: 首页>>代码示例>>Java>>正文


Java MetaClass.forClass方法代码示例

本文整理汇总了Java中org.apache.ibatis.reflection.MetaClass.forClass方法的典型用法代码示例。如果您正苦于以下问题:Java MetaClass.forClass方法的具体用法?Java MetaClass.forClass怎么用?Java MetaClass.forClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.ibatis.reflection.MetaClass的用法示例。


在下文中一共展示了MetaClass.forClass方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: resolveParameterJavaType

import org.apache.ibatis.reflection.MetaClass; //导入方法依赖的package包/类
private Class<?> resolveParameterJavaType(Class<?> resultType, String property, Class<?> javaType, JdbcType jdbcType) {
  if (javaType == null) {
    if (JdbcType.CURSOR.equals(jdbcType)) {
      javaType = java.sql.ResultSet.class;
    } else if (Map.class.isAssignableFrom(resultType)) {
      javaType = Object.class;
    } else {
      MetaClass metaResultType = MetaClass.forClass(resultType, configuration.getReflectorFactory());
      javaType = metaResultType.getGetterType(property);
    }
  }
  if (javaType == null) {
    javaType = Object.class;
  }
  return javaType;
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:17,代码来源:MapperBuilderAssistant.java

示例2: createResultObject

import org.apache.ibatis.reflection.MetaClass; //导入方法依赖的package包/类
private Object createResultObject(ResultSetWrapper rsw, ResultMap resultMap, List<Class<?>> constructorArgTypes, List<Object> constructorArgs, String columnPrefix)
    throws SQLException {
  final Class<?> resultType = resultMap.getType();
  final MetaClass metaType = MetaClass.forClass(resultType, reflectorFactory);
  final List<ResultMapping> constructorMappings = resultMap.getConstructorResultMappings();
  if (hasTypeHandlerForResultObject(rsw, resultType)) {
    return createPrimitiveResultObject(rsw, resultMap, columnPrefix);
  } else if (!constructorMappings.isEmpty()) {
    return createParameterizedResultObject(rsw, resultType, constructorMappings, constructorArgTypes, constructorArgs, columnPrefix);
  } else if (resultType.isInterface() || metaType.hasDefaultConstructor()) {
    return objectFactory.create(resultType);
  } else if (shouldApplyAutomaticMappings(resultMap, false)) {
    return createByConstructorSignature(rsw, resultType, constructorArgTypes, constructorArgs, columnPrefix);
  }
  throw new ExecutorException("Do not know how to create an instance of " + resultType);
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:17,代码来源:DefaultResultSetHandler.java

示例3: createRowKeyForUnmappedProperties

import org.apache.ibatis.reflection.MetaClass; //导入方法依赖的package包/类
private void createRowKeyForUnmappedProperties(ResultMap resultMap, ResultSetWrapper rsw, CacheKey cacheKey, String columnPrefix) throws SQLException {
  final MetaClass metaType = MetaClass.forClass(resultMap.getType(), reflectorFactory);
  List<String> unmappedColumnNames = rsw.getUnmappedColumnNames(resultMap, columnPrefix);
  for (String column : unmappedColumnNames) {
    String property = column;
    if (columnPrefix != null && !columnPrefix.isEmpty()) {
      // When columnPrefix is specified, ignore columns without the prefix.
      if (column.toUpperCase(Locale.ENGLISH).startsWith(columnPrefix)) {
        property = column.substring(columnPrefix.length());
      } else {
        continue;
      }
    }
    if (metaType.findProperty(property, configuration.isMapUnderscoreToCamelCase()) != null) {
      String value = rsw.getResultSet().getString(column);
      if (value != null) {
        cacheKey.update(column);
        cacheKey.update(value);
      }
    }
  }
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:23,代码来源:DefaultResultSetHandler.java

示例4: settingsAsPropertiess

import org.apache.ibatis.reflection.MetaClass; //导入方法依赖的package包/类
private Properties settingsAsPropertiess(XNode context) {
  if (context == null) {
    return new Properties();
  }
  // 源码解析: settings配置转换为Properties
  Properties props = context.getChildrenAsProperties();
  // Check that all settings are known to the configuration class

  // 源码解析: 检查所有的settings配置是否有效
  MetaClass metaConfig = MetaClass.forClass(Configuration.class, localReflectorFactory);
  for (Object key : props.keySet()) {
    if (!metaConfig.hasSetter(String.valueOf(key))) {
      throw new BuilderException("The setting " + key + " is not known.  Make sure you spelled it correctly (case sensitive).");
    }
  }
  return props;
}
 
开发者ID:txazo,项目名称:mybatis,代码行数:18,代码来源:XMLConfigBuilder.java

示例5: resolveParameterJavaType

import org.apache.ibatis.reflection.MetaClass; //导入方法依赖的package包/类
private Class<?> resolveParameterJavaType(Class<?> resultType, String property, Class<?> javaType, JdbcType jdbcType) {
  if (javaType == null) {
    if (JdbcType.CURSOR.equals(jdbcType)) {
      javaType = java.sql.ResultSet.class;
    } else if (Map.class.isAssignableFrom(resultType)) {
      javaType = Object.class;
    } else {
      MetaClass metaResultType = MetaClass.forClass(resultType);
      javaType = metaResultType.getGetterType(property);
    }
  }
  if (javaType == null) {
    javaType = Object.class;
  }
  return javaType;
}
 
开发者ID:shurun19851206,项目名称:mybaties,代码行数:17,代码来源:MapperBuilderAssistant.java

示例6: createResultObject

import org.apache.ibatis.reflection.MetaClass; //导入方法依赖的package包/类
private Object createResultObject(ResultSetWrapper rsw, ResultMap resultMap, List<Class<?>> constructorArgTypes, List<Object> constructorArgs, String columnPrefix)
     throws SQLException {
//得到result type
   final Class<?> resultType = resultMap.getType();
   final MetaClass metaType = MetaClass.forClass(resultType);
   final List<ResultMapping> constructorMappings = resultMap.getConstructorResultMappings();
   if (typeHandlerRegistry.hasTypeHandler(resultType)) {
     //基本型
     return createPrimitiveResultObject(rsw, resultMap, columnPrefix);
   } else if (!constructorMappings.isEmpty()) {
     //有参数的构造函数
     return createParameterizedResultObject(rsw, resultType, constructorMappings, constructorArgTypes, constructorArgs, columnPrefix);
   } else if (resultType.isInterface() || metaType.hasDefaultConstructor()) {
     //普通bean类型
     return objectFactory.create(resultType);
   } else if (shouldApplyAutomaticMappings(resultMap, false)) {
     //自动映射
     return createByConstructorSignature(rsw, resultType, constructorArgTypes, constructorArgs, columnPrefix);
   }
   throw new ExecutorException("Do not know how to create an instance of " + resultType);
 }
 
开发者ID:shurun19851206,项目名称:mybaties,代码行数:22,代码来源:DefaultResultSetHandler.java

示例7: createRowKeyForUnmappedProperties

import org.apache.ibatis.reflection.MetaClass; //导入方法依赖的package包/类
private void createRowKeyForUnmappedProperties(ResultMap resultMap, ResultSetWrapper rsw, CacheKey cacheKey, String columnPrefix) throws SQLException {
  final MetaClass metaType = MetaClass.forClass(resultMap.getType());
  List<String> unmappedColumnNames = rsw.getUnmappedColumnNames(resultMap, columnPrefix);
  for (String column : unmappedColumnNames) {
    String property = column;
    if (columnPrefix != null && !columnPrefix.isEmpty()) {
      // When columnPrefix is specified, ignore columns without the prefix.
      if (column.toUpperCase(Locale.ENGLISH).startsWith(columnPrefix)) {
        property = column.substring(columnPrefix.length());
      } else {
        continue;
      }
    }
    if (metaType.findProperty(property, configuration.isMapUnderscoreToCamelCase()) != null) {
      String value = rsw.getResultSet().getString(column);
      if (value != null) {
        cacheKey.update(column);
        cacheKey.update(value);
      }
    }
  }
}
 
开发者ID:shurun19851206,项目名称:mybaties,代码行数:23,代码来源:DefaultResultSetHandler.java

示例8: resolveResultJavaType

import org.apache.ibatis.reflection.MetaClass; //导入方法依赖的package包/类
/**
 * copy from mybatis sourceCode
 *
 * @param resultType
 * @param property
 * @param javaType
 * @return
 */
private Class<?> resolveResultJavaType(Class<?> resultType, String property, Class<?> javaType) {
  if (javaType == null && property != null) {
    try {
      MetaClass metaResultType = MetaClass.forClass(resultType, REFLECTOR_FACTORY);
      javaType = metaResultType.getSetterType(property);
    } catch (Exception ignored) {
      // ignore, following null check statement will deal with the
      // situation
    }
  }
  if (javaType == null) {
    javaType = Object.class;
  }
  return javaType;
}
 
开发者ID:colin-lee,项目名称:mybatis-spring-support,代码行数:24,代码来源:PaginationAutoMapInterceptor.java

示例9: createResultObject

import org.apache.ibatis.reflection.MetaClass; //导入方法依赖的package包/类
private Object createResultObject(ResultSetWrapper rsw, ResultMap resultMap, List<Class<?>> constructorArgTypes, List<Object> constructorArgs, String columnPrefix)
    throws SQLException {
  final Class<?> resultType = resultMap.getType();
  final MetaClass metaType = MetaClass.forClass(resultType, reflectorFactory);
  final List<ResultMapping> constructorMappings = resultMap.getConstructorResultMappings();
  if (typeHandlerRegistry.hasTypeHandler(resultType)) {
    return createPrimitiveResultObject(rsw, resultMap, columnPrefix);
  } else if (!constructorMappings.isEmpty()) {
    return createParameterizedResultObject(rsw, resultType, constructorMappings, constructorArgTypes, constructorArgs, columnPrefix);
  } else if (resultType.isInterface() || metaType.hasDefaultConstructor()) {
    return objectFactory.create(resultType);
  } else if (shouldApplyAutomaticMappings(resultMap, false)) {
    return createByConstructorSignature(rsw, resultType, constructorArgTypes, constructorArgs, columnPrefix);
  }
  throw new ExecutorException("Do not know how to create an instance of " + resultType);
}
 
开发者ID:toulezu,项目名称:play,代码行数:17,代码来源:DefaultResultSetHandler.java

示例10: settingsAsProperties

import org.apache.ibatis.reflection.MetaClass; //导入方法依赖的package包/类
private Properties settingsAsProperties(XNode context) {
    if (context == null) {
        return new Properties();
    }
    Properties props = context.getChildrenAsProperties();
    // Check that all settings are known to the configuration class
    MetaClass metaConfig = MetaClass.forClass(Configuration.class, localReflectorFactory);
    for (Object key : props.keySet()) {
        if (!metaConfig.hasSetter(String.valueOf(key))) {
            throw new BuilderException("The setting " + key + " is not known.  Make sure you spelled it correctly (case sensitive).");
        }
    }
    return props;
}
 
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:15,代码来源:MybatisXMLConfigBuilder.java

示例11: settingsElement

import org.apache.ibatis.reflection.MetaClass; //导入方法依赖的package包/类
private void settingsElement(XNode context) throws Exception {
    if (context != null) {
        Properties props = context.getChildrenAsProperties();
        // Check that all settings are known to the configuration class
        MetaClass metaConfig = MetaClass.forClass(Configuration.class, localReflectorFactory);
        for (Object key : props.keySet()) {
            if (!metaConfig.hasSetter(String.valueOf(key))) {
                throw new BuilderException("The setting " + key + " is not known.  Make sure you spelled it correctly (case sensitive).");
            }
        }
        configuration.setAutoMappingBehavior(AutoMappingBehavior.valueOf(props.getProperty("autoMappingBehavior", "PARTIAL")));
        configuration.setCacheEnabled(booleanValueOf(props.getProperty("cacheEnabled"), true));
        configuration.setProxyFactory((ProxyFactory) createInstance(props.getProperty("proxyFactory")));
        configuration.setLazyLoadingEnabled(booleanValueOf(props.getProperty("lazyLoadingEnabled"), false));
        configuration.setAggressiveLazyLoading(booleanValueOf(props.getProperty("aggressiveLazyLoading"), true));
        configuration.setMultipleResultSetsEnabled(booleanValueOf(props.getProperty("multipleResultSetsEnabled"), true));
        configuration.setUseColumnLabel(booleanValueOf(props.getProperty("useColumnLabel"), true));
        configuration.setUseGeneratedKeys(booleanValueOf(props.getProperty("useGeneratedKeys"), false));
        configuration.setDefaultExecutorType(ExecutorType.valueOf(props.getProperty("defaultExecutorType", "SIMPLE")));
        configuration.setDefaultStatementTimeout(integerValueOf(props.getProperty("defaultStatementTimeout"), null));
        configuration.setDefaultFetchSize(integerValueOf(props.getProperty("defaultFetchSize"), null));
        configuration.setMapUnderscoreToCamelCase(booleanValueOf(props.getProperty("mapUnderscoreToCamelCase"), false));
        configuration.setSafeRowBoundsEnabled(booleanValueOf(props.getProperty("safeRowBoundsEnabled"), false));
        configuration.setLocalCacheScope(LocalCacheScope.valueOf(props.getProperty("localCacheScope", "SESSION")));
        configuration.setJdbcTypeForNull(JdbcType.valueOf(props.getProperty("jdbcTypeForNull", "OTHER")));
        configuration.setLazyLoadTriggerMethods(stringSetValueOf(props.getProperty("lazyLoadTriggerMethods"), "equals,clone,hashCode,toString"));
        configuration.setSafeResultHandlerEnabled(booleanValueOf(props.getProperty("safeResultHandlerEnabled"), true));
        configuration.setDefaultScriptingLanguage(resolveClass(props.getProperty("defaultScriptingLanguage")));
        configuration.setCallSettersOnNulls(booleanValueOf(props.getProperty("callSettersOnNulls"), false));
        configuration.setLogPrefix(props.getProperty("logPrefix"));
        configuration.setLogImpl(resolveClass(props.getProperty("logImpl")));
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-core,代码行数:34,代码来源:HierarchicalXMLConfigBuilder.java

示例12: JpaBeanWrapper

import org.apache.ibatis.reflection.MetaClass; //导入方法依赖的package包/类
public JpaBeanWrapper(MetaObject metaObject, Object object) {
    super(metaObject, object) ;
    this.object = object;
    this.metaClass = MetaClass.forClass(object.getClass(), metaObject.getReflectorFactory());

    if(!entityFieldsMap.containsKey(object.getClass().getName())){
        entityFieldsMap.put(object.getClass().getName() ,
                FieldHelper.getAllEntityFieldColumnMap(object.getClass()) ) ;
    }

    entityFieldColumnMap = entityFieldsMap.get( object.getClass().getName() );
}
 
开发者ID:geeker-lait,项目名称:tasfe-framework,代码行数:13,代码来源:JpaBeanWrapper.java

示例13: resolveResultJavaType

import org.apache.ibatis.reflection.MetaClass; //导入方法依赖的package包/类
private Class<?> resolveResultJavaType(Class<?> resultType, String property, Class<?> javaType) {
  if (javaType == null && property != null) {
    try {
      MetaClass metaResultType = MetaClass.forClass(resultType, configuration.getReflectorFactory());
      javaType = metaResultType.getSetterType(property);
    } catch (Exception e) {
      //ignore, following null check statement will deal with the situation
    }
  }
  if (javaType == null) {
    javaType = Object.class;
  }
  return javaType;
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:15,代码来源:MapperBuilderAssistant.java

示例14: settingsAsProperties

import org.apache.ibatis.reflection.MetaClass; //导入方法依赖的package包/类
private Properties settingsAsProperties(XNode context) {
  if (context == null) {
    return new Properties();
  }
  Properties props = context.getChildrenAsProperties();
  // Check that all settings are known to the configuration class
  MetaClass metaConfig = MetaClass.forClass(Configuration.class, localReflectorFactory);
  for (Object key : props.keySet()) {
    if (!metaConfig.hasSetter(String.valueOf(key))) {
      throw new BuilderException("The setting " + key + " is not known.  Make sure you spelled it correctly (case sensitive).");
    }
  }
  return props;
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:15,代码来源:XMLConfigBuilder.java

示例15: settingsAsPropertiess

import org.apache.ibatis.reflection.MetaClass; //导入方法依赖的package包/类
private Properties settingsAsPropertiess(XNode context) {
	if (context == null) {
		return new Properties();
	}
	Properties props = context.getChildrenAsProperties();
	// Check that all settings are known to the configuration class
	MetaClass metaConfig = MetaClass.forClass(Configuration.class, localReflectorFactory);
	for (Object key : props.keySet()) {
		if (!metaConfig.hasSetter(String.valueOf(key))) {
			throw new BuilderException("The setting " + key + " is not known.  Make sure you spelled it correctly (case sensitive).");
		}
	}
	return props;
}
 
开发者ID:whatlookingfor,项目名称:spring-boot-sample,代码行数:15,代码来源:XMLConfigBuilder.java


注:本文中的org.apache.ibatis.reflection.MetaClass.forClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。