Problem with inner class?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with inner class?

Thomas Hofmann
Hi,

It seems like I cannot figure out what's wrong.

I am trying to call a factory method (implemented in Java) from Groovy:

IComponentSearchCriteria searchCritera = ComponentSearchCriteriaFactory.FACTORY.newInstance()

This is what I get:

groovy.lang.MissingPropertyException: No such property: FACTORY for class: com.ibm.team.scm.common.dto.IComponentSearchCriteria$ComponentSearchCriteriaFactory
        at groovy.lang.MetaClassImpl.invokeStaticMissingProperty(MetaClassImpl.java:876)
        at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:1610)
        at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:1586)
        at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:3303)
        at org.codehaus.groovy.runtime.callsite.ClassMetaClassGetPropertySite.getProperty(ClassMetaClassGetPropertySite.java:48)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:237)



The code in the factory looks like this:

public interface IComponentSearchCriteria extends ISearchCriteria {


    /**
     * Clients should call IComponentSearchCriteria.FACTORY.newInstance() to create
     * new IComponentSearchCriteria instances.
     */
    public static final ComponentSearchCriteriaFactory FACTORY = new ComponentSearchCriteriaFactory();

    public static class ComponentSearchCriteriaFactory {
        private ComponentSearchCriteriaFactory() {
        }

        /**
         * Factory method to create a new instance of IChangeSetSearchCriteria
         */
        public IComponentSearchCriteria newInstance() {
            return ScmDtoFactory.eINSTANCE.createComponentSearchCriteria();
        }
    }


The FACTORY constant is underlined in the editor.

Any help is appreciated, thanks

Thomas

BTW: Whem I call ScmDtoFactory.eINSTANCE.createComponentSearchCriteria() directly it works.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Problem with inner class?

Andrew Eisenberg
I can't immediately figure out what is happening here, but since you
are saying that FACTORY is underlined, this may point to a mismatch on
the runtime vs the build classpath.

If you can send me a small failing project, I will have a look.
Alternatively, you can try compiling and running from the command
line.  This will at least help determine if the problem is
groovy-eclipse related or groovy related.

On Mon, May 31, 2010 at 5:54 AM, Thomas Hofmann <[hidden email]> wrote:

> Hi,
>
> It seems like I cannot figure out what's wrong.
>
> I am trying to call a factory method (implemented in Java) from Groovy:
>
> IComponentSearchCriteria searchCritera = ComponentSearchCriteriaFactory.FACTORY.newInstance()
>
> This is what I get:
>
> groovy.lang.MissingPropertyException: No such property: FACTORY for class: com.ibm.team.scm.common.dto.IComponentSearchCriteria$ComponentSearchCriteriaFactory
>        at groovy.lang.MetaClassImpl.invokeStaticMissingProperty(MetaClassImpl.java:876)
>        at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:1610)
>        at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:1586)
>        at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:3303)
>        at org.codehaus.groovy.runtime.callsite.ClassMetaClassGetPropertySite.getProperty(ClassMetaClassGetPropertySite.java:48)
>        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:237)
>
>
>
> The code in the factory looks like this:
>
> public interface IComponentSearchCriteria extends ISearchCriteria {
>
>
>    /**
>     * Clients should call IComponentSearchCriteria.FACTORY.newInstance() to create
>     * new IComponentSearchCriteria instances.
>     */
>    public static final ComponentSearchCriteriaFactory FACTORY = new ComponentSearchCriteriaFactory();
>
>    public static class ComponentSearchCriteriaFactory {
>        private ComponentSearchCriteriaFactory() {
>        }
>
>        /**
>         * Factory method to create a new instance of IChangeSetSearchCriteria
>         */
>        public IComponentSearchCriteria newInstance() {
>            return ScmDtoFactory.eINSTANCE.createComponentSearchCriteria();
>        }
>    }
>
>
> The FACTORY constant is underlined in the editor.
>
> Any help is appreciated, thanks
>
> Thomas
>
> BTW: Whem I call ScmDtoFactory.eINSTANCE.createComponentSearchCriteria() directly it works.
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Problem with inner class?

Peter Niederwieser
Administrator
In reply to this post by Thomas Hofmann
Thomas Hofmann wrote
I am trying to call a factory method (implemented in Java) from Groovy:

IComponentSearchCriteria searchCritera = ComponentSearchCriteriaFactory.FACTORY.newInstance()

The code in the factory looks like this:

public interface IComponentSearchCriteria extends ISearchCriteria {
    public static final ComponentSearchCriteriaFactory FACTORY = new ComponentSearchCriteriaFactory();
}
My first impression is that Groovy is right. You call CSCF.FACTORY, but the field is defined on ICSCF (the interface).

Cheers,
Peter
Reply | Threaded
Open this post in threaded view
|

Re: Problem with inner class?

Thomas Hofmann
Thanks for pointing this out Peter, stupid me. I must have been blind.

-----Original Message-----
From: Peter Niederwieser [mailto:[hidden email]]
Sent: Montag, 31. Mai 2010 20:27
To: [hidden email]
Subject: [groovy-eclipse-plugin-user] Re: Problem with inner class?



Thomas Hofmann wrote:

>
> I am trying to call a factory method (implemented in Java) from Groovy:
>
> IComponentSearchCriteria searchCritera =
> ComponentSearchCriteriaFactory.FACTORY.newInstance()
>
> The code in the factory looks like this:
>
> public interface IComponentSearchCriteria extends ISearchCriteria {
>     public static final ComponentSearchCriteriaFactory FACTORY = new
> ComponentSearchCriteriaFactory(); }
>

My first impression is that Groovy is right. You call CSCF.FACTORY, but the
field is defined on ICSCF (the interface).

Cheers,
Peter
--
View this message in context: http://groovy-eclipse-plugin.42567.n3.nabble.com/Problem-with-inner-class-tp858305p859251.html
Sent from the groovy-eclipse-plugin-user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email