Example usage for org.apache.ibatis.reflection MetaObject getSetterType

List of usage examples for org.apache.ibatis.reflection MetaObject getSetterType

Introduction

In this page you can find the example usage for org.apache.ibatis.reflection MetaObject getSetterType.

Prototype

public Class<?> getSetterType(String name) 

Source Link

Usage

From source file:com.dk3k.framework.redis.cache.mybatis.RedisConfigurationBuilder.java

License:Apache License

private void setConfigProperties(Properties properties, ConfigWithHost jedisConfig) {
    if (properties != null) {
        MetaObject metaCache = SystemMetaObject.forObject(jedisConfig);
        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: '" + name + "' of type " + type);
                }//  w  w w .  j  a v  a 2 s  .c o m
            }
        }
    }
}

From source file:com.hand.hap.mybatis.mapperhelper.MultipleJdbc3KeyGenerator.java

License:Open Source License

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;//from   w  w  w  .j  a v a 2  s. c o m
        }
    }
    return typeHandlers;
}

From source file:com.ibatis.common.jdbc.DbcpConfiguration.java

License:Apache License

private Object convertValue(Object object, String propertyName, String value) {
    Object convertedValue = value;
    MetaObject metaObject = SystemMetaObject.forObject(object);
    Class targetType = metaObject.getSetterType(propertyName);
    if (targetType == Integer.class || targetType == int.class) {
        convertedValue = Integer.valueOf(value);
    } else if (targetType == Long.class || targetType == long.class) {
        convertedValue = Long.valueOf(value);
    } else if (targetType == Boolean.class || targetType == boolean.class) {
        convertedValue = Boolean.valueOf(value);
    }/*from   w  ww . j ava 2s. c  om*/
    return convertedValue;
}

From source file:com.zh.common.redis.RedisConfigurationBuilder.java

License:Apache License

private void setConfigProperties(Properties properties, RedisConfig jedisConfig) {
    if (properties != null) {
        MetaObject metaCache = SystemMetaObject.forObject(jedisConfig);
        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: '" + name + "' of type " + type);
                }//from   www.  java  2s .  c  o m
            }
        }
    }
}

From source file:org.mybatis.caches.redis.RedisConfigurationBuilder.java

License:Apache License

private void setConfigProperties(Properties properties, RedisConfig jedisConfig) {
    if (properties != null) {
        MetaObject metaCache = SystemMetaObject.forObject(jedisConfig);
        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: '" + name + "' of type " + type);
                }/*  w  w w .  j a va2 s.co m*/
            } else if (isInteger(value)) {
                jedisConfig.getSettings().put(name, Integer.parseInt(value));
            }
        }
    }
}

From source file:org.nanoframework.orm.mybatis.plugin.AbstractDataSourceFactory.java

License:Apache License

private Object convertValue(MetaObject metaDataSource, String propertyName, String value) {
    Object convertedValue = value;
    Class<?> targetType = metaDataSource.getSetterType(propertyName);
    if (targetType == Integer.class || targetType == int.class) {
        convertedValue = Integer.valueOf(value);
    } else if (targetType == Long.class || targetType == long.class) {
        convertedValue = Long.valueOf(value);
    } else if (targetType == Boolean.class || targetType == boolean.class) {
        convertedValue = Boolean.valueOf(value);
    }//from   ww  w .ja v a  2s  . c o  m
    return convertedValue;
}