You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mick Knutson <mi...@safeway.com> on 2005/10/28 00:47:29 UTC
[ot] utility to verify if an Object implements all methods from
Interface?
I have some generated Objects that I CAN"T make implement my given
interface, but I would like to run a test at startup time, if the Object
has all the methods it is suppose to have?
"MMS <safeway.com>" made the following annotations.
------------------------------------------------------------------------------
Warning:
All e-mail sent to this address will be received by the Safeway corporate e-mail system, and is subject to archival and review by someone other than the recipient. This e-mail may contain information proprietary to Safeway and is intended only for the use of the intended recipient(s). If the reader of this message is not the intended recipient(s), you are notified that you have received this message in error and that any review, dissemination, distribution or copying of this message is strictly prohibited. If you have received this message in error, please notify the sender immediately.
==============================================================================
Re: [ot] utility to verify if an Object implements all methods from
Interface?
Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
Interesting... why can't you implement the interface? Just curious.
Does it implement any other interfaces to build up the method list? If
so, you could just do a serious of instanceof's against all the
interfaces it implements. Alternatively, you can use reflection to get
a list of the methods it contains and do your checks against that.
Frank
Mick Knutson wrote:
> I have some generated Objects that I CAN"T make implement my given
> interface, but I would like to run a test at startup time, if the Object
> has all the methods it is suppose to have?
>
>
> "MMS <safeway.com>" made the following annotations.
> ------------------------------------------------------------------------------
> Warning:
> All e-mail sent to this address will be received by the Safeway corporate e-mail system, and is subject to archival and review by someone other than the recipient. This e-mail may contain information proprietary to Safeway and is intended only for the use of the intended recipient(s). If the reader of this message is not the intended recipient(s), you are notified that you have received this message in error and that any review, dissemination, distribution or copying of this message is strictly prohibited. If you have received this message in error, please notify the sender immediately.
>
> ==============================================================================
>
--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM: fzammetti
Yahoo: fzammetti
MSN: fzammetti@hotmail.com
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [ot] utility to verify if an Object implements all methods
from Interface?
Posted by David Evans <ds...@berndtgroup.net>.
I think you could use the java.lang.reflect package classes:
Object obj = new Object();
Method[] methods = obj.getClass.getMethods();
Create another test object that does implement all of the interfaces,
and then compare the methods array to the array created by the test
object's .getClass.getMethods()
dave
On Thu, 2005-10-27 at 15:47, Mick Knutson wrote:
> I have some generated Objects that I CAN"T make implement my given
> interface, but I would like to run a test at startup time, if the Object
> has all the methods it is suppose to have?
>
>
> "MMS <safeway.com>" made the following annotations.
> ------------------------------------------------------------------------------
> Warning:
> All e-mail sent to this address will be received by the Safeway corporate e-mail system, and is subject to archival and review by someone other than the recipient. This e-mail may contain information proprietary to Safeway and is intended only for the use of the intended recipient(s). If the reader of this message is not the intended recipient(s), you are notified that you have received this message in error and that any review, dissemination, distribution or copying of this message is strictly prohibited. If you have received this message in error, please notify the sender immediately.
>
> ==============================================================================
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [ot] utility to verify if an Object implements all methods from Interface?
Posted by Richard Yee <ry...@yahoo.com>.
Mick,
You could write a wrapper object that wraps (extends)
the generated object and implements the interface. If
the extended object does not have all of the methods
defined in the interface, you will get a compile
error.
-Richard
--- Mick Knutson <mi...@safeway.com> wrote:
> I have some generated Objects that I CAN"T make
> implement my given
> interface, but I would like to run a test at startup
> time, if the Object
> has all the methods it is suppose to have?
>
>
> "MMS <safeway.com>" made the following annotations.
>
------------------------------------------------------------------------------
> Warning:
> All e-mail sent to this address will be received by
> the Safeway corporate e-mail system, and is subject
> to archival and review by someone other than the
> recipient. This e-mail may contain information
> proprietary to Safeway and is intended only for the
> use of the intended recipient(s). If the reader of
> this message is not the intended recipient(s), you
> are notified that you have received this message in
> error and that any review, dissemination,
> distribution or copying of this message is strictly
> prohibited. If you have received this message in
> error, please notify the sender immediately.
>
>
==============================================================================
>
__________________________________
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org