Java: dynamic properties

前端 未结 5 1079
庸人自扰
庸人自扰 2020-12-16 00:39

Ladies & Gentlemen,

I´m new to Java, forgive me if it´s obvious, but I haven´t found much about it.

I´d like to create dynamic properties (variables) for

5条回答
  •  离开以前
    2020-12-16 01:28

    I don't know if this is an option on GAE (I didn't checked the restrictions) and if this will suit your needs but maybe have a look at the BeanGenerator class from CGLIB (an alternative to the ugly DynaBean from BeanUtils). Quoting "Death to DynaBeans" (have a look at the post):

    Not one to let my CGLIB Golden Hammer go to waste, I have checked in a BeanGenerator class into CVS. You use it like so:

    BeanGenerator bg = new BeanGenerator();
    bg.addProperty("foo", Double.TYPE);
    bg.addProperty("bar", String.class);
    Object bean = bg.create();
    

    The generated class is an real JavaBean, which means you can use standard bean utilities. This includes all of the classes in the net.sf.cglib.beans package (BeanCopier, BeanMap, and BulkBean). Do your part to end the tyranny of DynaBeans!

提交回复
热议问题