Java 类org.springframework.core.convert.Property 实例源码

项目:onetwo    文件:SpringUtils.java   
public static Map<String, Object> toFlatMap(Object obj, Function<Object, Boolean> isNestedObject) {
    Map<String, Object> map = Maps.newHashMap();
    BEAN_TO_MAP_CONVERTOR.flatObject("", obj, (k, v, ctx)->{
        Object value = v;
        TypeDescriptor sourceType = null;
        if(v.getClass()!=String.class){
            Field field = ctx.getField();
            if(field!=null && (field.getAnnotation(DateTimeFormat.class)!=null || field.getAnnotation(NumberFormat.class)!=null) ){
                sourceType = new TypeDescriptor(field);
            }
            if(sourceType==null){
                sourceType = new TypeDescriptor(new Property(ctx.getSource().getClass(), ctx.getProperty().getReadMethod(), ctx.getProperty().getWriteMethod()));
            }
            value = getFormattingConversionService().convert(v, sourceType, TypeDescriptor.valueOf(String.class));
           }
        map.put(k, value);
    });
    return map;
}
项目:lams    文件:ReflectivePropertyAccessor.java   
@Override
public boolean canWrite(EvaluationContext context, Object target, String name) throws AccessException {
    if (target == null) {
        return false;
    }
    Class<?> type = (target instanceof Class ? (Class<?>) target : target.getClass());
    CacheKey cacheKey = new CacheKey(type, name, target instanceof Class);
    if (this.writerCache.containsKey(cacheKey)) {
        return true;
    }
    Method method = findSetterForProperty(name, type, target);
    if (method != null) {
        // Treat it like a property
        Property property = new Property(type, null, method);
        TypeDescriptor typeDescriptor = new TypeDescriptor(property);
        this.writerCache.put(cacheKey, method);
        this.typeDescriptorCache.put(cacheKey, typeDescriptor);
        return true;
    }
    else {
        Field field = findField(name, type, target);
        if (field != null) {
            this.writerCache.put(cacheKey, field);
            this.typeDescriptorCache.put(cacheKey, new TypeDescriptor(field));
            return true;
        }
    }
    return false;
}
项目:spring4-understanding    文件:ReflectivePropertyAccessor.java   
@Override
public boolean canWrite(EvaluationContext context, Object target, String name) throws AccessException {
    if (target == null) {
        return false;
    }
    Class<?> type = (target instanceof Class ? (Class<?>) target : target.getClass());
    CacheKey cacheKey = new CacheKey(type, name, target instanceof Class);
    if (this.writerCache.containsKey(cacheKey)) {
        return true;
    }
    Method method = findSetterForProperty(name, type, target);
    if (method != null) {
        // Treat it like a property
        Property property = new Property(type, null, method);
        TypeDescriptor typeDescriptor = new TypeDescriptor(property);
        this.writerCache.put(cacheKey, method);
        this.typeDescriptorCache.put(cacheKey, typeDescriptor);
        return true;
    }
    else {
        Field field = findField(name, type, target);
        if (field != null) {
            this.writerCache.put(cacheKey, field);
            this.typeDescriptorCache.put(cacheKey, new TypeDescriptor(field));
            return true;
        }
    }
    return false;
}
项目:spring    文件:ReflectivePropertyAccessor.java   
@Override
public boolean canWrite(EvaluationContext context, Object target, String name) throws AccessException {
    if (target == null) {
        return false;
    }
    Class<?> type = (target instanceof Class ? (Class<?>) target : target.getClass());
    PropertyCacheKey cacheKey = new PropertyCacheKey(type, name, target instanceof Class);
    if (this.writerCache.containsKey(cacheKey)) {
        return true;
    }
    Method method = findSetterForProperty(name, type, target);
    if (method != null) {
        // Treat it like a property
        Property property = new Property(type, null, method);
        TypeDescriptor typeDescriptor = new TypeDescriptor(property);
        this.writerCache.put(cacheKey, method);
        this.typeDescriptorCache.put(cacheKey, typeDescriptor);
        return true;
    }
    else {
        Field field = findField(name, type, target);
        if (field != null) {
            this.writerCache.put(cacheKey, field);
            this.typeDescriptorCache.put(cacheKey, new TypeDescriptor(field));
            return true;
        }
    }
    return false;
}
项目:class-guard    文件:ReflectivePropertyAccessor.java   
public boolean canWrite(EvaluationContext context, Object target, String name) throws AccessException {
    if (target == null) {
        return false;
    }
    Class<?> type = (target instanceof Class ? (Class<?>) target : target.getClass());
    CacheKey cacheKey = new CacheKey(type, name, target instanceof Class);
    if (this.writerCache.containsKey(cacheKey)) {
        return true;
    }
    Method method = findSetterForProperty(name, type, target);
    if (method != null) {
        // Treat it like a property
        Property property = new Property(type, null, method);
        TypeDescriptor typeDescriptor = new TypeDescriptor(property);
        this.writerCache.put(cacheKey, method);
        this.typeDescriptorCache.put(cacheKey, typeDescriptor);
        return true;
    }
    else {
        Field field = findField(name, type, target);
        if (field != null) {
            this.writerCache.put(cacheKey, field);
            this.typeDescriptorCache.put(cacheKey, new TypeDescriptor(field));
            return true;
        }
    }
    return false;
}
项目:lams    文件:BeanWrapperImpl.java   
private Property property(PropertyDescriptor pd) {
    GenericTypeAwarePropertyDescriptor typeAware = (GenericTypeAwarePropertyDescriptor) pd;
    return new Property(typeAware.getBeanClass(), typeAware.getReadMethod(), typeAware.getWriteMethod(), typeAware.getName());
}
项目:spring4-understanding    文件:BeanWrapperImpl.java   
private Property property(PropertyDescriptor pd) {
    GenericTypeAwarePropertyDescriptor gpd = (GenericTypeAwarePropertyDescriptor) pd;
    return new Property(gpd.getBeanClass(), gpd.getReadMethod(), gpd.getWriteMethod(), gpd.getName());
}
项目:spring    文件:BeanWrapperImpl.java   
private Property property(PropertyDescriptor pd) {
    GenericTypeAwarePropertyDescriptor gpd = (GenericTypeAwarePropertyDescriptor) pd;
    return new Property(gpd.getBeanClass(), gpd.getReadMethod(), gpd.getWriteMethod(), gpd.getName());
}
项目:onetwo    文件:SpringUtils.java   
public static TypeDescriptor typeDescriptorForPerperty(Class<?> clazz, String propertyName){
    PropertyDescriptor pd = ReflectUtils.getPropertyDescriptor(clazz, propertyName);
    TypeDescriptor td = new TypeDescriptor(new Property(clazz, pd.getReadMethod(), pd.getWriteMethod()));
    return td;
}
项目:class-guard    文件:BeanWrapperImpl.java   
private Property property(PropertyDescriptor pd) {
    GenericTypeAwarePropertyDescriptor typeAware = (GenericTypeAwarePropertyDescriptor) pd;
    return new Property(typeAware.getBeanClass(), typeAware.getReadMethod(), typeAware.getWriteMethod(), typeAware.getName());
}
项目:jdal    文件:AbstractBinder.java   
/**
 * @return Property for property binder
 */
protected Property getProperty() {
    PropertyDescriptor pd = getPropertyDescriptor();
    return new Property(getModel().getClass(), pd.getReadMethod(), pd.getWriteMethod());
}