當前位置: 首頁>>代碼示例>>Java>>正文


Java MetaObject.hasSetter方法代碼示例

本文整理匯總了Java中org.apache.ibatis.reflection.MetaObject.hasSetter方法的典型用法代碼示例。如果您正苦於以下問題:Java MetaObject.hasSetter方法的具體用法?Java MetaObject.hasSetter怎麽用?Java MetaObject.hasSetter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.ibatis.reflection.MetaObject的用法示例。


在下文中一共展示了MetaObject.hasSetter方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: hasSetter

import org.apache.ibatis.reflection.MetaObject; //導入方法依賴的package包/類
@Override
public boolean hasSetter(String name) {
  PropertyTokenizer prop = new PropertyTokenizer(name);
  if (prop.hasNext()) {
    if (metaClass.hasSetter(prop.getIndexedName())) {
      MetaObject metaValue = metaObject.metaObjectForProperty(prop.getIndexedName());
      if (metaValue == SystemMetaObject.NULL_META_OBJECT) {
        return metaClass.hasSetter(name);
      } else {
        return metaValue.hasSetter(prop.getChildren());
      }
    } else {
      return false;
    }
  } else {
    return metaClass.hasSetter(name);
  }
}
 
開發者ID:yuexiahandao,項目名稱:MybatisCode,代碼行數:19,代碼來源:BeanWrapper.java

示例2: hasSetter

import org.apache.ibatis.reflection.MetaObject; //導入方法依賴的package包/類
public boolean hasSetter(String name) {
	PropertyTokenizer prop = new PropertyTokenizer(name);
	if (prop.hasNext()) {
		if (metaClass.hasSetter(prop.getIndexedName())) {
			MetaObject metaValue = metaObject.metaObjectForProperty(prop
					.getIndexedName());
			if (metaValue == SystemMetaObject.NULL_META_OBJECT) {
				return metaClass.hasSetter(name);
			} else {
				return metaValue.hasSetter(prop.getChildren());
			}
		} else {
			return false;
		}
	} else {
		return metaClass.hasSetter(name);
	}
}
 
開發者ID:yinshipeng,項目名稱:sosoapi-base,代碼行數:19,代碼來源:BeanWrapper.java

示例3: getTypeHandlers

import org.apache.ibatis.reflection.MetaObject; //導入方法依賴的package包/類
private TypeHandler<?>[] getTypeHandlers(TypeHandlerRegistry typeHandlerRegistry, MetaObject metaParam, String[] keyProperties) {
    TypeHandler<?>[] typeHandlers = new TypeHandler<?>[keyProperties.length];
    for (int i = 0; i < keyProperties.length; i++) {
        if (metaParam.hasSetter(keyProperties[i])) {
            Class<?> keyPropertyType = metaParam.getSetterType(keyProperties[i]);
            TypeHandler<?> th = typeHandlerRegistry.getTypeHandler(keyPropertyType);
            typeHandlers[i] = th;
        }
    }
    return typeHandlers;
}
 
開發者ID:Yanweichen,項目名稱:MybatisGeneatorUtil,代碼行數:12,代碼來源:MultipleJdbc3KeyGenerator.java

示例4: setValue

import org.apache.ibatis.reflection.MetaObject; //導入方法依賴的package包/類
private void setValue(MetaObject metaParam, String property, Object value) {
    if (metaParam.hasSetter(property)) {
        if(metaParam.hasGetter(property)){
            Object defaultValue = metaParam.getValue(property);
            if(defaultValue != null){
                return;
            }
        }
        metaParam.setValue(property, value);
    } else {
        throw new ExecutorException("No setter found for the keyProperty '" + property + "' in " + metaParam.getOriginalObject().getClass().getName() + ".");
    }
}
 
開發者ID:godlike110,項目名稱:tk-mybatis,代碼行數:14,代碼來源:SelectKeyGenerator.java

示例5: setCacheProperties

import org.apache.ibatis.reflection.MetaObject; //導入方法依賴的package包/類
private void setCacheProperties(Cache cache) {
  if (properties != null) {
    MetaObject metaCache = SystemMetaObject.forObject(cache);
    for (Map.Entry<Object, Object> entry : properties.entrySet()) {
      String name = (String) entry.getKey();
      String value = (String) entry.getValue();
      if (metaCache.hasSetter(name)) {
        Class<?> type = metaCache.getSetterType(name);
        if (String.class == type) {
          metaCache.setValue(name, value);
        } else if (int.class == type
            || Integer.class == type) {
          metaCache.setValue(name, Integer.valueOf(value));
        } else if (long.class == type
            || Long.class == type) {
          metaCache.setValue(name, Long.valueOf(value));
        } else if (short.class == type
            || Short.class == type) {
          metaCache.setValue(name, Short.valueOf(value));
        } else if (byte.class == type
            || Byte.class == type) {
          metaCache.setValue(name, Byte.valueOf(value));
        } else if (float.class == type
            || Float.class == type) {
          metaCache.setValue(name, Float.valueOf(value));
        } else if (boolean.class == type
            || Boolean.class == type) {
          metaCache.setValue(name, Boolean.valueOf(value));
        } else if (double.class == type
            || Double.class == type) {
          metaCache.setValue(name, Double.valueOf(value));
        } else {
          throw new CacheException("Unsupported property type for cache: '" + name + "' of type " + type);
        }
      }
    }
  }
}
 
