Use bindConstant() as
bindConstant().annotatedWith(MyAnnotation.class).to(30);
You can just have @Inject and @MyAnnotation annotated on your integer field.
Note:
In case your MyAnnotation annotation has one more element say stringValue() like,
@BindingAnnotation
@Target({ ElementType.FIELD, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
public @interface MyAnnotation {
int value() default 0;
String stringValue default "";
}
adding one more binding for that element bindConstant().annotatedWith(MyAnnotation.class).to("someValue") seems to work in the following case, but I feel this is not the correct approach.
public class A {
@Inject
public A(@MyAnnotation Integer integer, @MyAnnotation String string) {
//Here integer will be 10 and string will be someValue
}
}