Java Code Examples for com.google.gwt.core.ext.typeinfo.JClassType#getAnnotation()

The following examples show how to use com.google.gwt.core.ext.typeinfo.JClassType#getAnnotation() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EventsAnnotationsLoader.java    From mvp4g with Apache License 2.0 6 votes vote down vote up
private void loadDebug(JClassType c,
                       Events annotation,
                       Mvp4gConfiguration configuration)
  throws Mvp4gAnnotationException {
  Debug debug = c.getAnnotation(Debug.class);

  if (debug != null) {
    Class<? extends Mvp4gLogger> loggerClass = debug.logger();
    DebugElement debugElem = new DebugElement();
    debugElem.setLogger(loggerClass.getCanonicalName());
    debugElem.setLogLevel(debug.logLevel()
                               .name());

    configuration.setDebug(debugElem);
  }
}
 
Example 2
Source File: EventsAnnotationsLoader.java    From mvp4g with Apache License 2.0 6 votes vote down vote up
private void loadHistoryConfiguration(JClassType c,
                                      Mvp4gConfiguration configuration)
  throws Mvp4gAnnotationException {

  PlaceService historyConfig = c.getAnnotation(PlaceService.class);
  if (historyConfig != null) {
    HistoryElement history = configuration.getHistory();
    if (history == null) {
      history = new HistoryElement();
      configuration.setHistory(history);
    }

    history.setPlaceServiceClass(historyConfig.value()
                                              .getCanonicalName());
  }
}
 
Example 3
Source File: UiBinderLocalizedCreator.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 6 votes vote down vote up
public UiBinderLocalizedCreator(JClassType binderType, GwtLocale locale) {
	this.binderType = binderType;
	this.locale = locale;

	for (JClassType interfaceType : binderType.getImplementedInterfaces()) {
		if (interfaceType.getQualifiedSourceName().equals(UiBinderLocalized.class.getCanonicalName())
			&& interfaceType instanceof JParameterizedType) {
			JParameterizedType paramType = (JParameterizedType) interfaceType;
			this.widgetType = paramType.getTypeArgs()[0];
			this.targetType = paramType.getTypeArgs()[1];
		}
	}
	UiTemplate templateAnnotation = binderType.getAnnotation(UiTemplate.class);
	if (templateAnnotation != null) {
		this.templateName = templateAnnotation.value().replace(UiBinderLocalizedCreator.TEMPLATE_SUFFIX, "");
	}
	if (this.templateName == null) {
		this.templateName = this.targetType.getSimpleSourceName();
	}
}
 
Example 4
Source File: EventHandlerAnnotationsLoader.java    From mvp4g with Apache License 2.0 5 votes vote down vote up
@Override
protected EventHandlerElement loadHandler(JClassType c,
                                          EventHandler annotation,
                                          Mvp4gConfiguration configuration)
  throws Mvp4gAnnotationException {
  if (c.getAnnotation(Presenter.class) != null) {
    String err = "You can't annotate a class with @Presenter and @EventHandler.";
    throw new Mvp4gAnnotationException(c.getQualifiedSourceName(),
                                       null,
                                       err);
  }
  return new EventHandlerElement();
}
 
Example 5
Source File: ProxyViewCreator.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
public ProxyViewCreator(JClassType placeType) {
	this.placeType = placeType;
	this.packageName = this.placeType.getPackage().getName();
	String qualifiedName = this.placeType.getQualifiedSourceName() + ProxyViewCreator.PROXY_SUFFIX;
	this.viewProxyQualifiedName = qualifiedName.replace(placeType.getName(), placeType.getName().replace('.', '_'));
	this.viewProxySimpleName = this.viewProxyQualifiedName.replace(this.packageName + ".", "");
	this.activityDescrition = placeType.getAnnotation(ActivityDescription.class);
	this.placeTokenizerClass = this.activityDescrition.placeTokenizer();

	if (PlaceTokenizer.class.equals(this.placeTokenizerClass)) {
		this.placeTokenizerClass = null;
		this.getClass();
		try {
			Class<? extends ViewPlace> placeClass =
				(Class<? extends ViewPlace>) Class.forName(this.placeType.getQualifiedSourceName());
			for (Class<?> inter : placeClass.getInterfaces()) {
				if (inter.equals(PlaceTokenizer.class)) {
					this.placeTokenizerClass = (Class<? extends PlaceTokenizer<?>>) placeClass;
				}
			}
		} catch (ClassNotFoundException e) {
			this.placeTokenizerClass = null;
		}
	}
	this.viewDecoratorClass = this.activityDescrition.viewDecorator();
	if (ViewDecorator.class.equals(this.viewDecoratorClass)) {
		this.viewDecoratorClass = null;
	}
}
 
Example 6
Source File: ModuleCreatorFactory.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void createDelegates(JClassType injectableType, Collection<InjectorCreatorDelegate> delegates) {
	if (injectableType.getAnnotation(MvpDescription.class) != null) {
		delegates.add(
			new InjectMvpDescriptionCreator(injectableType, injectableType.getAnnotation(MvpDescription.class)));
	}
	if (injectableType.getAnnotation(ThemeDescription.class) != null) {
		delegates.add(new InjectThemeCreator(injectableType, injectableType.getAnnotation(ThemeDescription.class)));
	}
	if (injectableType.getAnnotation(ErrorManagmentDescription.class) != null) {
		delegates.add(
			new InjectErrorManagerCreator(injectableType, injectableType.getAnnotation(ErrorManagmentDescription.class)));
	}
}
 
Example 7
Source File: SecurityCreatorFactory.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void createDelegates(JClassType injectableType, Collection<InjectorCreatorDelegate> delegates) {
	Secured securedAnnotation = injectableType.getAnnotation(Secured.class);
	if (securedAnnotation != null) {
		delegates.add(new InjectSecuritedCreator(securedAnnotation));
	}
}
 
Example 8
Source File: InjectTemplateCreator.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
public InjectTemplateCreator(JClassType viewType) {
	this.viewType = viewType;
	this.templateInterfaceName = viewType.getSimpleSourceName() + "TemplateBinder";
	Templated templateAnnotation = viewType.getAnnotation(Templated.class);
	if (Templated.DEFAULT_VALUE.equals(templateAnnotation.value())) {
		this.templateName = null;
	} else {
		this.templateName = templateAnnotation.value();
	}
}
 
Example 9
Source File: GssResourceGenerator.java    From gss.gwt with Apache License 2.0 5 votes vote down vote up
private void maybeHandleSharedMethod(JMethod method, String obfuscatedClassName) {
  JClassType enclosingType = method.getEnclosingType();
  Shared shared = enclosingType.getAnnotation(Shared.class);

  if (shared != null) {
    replacementsForSharedMethods.put(method, obfuscatedClassName);
  }
}
 
Example 10
Source File: GssResourceGenerator.java    From gss.gwt with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the import prefix for a type, including the trailing hyphen.
 */
private String getImportPrefix(JClassType importType) {
  String prefix = importType.getSimpleSourceName();
  ImportedWithPrefix exp = importType.getAnnotation(ImportedWithPrefix.class);
  if (exp != null) {
    prefix = exp.value();
  }

  return prefix + "-";
}
 
Example 11
Source File: TemplatedCreatorFactory.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void createDelegates(JClassType injectableType, Collection<InjectorCreatorDelegate> delegates) {
	if (injectableType.getAnnotation(Templated.class) != null) {
		delegates.add(new InjectTemplateCreator(injectableType));
	}
}