開發者ID:yuexiahandao,項目名稱:MybatisCode,代碼行數:39,代碼來源:CacheBuilder.java

示例6: createAutomaticMappings

import org.apache.ibatis.reflection.MetaObject; //導入方法依賴的package包/類
private List<UnMappedColumnAutoMapping> createAutomaticMappings(ResultSetWrapper rsw, ResultMap resultMap, MetaObject metaObject, String columnPrefix) throws SQLException {
  final String mapKey = resultMap.getId() + ":" + columnPrefix;
  List<UnMappedColumnAutoMapping> autoMapping = autoMappingsCache.get(mapKey);
  if (autoMapping == null) {
    autoMapping = new ArrayList<UnMappedColumnAutoMapping>();
    final List<String> unmappedColumnNames = rsw.getUnmappedColumnNames(resultMap, columnPrefix);
    for (String columnName : unmappedColumnNames) {
      String propertyName = columnName;
      if (columnPrefix != null && !columnPrefix.isEmpty()) {
        // When columnPrefix is specified,
        // ignore columns without the prefix.
        if (columnName.toUpperCase(Locale.ENGLISH).startsWith(columnPrefix)) {
          propertyName = columnName.substring(columnPrefix.length());
        } else {
          continue;
        }
      }
      final String property = metaObject.findProperty(propertyName, configuration.isMapUnderscoreToCamelCase());
      if (property != null && metaObject.hasSetter(property)) {
        final Class<?> propertyType = metaObject.getSetterType(property);
        if (typeHandlerRegistry.hasTypeHandler(propertyType, rsw.getJdbcType(columnName))) {
          final TypeHandler<?> typeHandler = rsw.getTypeHandler(propertyType, columnName);
          autoMapping.add(new UnMappedColumnAutoMapping(columnName, property, typeHandler, propertyType.isPrimitive()));
        } else {
          configuration.getAutoMappingUnknownColumnBehavior()
                  .doAction(mappedStatement, columnName, property, propertyType);
        }
      } else{
        configuration.getAutoMappingUnknownColumnBehavior()
                .doAction(mappedStatement, columnName, (property != null) ? property : propertyName, null);
      }
    }
    autoMappingsCache.put(mapKey, autoMapping);
  }
  return autoMapping;
}
 
開發者ID:yuexiahandao,項目名稱:MybatisCode,代碼行數:37,代碼來源:DefaultResultSetHandler.java

示例7: getTypeHandlers

import org.apache.ibatis.reflection.MetaObject; //導入方法依賴的package包/類
private TypeHandler<?>[] getTypeHandlers(TypeHandlerRegistry typeHandlerRegistry, MetaObject metaParam, String[] keyProperties, ResultSetMetaData rsmd) throws SQLException {
  TypeHandler<?>[] typeHandlers = new TypeHandler<?>[keyProperties.length];
  for (int i = 0; i < keyProperties.length; i++) {
    if (metaParam.hasSetter(keyProperties[i])) {
      Class<?> keyPropertyType = metaParam.getSetterType(keyProperties[i]);
      TypeHandler<?> th = typeHandlerRegistry.getTypeHandler(keyPropertyType, JdbcType.forCode(rsmd.getColumnType(i + 1)));
      typeHandlers[i] = th;
    }
  }
  return typeHandlers;
}
 
開發者ID:yuexiahandao,項目名稱:MybatisCode,代碼行數:12,代碼來源:Jdbc3KeyGenerator.java

示例8: setValue

import org.apache.ibatis.reflection.MetaObject; //導入方法依賴的package包/類
private void setValue(MetaObject metaParam, String property, Object value) {
  if (metaParam.hasSetter(property)) {
    metaParam.setValue(property, value);
  } else {
    throw new ExecutorException("No setter found for the keyProperty '" + property + "' in " + metaParam.getOriginalObject().getClass().getName() + ".");
  }
}
 
開發者ID:yuexiahandao,項目名稱:MybatisCode,代碼行數:8,代碼來源:SelectKeyGenerator.java

示例9: setFieldValByName

import org.apache.ibatis.reflection.MetaObject; //導入方法依賴的package包/類
/**
 * <p>
 * Common method to set value for java bean.
 * </p>
 * <p>
 * 如果包含前綴 et 使用該方法,否則可以直接 metaObject.setValue(fieldName, fieldVal);
 * </p>
 *
 * @param fieldName  java bean property name
 * @param fieldVal   java bean property value
 * @param metaObject meta object parameter
 */
public MetaObjectHandler setFieldValByName(String fieldName, Object fieldVal, MetaObject metaObject) {
    if (metaObject.hasSetter(fieldName) && metaObject.hasGetter(fieldName)) {
        metaObject.setValue(fieldName, fieldVal);
    } else if (metaObject.hasGetter(META_OBJ_PREFIX)) {
        Object et = metaObject.getValue(META_OBJ_PREFIX);
        if (et != null) {
            MetaObject etMeta = SystemMetaObject.forObject(et);
            if (etMeta.hasSetter(fieldName)) {
                etMeta.setValue(fieldName, fieldVal);
            }
        }
    }
    return this;
}
 
開發者ID:baomidou,項目名稱:mybatis-plus,代碼行數:27,代碼來源:MetaObjectHandler.java


注:本文中的org.apache.ibatis.reflection.MetaObject.hasSetter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。