Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #8221
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | markspace <-@.> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: How do I figure out what class method is annotated with @Id? |
| Date | Thu, 22 Sep 2011 15:30:40 -0700 |
| Organization | A noiseless patient Spider |
| Lines | 20 |
| Message-ID | <j5gcuk$ke4$1@dont-email.me> (permalink) |
| References | <46e27630-0633-49fb-975b-a4e78d787655@v7g2000yqk.googlegroups.com> <s8Oeq.47452$OO1.764@newsfe02.iad> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| Injection-Date | Thu, 22 Sep 2011 22:30:44 +0000 (UTC) |
| Injection-Info | mx04.eternal-september.org; posting-host="XjIWM99mD7Ijfdu600oVPA"; logging-data="20932"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Eh5QDOd05RW3SQBXqy9FjfZsLaQSl2lg=" |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.2) Gecko/20110902 Thunderbird/6.0.2 |
| In-Reply-To | <s8Oeq.47452$OO1.764@newsfe02.iad> |
| Cancel-Lock | sha1:45YO0XMKKja2ImtF6Na8LJnhVIU= |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:8221 |
Show key headers only | View raw
On 9/22/2011 2:54 PM, Daniel Pitts wrote: > On 9/22/11 11:42 AM, laredotornado wrote: >> Given a java.lang.Class, how do I figure out what method is >> annotated with the "@Id" annotation? Thanks, - Dave > > Use Class.getDeclaredMethods and Method.isAnnotationPresent I'd prefer Class.getMethods. getDeclaredMethods won't look at inherited methods, which is not normally what you want. And you can skip isAnnotationPresent and just go for getAnnotations. It returns a 0 length array if no annotations are present. Your loop iterator should catch that by default, no need for additional checks or logic in the driving code.
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar
How do I figure out what class method is annotated with @Id? laredotornado <laredotornado@zipmail.com> - 2011-09-22 11:42 -0700
Re: How do I figure out what class method is annotated with @Id? markspace <-@.> - 2011-09-22 11:49 -0700
Re: How do I figure out what class method is annotated with @Id? Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2011-09-22 14:54 -0700
Re: How do I figure out what class method is annotated with @Id? markspace <-@.> - 2011-09-22 15:30 -0700
Re: How do I figure out what class method is annotated with @Id? Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2011-09-22 16:11 -0700
csiph-web