summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/rootcomponentgenerator/annotation/DialerComponent.java
diff options
context:
space:
mode:
authorWeijia Xu <weijiaxu@google.com>2018-03-23 18:13:41 -0700
committerWeijia Xu <weijiaxu@google.com>2018-03-26 11:09:04 -0700
commitcac4acd257f66c2639c4daa26be72484d9865ef6 (patch)
treea00af97c94375f26b2d353251cc85aab57bfd041 /java/com/android/dialer/rootcomponentgenerator/annotation/DialerComponent.java
parent2aea5b1df52c9f15e551006a46743e792b71cb51 (diff)
Add RootComponentGenerator to auto-generate root components for different dialer variants.
Bug: 35612086 Test: Test included PiperOrigin-RevId: 189981890 Change-Id: Ife99969189d5d37bb1ad8ba61361a51e78abdfbb
Diffstat (limited to 'java/com/android/dialer/rootcomponentgenerator/annotation/DialerComponent.java')
-rw-r--r--java/com/android/dialer/rootcomponentgenerator/annotation/DialerComponent.java45
1 files changed, 45 insertions, 0 deletions
diff --git a/java/com/android/dialer/rootcomponentgenerator/annotation/DialerComponent.java b/java/com/android/dialer/rootcomponentgenerator/annotation/DialerComponent.java
new file mode 100644
index 000000000..573abae7f
--- /dev/null
+++ b/java/com/android/dialer/rootcomponentgenerator/annotation/DialerComponent.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * 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 com.android.dialer.rootcomponentgenerator.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
+
+/**
+ * Annotates a type equivalent to {@link dagger.Subcomponent}.
+ *
+ * <p>The annotation processor will generate a new type file with some prefix, which contains public
+ * static XXX get(Context context) method and HasComponent interface like:
+ *
+ * <p>
+ *
+ * <pre>
+ * <code>
+ * public static SimulatorComponent get(Context context) {
+ * HasRootComponent hasRootComponent = (HasRootComponent) context.getApplicationContext();
+ * return ((HasComponent)(hasRootComponent.component()).simulatorComponent();
+ * }
+ * public interface HasComponent {
+ * SimulatorComponent simulatorComponent();
+ * }
+ * </code>
+ * </pre>
+ */
+@Target(ElementType.TYPE)
+public @interface DialerComponent {
+ Class<?>[] modules() default {};
+}