@@ -0,0 +1,2885 @@
+package com.google.inject;%0A%0Aimport static java.lang.annotation.ElementType.ANNOTATION_TYPE;%0Aimport static java.lang.annotation.ElementType.TYPE;%0Aimport static java.lang.annotation.RetentionPolicy.RUNTIME;%0A%0Aimport java.lang.annotation.Annotation;%0Aimport java.lang.annotation.Documented;%0Aimport java.lang.annotation.Inherited;%0Aimport java.lang.annotation.Retention;%0Aimport java.lang.annotation.Target;%0A%0A/**%0A * Annotation restricting the binding of the target type to permitted modules.%0A *%0A * %3Cp%3EIf a binding's type or qualifier annotation type is annotated with%0A * %7B@code @RestrictedBindingSource%7D, then only modules annotated with a permit from %7B@link #permits%7D%0A * are allowed to create it (note that if both the type and qualifier annotation type are restricted%0A * this way, both restrictions are enforced) -- otherwise, an error message including the %7B@link%0A * #explanation%7D is issued.%0A *%0A * %3Cp%3EThis allows libraries to prevent their clients from binding their keys, similar to how%0A * declaring a class final prevents subtyping. For example, a library may want to prevent users from%0A * creating mock bindings for tests, using the %7B@link #explanation%7D - included in the error message%0A * - to point them to a supported testing module.%0A *%0A * %3Cp%3ETODO(user): Concrete Example!%0A *%0A * %3Cp%3ENote that a binding is created by a stack of modules, where the module at the bottom of the%0A * stack creates it directly, and its ancestor modules up the stack create it indirectly. A binding%0A * restricted this way can be created if one of the modules on the stack is annotated with one of%0A * the annotations in %7B@link #permits%7D.%0A *%0A * %3Cp%3E%3Cb%3EWarning:%3C/b%3E This is an experimental API, currently in developement.%0A *%0A * @author vzm@google.com (Vladimir Makaric)%0A */%0A@Inherited%0A@Retention(RUNTIME)%0A@Target(TYPE)%0Apublic @interface RestrictedBindingSource %7B%0A  /**%0A   * Explanation of why binding this target type is restricted.%0A   *%0A   * %3Cp%3EWill appear as the error message if the target type is bound by non-allowed modules.%0A   */%0A  String explanation();%0A%0A  /**%0A   * Meta-annotation indicating that the target annotation is a permit for binding restricted%0A   * bindings. Annotating a module with a permit gives the module permission to bind the restricted%0A   * bindings guarded by the permit (see %7B@link #permits%7D).%0A   */%0A  @Documented%0A  @Retention(RUNTIME)%0A  @Target(ANNOTATION_TYPE)%0A  public @interface Permit %7B%7D%0A%0A  /**%0A   * List of %7B@code Permit%7D annotations (must be non-empty), one of which has has to be present on a%0A   * restricted binding's module stack.%0A   */%0A  Class%3C? extends Annotation%3E%5B%5D permits();%0A%0A  /** Level of restriction. Determines how violations are handled. */%0A  public static enum RestrictionLevel %7B%0A    WARNING,%0A    ERROR;%0A  %7D%0A%0A  RestrictionLevel restrictionLevel() default RestrictionLevel.ERROR;%0A%0A  // TODO(user): Add exemption mechanism similar to RestrictedApi's allowedOnPath.%0A%7D%0A

Define @RestrictedBindingSource API.