groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Venutolo <>
Subject Spring Groovy application context and creating @Immutable class beans
Date Mon, 11 Apr 2016 20:47:01 GMT
Hi all,

As a fun learning experience I am attempting to move an application's
Spring configuration from XML to Groovy. I need to create a bean for a
Groovy class that is annotated with @Immutable.

Let's say my class is this:

class MyImmutableClass {
    String someString
    String otherString
    String anotherString

And I attempt to create a bean like so:

beans {
            someString: 'some',
            otherString: 'other',
            anotherString: 'another'

It fails:
Invalid property 'someString' of bean class [MyImmutableClass]: Bean
property 'someString' is not writable or has an invalid setter method. Does
the parameter type of the setter match the return type of the getter?

I can do the following, but I then lose the parameter name information that
tells me which fields are set to which values:

beans {

I can also remove the @Immutable annotation from the class. But let's
assume this class comes from somewhere else and I cannot modify it.

So what are my options here that combine not modifying the @Immutable class
and keeping the parameter names? I know I can combine Groovy and XML
configuration and define the bean in XML and then use importBeans in my
Groovy code, but is there something I can do that is purely Groovy?

I found this issue, which describes my problem:


View raw message