aboutsummaryrefslogtreecommitdiff
path: root/java/dagger/spi/model/DaggerType.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/dagger/spi/model/DaggerType.java')
-rw-r--r--java/dagger/spi/model/DaggerType.java52
1 files changed, 16 insertions, 36 deletions
diff --git a/java/dagger/spi/model/DaggerType.java b/java/dagger/spi/model/DaggerType.java
index 249d49492..463350606 100644
--- a/java/dagger/spi/model/DaggerType.java
+++ b/java/dagger/spi/model/DaggerType.java
@@ -16,47 +16,27 @@
package dagger.spi.model;
-import com.google.auto.value.AutoValue;
import com.google.devtools.ksp.symbol.KSType;
-import javax.annotation.Nullable;
+import com.google.errorprone.annotations.DoNotMock;
import javax.lang.model.type.TypeMirror;
/** Wrapper type for a type. */
-@AutoValue
+@DoNotMock("Only use real implementations created by Dagger")
public abstract class DaggerType {
- public static DaggerType fromJavac(TypeMirror type) {
- return new AutoValue_DaggerType(type, null);
- }
-
- public static DaggerType fromKsp(KSType type) {
- return new AutoValue_DaggerType(null, type);
- }
-
- /** Java representation for the type, returns {@code null} not using java annotation processor. */
- @Nullable
- public abstract TypeMirror java();
-
- /** KSP declaration for the type, returns {@code null} not using KSP. */
- @Nullable
+ /**
+ * Returns the Javac representation for the type.
+ *
+ * @throws IllegalStateException if the current backend isn't Javac.
+ */
+ public abstract TypeMirror javac();
+
+ /**
+ * Returns the KSP representation for the type.
+ *
+ * @throws IllegalStateException if the current backend isn't KSP.
+ */
public abstract KSType ksp();
- public DaggerProcessingEnv.Backend backend() {
- if (java() != null) {
- return DaggerProcessingEnv.Backend.JAVAC;
- } else if (ksp() != null) {
- return DaggerProcessingEnv.Backend.KSP;
- }
- throw new AssertionError("Unexpected backend");
- }
-
- @Override
- public final String toString() {
- switch (backend()) {
- case JAVAC:
- return java().toString();
- case KSP:
- return ksp().toString();
- }
- throw new IllegalStateException(String.format("Backend %s not supported yet.", backend()));
- }
+ /** Returns the backend used in this compilation. */
+ public abstract DaggerProcessingEnv.Backend backend();
}