dagger.releasablereferences.CanReleaseReferences Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dagger Show documentation
Show all versions of dagger Show documentation
A fast dependency injector for Android and Java.
/*
* Copyright (C) 2016 The Dagger Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package dagger.releasablereferences;
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import dagger.internal.Beta;
import dagger.internal.GwtIncompatible;
import java.lang.annotation.Documented;
import java.lang.annotation.Target;
/**
* Annotates {@linkplain javax.inject.Scope scope annotations} to indicate that references to
* objects stored within that scope can be released during the lifetime
* of the scope.
*
* A scope can release references if it is annotated with {@code CanReleaseReferences} or if it
* is annotated with an annotation that itself is annotated with {@code CanReleaseReferences}.
*
*
For example:
*
*
* {@literal @Documented}
* {@literal @Retention(RUNTIME)}
* {@literal @CanReleaseReferences}
* {@literal @Scope}
* public {@literal @interface} MyScope {}
*
* or:
*
*
* {@literal @CanReleaseReferences}
* public {@literal @interface} SomeAnnotation {}
*
* {@literal @Documented}
* {@literal @Retention(RUNTIME)}
* {@literal @SomeAnnotation}
* {@literal @Scope}
* public {@literal @interface} MyScope {}
*
* Note:Releasable references uses Java's {@link java.lang.ref.WeakReference}, and so is
* not compatible with GWT.
*
* @since 2.8
*/
@Beta
@Documented
@GwtIncompatible
@Target(ANNOTATION_TYPE)
public @interface CanReleaseReferences {}