Forums Register Login
type of argument lost?
I've created an inner class (recentPatientMatch) with one method (match). An argument is passed to the method (Patient) but inside the method the patient object doesn't seem to have access to it's own methods. As the errors show(see the bottom of the post), it's being treated as java.lang.Object.

I can't figure out why. Why doesn't the compiler see it as a Patient, and not just an Object?

C:\Documents and Settings\beaconuser\My Documents\NetBeansProjects\UbiquityUtilities\src\ubiquityutilities\NoteUpdater.java:93: cannot find symbol
symbol : method getSocDate()
location: class java.lang.Object
return Integer.valueOf(p.getSocDate()) >= 1 &&
C:\Documents and Settings\beaconuser\My Documents\NetBeansProjects\UbiquityUtilities\src\ubiquityutilities\NoteUpdater.java:94: cannot find symbol
symbol : method getDcDate()
location: class java.lang.Object
(p.getDcDate().equals("") ||
C:\Documents and Settings\beaconuser\My Documents\NetBeansProjects\UbiquityUtilities\src\ubiquityutilities\NoteUpdater.java:95: cannot find symbol
symbol : method getDcDate()
location: class java.lang.Object
Integer.valueOf(p.getDcDate()) >= 20100824);
Note: C:\Documents and Settings\beaconuser\My Documents\NetBeansProjects\UbiquityUtilities\src\ubiquityutilities\NoteUpdater.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
3 errors
C:\Documents and Settings\beaconuser\My Documents\NetBeansProjects\UbiquityUtilities\nbproject\build-impl.xml:528: The following error occurred while executing this line:
C:\Documents and Settings\beaconuser\My Documents\NetBeansProjects\UbiquityUtilities\nbproject\build-impl.xml:261: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 5 seconds)
OK, first, it's generally a good idea to reduce the code to the smallest example that still demonstrates the problem. Often someone who might be able to answer your question will be see the wall of code, and decide it's time to finish their TPS reports instead. Fortuanately, I got my reports done early today!

Your inner class should start with a capital letter, like all Java classes. The compiler doesn't care about that, but it makes thing more readable to future generations of Java coders who may have to maintain your code.

And finally, the actual problem is that way you've defined your templates. I assume Predicate is a generic class, which you are parameterizing with <Patient>, but then you also parameterize the inner class that extends it, which doesn't make sense. Now, I'm not saying the compiler error was especially clear on that point, but if you change your class declaration to:

private class RecentPatientMatch extends Predicate<Patient> { ... }

then everything should work for you.

Thank you very much for your reply.

I'll try to reduce the code I post in the future. Thanks for scaling the wall of code anyways.

Ah, good catch on capitalizing the Class. I got into method writing mode. :-)

Yes! That did it! My grasp of generics is still a little fuzzy but I'm gettin' there.

Thanks again for your help and good luck on those TPS reports.

mooooooo ..... tiny ad ....
Thread Boost - a very different sort of advertising

This thread has been viewed 709 times.

All times above are in ranch (not your local) time.
The current ranch time is
Apr 23, 2018 23:05:30.