@Override
protected Expression instantiate( Object oldInstance, Encoder out ) {
Class type = oldInstance.getClass();
if ( !Modifier.isPublic( type.getModifiers() ) )
throw new IllegalArgumentException( "Could not instantiate instance of non-public class: " + oldInstance );
for ( Field field : type.getFields() ) {
int mod = field.getModifiers();
if ( Modifier.isPublic( mod ) && Modifier.isStatic( mod ) && Modifier.isFinal( mod ) && ( type == field.getDeclaringClass() ) ) {
try {
if ( oldInstance == field.get( null ) )
return new Expression( oldInstance, field, "get", new Object[]{null} );
} catch ( IllegalAccessException exception ) {
throw new IllegalArgumentException( "Could not get value of the field: " + field, exception );
}
}
}
throw new IllegalArgumentException( "Could not instantiate value: " + oldInstance );
}
PainterUtil.java 文件源码
java
阅读 24
收藏 0
点赞 0
评论 0
项目:swingx
作者:
评论列表
文章目录