I have a Java class in a xtend file that uses Guice, like this:
class myClass {
@Inject private extension classA
@Inject private extension classB
// methods
// ...
}
I want to add an integer field and modify the default constructor to set it by using a helper class IdProvider, doing something like this:
import some.package.IdProvider
class myClass {
@Inject private extension classA
@Inject private extension classB
private long mMaxId
new() {
var IdProvider provider
mMaxId = provider.getMaxId("Student")
}
// methods
// ...
}
However this doens't work, I get this error:
com.google.inject.ProvisionException: Guice provision errors. Error injecting constructor, java.lang.NullPointerException
I have also tried this, but I get the same error:
import some.package.IdProvider
class myClass {
@Inject private extension classA
@Inject private extension classB
private long mMaxId
@Inject private IdProvider provider
new() {
mMaxId = provider.getMaxId("Student")
}
// methods
// ...
}
I am new to xtend and Guice, so any help understanding how to get this to work would be appreciated.