• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Best way to run static class method from a string?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Best way to run static class method from a string?


  • Subject: Re: Best way to run static class method from a string?
  • From: Henrique Prange <email@hidden>
  • Date: Tue, 09 Dec 2014 14:05:51 -0200

Hi James,

You can use reflection to call that entity’s static method. You just need to discover the corresponding class name for that entity in the first place.

String entityName = "YourEntityName";

EOEntity entity = EOModelGroup.defaultGroup().entityNamed(entityName);

Class<?> clazz = Class.forName(entity.className());

Method method = clazz.getMethod("yourStaticMethodName");

method.invoke(null);

Is that what you want?

Cheers,

Henrique

On 09/12/2014, at 13:37, James Cicenia <email@hidden> wrote:


I have a string that is an EntityName.
I want to run that entity’s static class method.

do I have to do this?:

       EOEnterpriseObject myClass = EOUtilities.createAndInsertInstance( ec, entityName) ;

I really don’t want to create an instance.

Thanks
James

Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Best way to run static class method from a string? (From: James Cicenia <email@hidden>)

  • Prev by Date: Best way to run static class method from a string?
  • Next by Date: Re: Best way to run static class method from a string?
  • Previous by thread: Best way to run static class method from a string?
  • Next by thread: Re: Best way to run static class method from a string?
  • Index(es):
    • Date
    • Thread