سؤال

I have a Class that i wanted to generate his AutoBean.

Example.class :

   public static class Example implements Serializable {
       public Example2 example2 = new Example2();
       public static BigDecimal calc(BigDecimal dec){
          return dec != null ? dec: BigDecimal.ZERO;
       }
       public static class Example2 implements Serializable {
         public BigDecimal value1 = BigDecimal.ZERO;
         public BigDecimal value2 = BigDecimal.ZERO;
         public BigDecimal getSum(){
            return calc(value1).add(calc(value2));
         }
       }
   }

AutoBean Example:

public inteface Example {

  @PropertyName("example2")
  public Example2 getExample2();

  BigDecimal calc(BigDecimal dec);
}

I try to do this

AutoBean Example2 :

public interface Example2 {
   @PropertyName("value1")
   public BigDecimal getValue1();

   @PropertyName("value2")
   public BigDecimal getValue2();

   BigDecimal getSum();
}

There is also Example2Category where the function is implement.

but when i try to get the value1 or value2 i have an Error :

TypeError: Cannot read property of null

i think this happend because there is no initialized values like into their Class representation. I try this solution but dont seems to work.

So How can I represent the AutoBean from my Example2 Class with init values?

هل كانت مفيدة؟

المحلول

It seems like it is a BigDecimal issues. For me i change the Server Value to Double and it work now.

see this Post.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top