private void processValueProperty( final ClassWriter cw,
final ValueProperty property )
{
final String propertyFieldName = findPropertyField( property ).getName();
final Reference referenceAnnotation = property.getAnnotation( Reference.class );
final boolean reference = ( referenceAnnotation != null );
Method getter = findMethod( "get" + property.name() );
if( getter == null )
{
getter = findMethod( "is" + property.name() );
}
if( getter != null )
{
this.implementedMethods.add( getter );
final MethodVisitor mv = cw.visitMethod
(
ACC_PUBLIC,
getter.getName(),
Type.getMethodDescriptor( Type.getType( reference ? ReferenceValue.class : Value.class ), new Type[ 0 ] ),
null,
null
);
mv.visitCode();
mv.visitVarInsn( ALOAD, 0 );
mv.visitFieldInsn
(
GETSTATIC,
this.typeInterfaceClassInternalName,
propertyFieldName,
Type.getDescriptor( ValueProperty.class )
);
mv.visitMethodInsn
(
INVOKEVIRTUAL,
this.typeImplClassInternalName,
"property",
Type.getMethodDescriptor( Type.getType( Value.class ), new Type[] { Type.getType( ValueProperty.class ) } )
);
if( reference )
{
mv.visitTypeInsn( CHECKCAST, Type.getInternalName( ReferenceValue.class ) );
}
mv.visitInsn( ARETURN );
mv.visitMaxs( 0, 0 );
mv.visitEnd();
}
implementSetterMethod( cw, property, String.class );
final Class<?> propertyTypeClass = property.getTypeClass();
if( propertyTypeClass != String.class )
{
implementSetterMethod( cw, property, propertyTypeClass );
}
if( reference )
{
implementSetterMethod( cw, property, referenceAnnotation.target() );
}
}