/** * Add a binding for a given type or classifier (annotation). * * <p>Whenever a method parameter is encountered, a binding must be found for it * so that it can be called later to consume the stack of arguments provided by * the user and return an object that is later passed to * {@link Method#invoke(Object, Object...)}.</p> * * <p>Normally, a {@link Type} is used to discern between different bindings, but * if this is not specific enough, an annotation can be defined and used. This * makes it a "classifier" and it will take precedence over the base type. For * example, even if there is a binding that handles {@link String} parameters, * a special {@code @MyArg} annotation can be assigned to a {@link String} * parameter, which will cause the {@link Builder} to consult the {@link Binding} * associated with {@code @MyArg} rather than with the binding for * the {@link String} type.</p> * * @param binding the binding * @param type a list of types (if specified) to override the binding's types */ public void addBinding(Binding binding, Type... type) { if (type == null || type.length == 0) { type = binding.getTypes(); } for (Type t : type) { bindings.put(t, binding); } }