• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

type of argument lost?  RSS feed

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
Sheriff
Posts: 3015
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Scott Hibbard
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greg,

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.

-Scott
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!