VariantBeanHelper.java 文件源码

java
阅读 17 收藏 0 点赞 0 评论 0

项目:neoscada 作者:
public static void apply ( final Map<String, Variant> data, final Object target, final WriteAttributeResults results ) throws IntrospectionException
{
    final BeanInfo bi = Introspector.getBeanInfo ( target.getClass () );

    for ( final Map.Entry<String, Variant> entry : data.entrySet () )
    {
        final PropertyDescriptor pd = findDescriptor ( bi, entry.getKey () );
        if ( pd != null )
        {
            try
            {
                applyValue ( target, pd, entry.getValue () );
                results.put ( entry.getKey (), WriteAttributeResult.OK );
            }
            catch ( final Exception e )
            {
                results.put ( entry.getKey (), new WriteAttributeResult ( e ) );
            }
        }
        else
        {
            results.put ( entry.getKey (), new WriteAttributeResult ( new IllegalArgumentException ( String.format ( "'%s' is not a property name of '%s'", entry.getKey (), target.getClass ().getName () ) ) ) );
        }
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号