MCPcopy Index your code
hub / github.com/google/dagger / rewrapType

Method rewrapType

java/dagger/internal/codegen/DaggerTypes.java:125–136  ·  view source on GitHub ↗

Returns type's single type argument wrapped in wrappingClass. For example, if type is List and wrappingClass is Set.class, this will return Set . If type has no type parameters, returns a TypeMirror for {@

(TypeMirror type, Class<?> wrappingClass)

Source from the content-addressed store, hash-verified

123 * @throws IllegalArgumentException if {@code} has more than one type argument.
124 */
125 DeclaredType rewrapType(TypeMirror type, Class<?> wrappingClass) {
126 List<? extends TypeMirror> typeArguments = MoreTypes.asDeclared(type).getTypeArguments();
127 TypeElement wrappingType = elements.getTypeElement(wrappingClass.getCanonicalName());
128 switch (typeArguments.size()) {
129 case 0:
130 return types.getDeclaredType(wrappingType);
131 case 1:
132 return types.getDeclaredType(wrappingType, getOnlyElement(typeArguments));
133 default:
134 throw new IllegalArgumentException(type + " has more than 1 type argument");
135 }
136 }
137
138 /** Returns a {@link TypeMirror} for the binding that is accessible to the component. */
139 protected final TypeMirror accessibleType(TypeMirror type, ClassName requestingClass) {

Callers 1

toMethod · 0.80

Calls 2

getDeclaredTypeMethod · 0.80
getTypeElementMethod · 0.45

Tested by

no test coverage detected