1 /* 2 * Copyright (C) 2021 The Dagger Authors. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package dagger.spi.model; 18 19 import static androidx.room.compiler.processing.compat.XConverters.toJavac; 20 21 import androidx.room.compiler.processing.XType; 22 import com.google.auto.common.MoreTypes; 23 import com.google.auto.value.AutoValue; 24 import com.google.common.base.Equivalence; 25 import com.google.common.base.Preconditions; 26 import javax.lang.model.type.TypeMirror; 27 28 /** Wrapper type for a type. */ 29 @AutoValue 30 public abstract class DaggerType { 31 private XType type; 32 from(XType type)33 public static DaggerType from(XType type) { 34 Preconditions.checkNotNull(type); 35 DaggerType daggerType = new AutoValue_DaggerType(MoreTypes.equivalence().wrap(toJavac(type))); 36 daggerType.type = type; 37 return daggerType; 38 } 39 typeMirror()40 abstract Equivalence.Wrapper<TypeMirror> typeMirror(); 41 xprocessing()42 public XType xprocessing() { 43 return type; 44 } 45 java()46 public TypeMirror java() { 47 return toJavac(type); 48 } 49 50 @Override toString()51 public final String toString() { 52 return type.toString(); 53 } 54 } 55