| Bean-Properties 1.0 发布了.
Bean-Properties 是一个纯Java的工具, 为Java中的运用到属性的地方提供了一个模板. Bean-Properties 不再推荐使用getX() and setX() , 而是通过一个二进制代码生成器来生成符合JavaBean specification 的代码.
Bean-Properties 背后最基本的思想, 就是使用实现了get/set 方法的 public final fields 来实现 Properties.
一个简单的例子如下:
public class NewBean { public final Property<Integer> x = new PropertyImpl<Integer>(); }
你可以这样使用NewBean:
NewBean b = new NewBean(); b.x.set(5); b.x.get();
你也可以扩展出其他的你也可以扩展出其他的:
public class MyProperty<T> extends PropertyImpl<T> { public <T> get() { log.print(getName() + ".get() invoked..."); return super.get(); } }
更多的信息,可以参考官方站点: https://bean-properties.dev.java.net/
|