Commons Attributes
Commons Attributes enables Java programmers to use C#/.Net-style attributes in their code.
示例代码:
/**
* Make this attribute inheritable...
*
* @@Inheritable()
*/
public class MyAttribute {
private final float value;
public MyAttribute( float value ) {
this.value = value;
}
public float getValue() {
return value;
}
}
/**
* Add a MyAttribute with value 0.8.
*
* @@MyAttribute( 0.8 )
*/
public class MyClass {
public static void main( String[] args ) {
System.out.println( "MyClass has the following attributes:" +
Attributes.getAttributes( MyClass.class ) );
}
}
评论