forked from google/dagger
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDependencyRequest.java
More file actions
77 lines (65 loc) · 2.63 KB
/
Copy pathDependencyRequest.java
File metadata and controls
77 lines (65 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
* Copyright (C) 2014 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.model;
import com.google.auto.value.AutoValue;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.CheckReturnValue;
import dagger.Provides;
import java.util.Optional;
import javax.inject.Inject;
import javax.lang.model.element.Element;
/**
* Represents a request for a {@link Key} at an injection point. For example, parameters to {@link
* Inject} constructors, {@link Provides} methods, and component methods are all dependency
* requests.
*
* <p id="synthetic">A dependency request is considered to be <em>synthetic</em> if it does not have
* an {@link Element} in code that requests the key directly. For example, an {@link
* java.util.concurrent.Executor} is required for all {@code @Produces} methods to run
* asynchronously even though it is not directly specified as a parameter to the binding method.
*/
@AutoValue
public abstract class DependencyRequest {
/** The kind of this request. */
public abstract RequestKind kind();
/** The key of this request. */
public abstract Key key();
/**
* The element that declares this dependency request. Absent for <a href="#synthetic">synthetic
* </a> requests.
*/
public abstract Optional<Element> requestElement();
/**
* Returns {@code true} if this request allows null objects. A request is nullable if it is
* has an annotation with "Nullable" as its simple name.
*/
public abstract boolean isNullable();
/** Returns a new builder of dependency requests. */
public static DependencyRequest.Builder builder() {
return new AutoValue_DependencyRequest.Builder().isNullable(false);
}
/** A builder of {@link DependencyRequest}s. */
@CanIgnoreReturnValue
@AutoValue.Builder
public abstract static class Builder {
public abstract Builder kind(RequestKind kind);
public abstract Builder key(Key key);
public abstract Builder requestElement(Element element);
public abstract Builder isNullable(boolean isNullable);
@CheckReturnValue
public abstract DependencyRequest build();
}
}