String localName = javaFieldNames[i]+"$";
LocalVariable localVariable = new LocalVariable(localName, JavaTypeNames.RTVALUE);
LocalVariableDeclaration localDeclaration = new LocalVariableDeclaration(localVariable);
javaMethod.addStatement(localDeclaration);
Assignment localAssignment = new Assignment(localVariable, field);
InstanceOf checkType = new InstanceOf(localAssignment, JavaTypeNames.RTRESULT_FUNCTION);
MethodInvocation getValue = new MethodInvocation.Instance(localVariable, "getValue", JavaTypeNames.RTVALUE, MethodInvocation.InvocationType.VIRTUAL);
Assignment fieldAssignment = new Assignment(field, getValue);
ReturnStatement returnNewVal = new ReturnStatement(fieldAssignment);
IfThenElseStatement ifThen = new IfThenElseStatement(checkType, returnNewVal);
javaMethod.addStatement(ifThen);