Reputation: 1651
I have tried to include a class(literally cut and pasted from one groovy file to another).
I get the below error
Error(s) in Groovy Script: startup failed, Script1.groovy: 101: Class definition not expected here. Possible attempt to use inner class. Inner classes not supported, perhaps try using a closure instead.
The objective is to separate the whole static logic separately.
Upvotes: 1
Views: 1362
Reputation: 171054
You've got what looks like an internal class
class Maps
Right in the middle of the method
public static void populateInstance(List lookup_1, List lookup_2, List lookup_3, List lookup_4,
List lookup_5, List lookup_6, List lookup_7){
Also, as this is Groovy, declaring all those getters shouldn't be necessary
And
import com.mobRet.*
isn't needed as you're already in that package. Also
import java.util.ArrayList
import java.util.HashMap;
import java.util.List
Can be removed as Groovy imports them by default
And inside the populateInstance
method, you can change all those:
tariffAllowance = new ArrayList();
lookup_1.each { offer ->
tariffAllowance.add(offer)
}
fmb = new ArrayList();
lookup_2.each { offer ->
fmb.add(offer)
}
blocks to:
tariffAllowance = lookup_1.collect()
fmb = lookup_2.collect()
You also seem to be making a singleton that can have all of it's data changed by calling populateInstance
. In a multi-threaded environment, the chances of this being wrong are huge (effectively this is one huge global variable)
Upvotes: 3