Class EntityProxy.BeanInstance<BEAN,​RES>

  • Enclosing class:
    EntityProxy<RES>

    public static class EntityProxy.BeanInstance<BEAN,​RES>
    extends Object
    • Constructor Detail

      • BeanInstance

        public BeanInstance​(@NotNull
                            RES instance,
                            @NotNull
                            EntityProxy<BEAN> proxy)
    • Method Detail

      • setProperty

        @NotNull
        public EntityProxy.BeanInstance<BEAN,​RES> setProperty​(@NotNull
                                                                    String db_field_name,
                                                                    @Nullable
                                                                    Object value)
        设置一个属性,该方法不会自动转换value的类型。
        如代理对象的`id`是`Long`或者`Int`类型,现在有一个`BigDecimal`类型的值,如何将这个`BigDecimal`设置到`id`上呢?
        参考如下代码:
             BeanInstance<Object> instance = BeanProxy.fromBean(bean);
             String field_name = "id";
        
             Object typedValue = new ObjectMapper().convertValue(bigDecimalId, instance.getPropertyType(field_name));
             instance.setProperty(field_name, typedValue);
         
        ```java ```
      • getProperty

        @Nullable
        public Object getProperty​(@NotNull
                                  String db_field_name)
        get
      • getPropertyType

        @Nullable
        public Class<?> getPropertyType​(@NotNull
                                        String db_field_name)
        获取某属性的类型
      • toBean

        @Nullable
        public RES toBean()
        获取bean
      • getBeanType

        public Class<BEAN> getBeanType()
        获取bean的类型