Unable to resolve class DeviceWrapper

(Ross Tyler) #1


… describes the DeviceWrapper class in the signatures of some methods. I would like to use this in the signature of a groovy varargs method. For example,

def myVarargsMethod(arg1, arg2, DeviceWrapper... devices) {

Unfortunately, when saving such code, the IDE warns

Unable to resolve class DeviceWrapper

Using Object instead does not work as the runtime does not allow me to call through it.
I will be wanting use such code with Switch and/or SwitchLevel capable devices.
I will need to access the attributes/commands of such devices.
I am not sure that even DeviceWrapper will work but I can’t think of what else to try.

I know that, instead of passing devices in a varargs fashion …

myVarargsMethod(0, 1, device1, device2)
myVarargsMethod(3, 4, device5)
myVarargsMethod(7, 9, device8, device3, device7, device1)

… I can pass them in a single array argument …

myNonVarargsMethod(0, 1, [device1, device2])
myNonVarargsMethod(3, 4, [device5])
myNonVarargsMethod(7, 9, [device8, device3, device7, device1])

… receive them as untyped …

def myNonVarargsMethod(arg1, arg2, devices) {

… and process them as a list. That serves as a workaround but it is not as elegant as just listing the devices at the end of the call.

(Ross Tyler) #2

Solved it.
I needed to qualify it with its package: