Forum Discussion
rreeves
8 years agoFormer Employee
It sounds like getAccountVariableValue is a method that applies to each account implementation. Correct me if I’m wrong.
I’d suggest defining an interface that extends Account and defines getAccountVariableValue. Let’s call it FooAccount. Each of your account implementations would implement FooAccount. Note, you could also define a super class for the accounts instead of an interface.
//TODO replace Object with proper types
public interface FooAccount extends Account<Object> {
Object getAccountVariableValue();
}
Then modify the snap to inject FooAccount.
public class FooSnap extends SimpleSnap implements MultiAccountBinding<FooAccount> {
@Inject
FooAccount snapAccount;
@Override
public Module getManagedAccountModule(final FooAccount account) {
return binder -> binder.bind(FooAccount.class).toInstance(account);
}
}
andrew_holbrook
8 years agoNew Contributor III
Thanks! Very helpful.