boolean isExtension(TypeElement element) { return element.getAnnotation(GlideExtension.class) != null; }
private Implements getImplementsAnnotation() { return shadowType.getAnnotation(Implements.class); }
public boolean shadowIsDeprecated() { return shadowType.getAnnotation(Deprecated.class) != null; }
private GraphAnalysisInjectBinding(String provideKey, String membersKey, TypeElement type, List<String> keys, String supertypeKey) { super(provideKey, membersKey, type.getAnnotation(Singleton.class) != null, type.getQualifiedName().toString()); this.type = type; this.keys = keys; this.bindings = new Binding<?>[keys.size()]; this.supertypeKey = supertypeKey; }
private String getGlideName(TypeElement appModule) { return appModule.getAnnotation(GlideModule.class).glideName(); }
private MethodSpec writeInjectAdapterConstructor(ExecutableElement constructor, TypeElement type, ClassName strippedTypeName) { String key = (constructor != null) ? GeneratorKeys.get(type.asType()) : null; String membersKey = GeneratorKeys.rawMembersKey(type.asType()); boolean singleton = type.getAnnotation(Singleton.class) != null; return MethodSpec.constructorBuilder() .addModifiers(PUBLIC) .addStatement("super($S, $S, $N, $T.class)", key, membersKey, (singleton ? "IS_SINGLETON" : "NOT_SINGLETON"), strippedTypeName) .build(); }
public boolean isInAndroidSdk() { return shadowType.getAnnotation(Implements.class).isInAndroidSdk(); }
@Nullable private MirrorModel getMirrorModelIfAnnotation() { if (this.kind == AttributeTypeKind.ANNOTATION) { TypeElement element = toElement(this.type); if (element.getAnnotation(Mirror.Annotation.class) != null) { return new MirrorModel(element); } } return null; }
private String getGroup(TypeElement type) { Controller controller = type.getAnnotation(Controller.class); if (controller != null) { return controller.value(); } RestController restController = type.getAnnotation(RestController.class); if (restController != null) { return restController.value(); } throw new IllegalStateException(String.format("The type is not a Controller: %1$s.", type)); }
private String getGroup(TypeElement type) { Website website = type.getAnnotation(Website.class); if (website != null) { return website.value(); } throw new IllegalStateException(String.format("The type is not a Website: %1$s.", type)); }
private String getGroup(TypeElement type) { Interceptor interceptor = type.getAnnotation(Interceptor.class); if (interceptor != null) { return interceptor.value(); } throw new IllegalStateException(String.format("The type is not a Interceptor: %1$s.", type)); }
private String getGroup(TypeElement type) { Converter converter = type.getAnnotation(Converter.class); if (converter != null) { return converter.value(); } throw new IllegalStateException(String.format("The type is not a Converter: %1$s.", type)); }
private String getGroup(TypeElement type) { Resolver resolver = type.getAnnotation(Resolver.class); if (resolver != null) { return resolver.value(); } throw new IllegalStateException(String.format("The type is not a Resolver: %1$s.", type)); }
@Nullable public static TypeElement getTestSpecValue(TypeElement element) { try { element.getAnnotation(TestSpec.class).value(); } catch (MirroredTypeException e) { final TypeMirror typeMirror = e.getTypeMirror(); return (TypeElement) ((Type.ClassType) typeMirror).asElement(); } return null; } }
private boolean isJsonFieldFieldAnnotationValid(Element element, Elements elements) { TypeElement enclosingElement = (TypeElement) element.getEnclosingElement(); Annotation objectAnnotation = enclosingElement.getAnnotation(JsonObject.class); if (objectAnnotation == null) { error(enclosingElement, "%s: @%s fields can only be in classes annotated with @%s.", enclosingElement.getQualifiedName(), JsonField.class.getSimpleName(), JsonObject.class.getSimpleName()); return false; } if (element.getModifiers().contains(PRIVATE) && (TextUtils.isEmpty(JsonFieldHolder.getGetter(element, elements)) || TextUtils.isEmpty(JsonFieldHolder.getSetter(element, elements)))) { error(element, "@%s annotation can only be used on private fields if both getter and setter are present.", JsonField.class.getSimpleName()); return false; } return true; }
private Type createEnumType(DeclaredType declaredType, TypeElement typeElement, boolean deep) { // fallback Type enumType = createType(typeElement, TypeCategory.ENUM, declaredType.getTypeArguments(), deep); for (Class<? extends Annotation> entityAnn : entityAnnotations) { if (typeElement.getAnnotation(entityAnn) != null) { EntityType entityType = new EntityType(enumType, variableNameFunction); typeMappings.register(entityType, queryTypeFactory.create(entityType)); return entityType; } } return enumType; }
public static TypeElement validateLayout(TypeElement typeElement) throws IllegalUseException { validateNonPrivateModifier(typeElement); Layout layout = typeElement.getAnnotation(Layout.class); if (layout.value() <= 0) { String msg = "@Layout should have positive value passed"; throw new IllegalUseException(msg); } return typeElement; }
@Before public void setUp() { MockitoAnnotations.initMocks(this); when(mElements.getDocComment(mTypeElement)).thenReturn(""); when(mTypeElement.getQualifiedName()).thenReturn(new MockName(TEST_QUALIFIED_SPEC_NAME)); when(mTypeElement.getAnnotation(LayoutSpec.class)).thenReturn(mLayoutSpec); }
private void setRootUrl(Element element, RestHolder holder) { TypeElement typeElement = (TypeElement) element; String rootUrl = typeElement.getAnnotation(Rest.class).rootUrl(); holder.getInit().body().assign(holder.getRootUrlField(), lit(rootUrl)); }
private void setOnCreateView() { JMethod onCreateView = generatedClass.method(PUBLIC, getClasses().VIEW, "onCreateView"); onCreateView.annotate(Override.class); inflater = onCreateView.param(getClasses().LAYOUT_INFLATER, "inflater"); container = onCreateView.param(getClasses().VIEW_GROUP, "container"); JVar savedInstanceState = onCreateView.param(getClasses().BUNDLE, "savedInstanceState"); boolean forceInjection = getAnnotatedElement().getAnnotation(EFragment.class).forceLayoutInjection(); JBlock body = onCreateView.body(); if (!forceInjection) { body.assign(contentView, _super().invoke(onCreateView).arg(inflater).arg(container).arg(savedInstanceState)); } setContentViewBlock = body.blockSimple(); body._return(contentView); }