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

Method castTo

javatests/dagger/internal/codegen/ExpressionTest.java:36–49  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

34 interface Subtype extends Supertype {}
35
36 @Test
37 public void castTo() {
38 TypeMirror subtype = type(Subtype.class);
39 TypeMirror supertype = type(Supertype.class);
40 Expression expression = Expression.create(subtype, "new $T() {}", subtype);
41
42 Expression castTo = expression.castTo(supertype);
43
44 assertThat(castTo.type()).isSameAs(supertype);
45 assertThat(castTo.codeBlock().toString())
46 .isEqualTo(
47 "(dagger.internal.codegen.ExpressionTest.Supertype) "
48 + "new dagger.internal.codegen.ExpressionTest.Subtype() {}");
49 }
50
51 private TypeMirror type(Class<?> clazz) {
52 return compilationRule.getElements().getTypeElement(clazz.getCanonicalName()).asType();

Callers

nothing calls this directly

Calls 6

typeMethod · 0.95
createMethod · 0.95
castToMethod · 0.95
typeMethod · 0.95
codeBlockMethod · 0.95
toStringMethod · 0.45

Tested by

no test coverage detected