本文整理匯總了Java中com.google.gwt.core.ext.typeinfo.JClassType.getQualifiedSourceName方法的典型用法代碼示例。如果您正苦於以下問題:Java JClassType.getQualifiedSourceName方法的具體用法?Java JClassType.getQualifiedSourceName怎麽用?Java JClassType.getQualifiedSourceName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.gwt.core.ext.typeinfo.JClassType
的用法示例。
在下文中一共展示了JClassType.getQualifiedSourceName方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: loadElementWithServices
import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
@Override
Mvp4gWithServicesElement loadElementWithServices(JClassType c,
History annotation,
Mvp4gConfiguration configuration)
throws Mvp4gAnnotationException {
String className = c.getQualifiedSourceName();
String historyName = buildElementNameIfNeeded(annotation.name(),
className,
"");
String type = annotation.type()
.name();
HistoryConverterElement historyConverter = new HistoryConverterElement();
historyConverter.setName(historyName);
historyConverter.setClassName(className);
historyConverter.setType(type);
addElement(configuration.getHistoryConverters(),
historyConverter,
c,
null);
return historyConverter;
}
示例2: buildEventBusElement
import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
/**
* Build event bus element according to the implemented interface.
*
* @param c annoted class type
* @param configuration configuration containing loaded elements of the application
* @return event bus corresponding to the implemented interface (null if none of the interfaces
* are implemented)
*/
private EventBusElement buildEventBusElement(JClassType c,
Mvp4gConfiguration configuration) {
TypeOracle oracle = configuration.getOracle();
EventBusElement eventBus = null;
if (c.isAssignableTo(oracle.findType(EventBusWithLookup.class.getCanonicalName()))) {
eventBus = new EventBusElement(c.getQualifiedSourceName(),
BaseEventBusWithLookUp.class.getCanonicalName(),
true);
} else if (c.isAssignableTo(oracle.findType(EventBus.class.getCanonicalName()))) {
eventBus = new EventBusElement(c.getQualifiedSourceName(),
BaseEventBus.class.getCanonicalName(),
false);
}
return eventBus;
}
示例3: loadHistory
import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
/**
* Build history converter of an event. If the converter class name is given, first it tries to
* find an instance of this class, and if none is found, create one.
*
* @param c annoted class
* @param method method that defines the event
* @param annotation Event annotation
* @param element Event element
* @param configuration configuration containing loaded elements of the application
* @throws Mvp4gAnnotationException
*/
private void loadHistory(JClassType c,
JMethod method,
Event annotation,
EventElement element,
Mvp4gConfiguration configuration)
throws Mvp4gAnnotationException {
String hcName = annotation.historyConverterName();
Class<?> hcClass = annotation.historyConverter();
if ((hcName != null) && (hcName.length() > 0)) {
element.setHistory(hcName);
} else if (!Event.NoHistoryConverter.class.equals(hcClass)) {
String hcClassName = hcClass.getCanonicalName();
Set<HistoryConverterElement> historyConverters = configuration.getHistoryConverters();
hcName = getElementName(historyConverters,
hcClassName);
if (hcName == null) {
String err = "No instance of " + hcClassName + " is defined. Have you forgotten to annotate your history converter with @History?";
throw new Mvp4gAnnotationException(c.getQualifiedSourceName(),
method.getName(),
err);
}
element.setHistory(hcName);
}
}
示例4: loadHandler
import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
@Override
protected PresenterElement loadHandler(JClassType c,
Presenter annotation,
Mvp4gConfiguration configuration)
throws Mvp4gAnnotationException {
String className = c.getQualifiedSourceName();
String viewName = buildElementNameIfNeeded(annotation.viewName(),
className,
"View");
PresenterElement presenter = new PresenterElement();
presenter.setView(viewName);
ViewElement view = new ViewElement();
view.setClassName(annotation.view()
.getCanonicalName());
view.setName(viewName);
addElement(configuration.getViews(),
view,
c,
null);
return presenter;
}
示例5: generateDependenciesForExtension
import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
/**
* Writes dependency gathering code, like:
*
* <p>Array<DependencyDescription> deps = Collections.<DependencyDescription> createArray();
* deps.add(new DependencyDescription("ide.api.ui.menu", "")); deps.add(new
* DependencyDescription("extension.demo", "1.0.0-alpha"));
*
* @param sw
* @param extension
* @throws UnableToCompleteException
*/
private void generateDependenciesForExtension(SourceWriter sw, JClassType extension)
throws UnableToCompleteException {
// expected code
/*
Array<DependencyDescription> deps = Collections.<DependencyDescription> createArray();
deps.add(new DependencyDescription("ide.api.ui.menu", ""));
*/
if (extension.getConstructors().length == 0) {
throw new UnableToCompleteException();
}
sw.println("List<DependencyDescription> deps = new ArrayList<>();");
JConstructor jConstructor = extension.getConstructors()[0];
JType[] parameterTypes = jConstructor.getParameterTypes();
for (JType jType : parameterTypes) {
JClassType argType = jType.isClassOrInterface();
if (argType != null
&& (argType.isAnnotationPresent(SDK.class)
|| argType.isAnnotationPresent(Extension.class))) {
String id = "";
String version = "";
if (argType.isAnnotationPresent(SDK.class)) {
id = argType.getAnnotation(SDK.class).title();
} else if (argType.isAnnotationPresent(Extension.class)) {
id = argType.getQualifiedSourceName();
version = argType.getAnnotation(Extension.class).version();
}
sw.println(
"deps.add(new DependencyDescription(\"%s\", \"%s\"));", escape(id), escape(version));
}
}
}
示例6: loadElementWithServices
import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
@Override
Mvp4gWithServicesElement loadElementWithServices(JClassType c,
A annotation,
Mvp4gConfiguration configuration)
throws Mvp4gAnnotationException {
String className = c.getQualifiedSourceName();
String eventHandlerName = buildElementNameIfNeeded(getAnnotationName(annotation),
className,
"");
T eventHandler = loadHandler(c,
annotation,
configuration);
eventHandler.setName(eventHandlerName);
eventHandler.setClassName(className);
eventHandler.setMultiple(Boolean.toString(isAnnotationMultiple(annotation)));
Class<? extends Mvp4gSplitter> splitter = getAnnotationSplitter(annotation);
if (!splitter.equals(NotAsync.class)) {
eventHandler.setAsync(splitter.getCanonicalName());
}
addElement(getConfigList(configuration),
eventHandler,
c,
null);
return eventHandler;
}
示例7: controlType
import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
/**
* Control if the class can accept the annotation.
*
* @param c
* class to control
* @param mandatoryInterface
* interface that the class must implement
*
* @throws Mvp4gAnnotationException
* if the class don't implement the interface
*/
@SuppressWarnings("unchecked")
protected void controlType(JClassType c,
JClassType mandatoryInterface)
throws Mvp4gAnnotationException {
if (!c.isAssignableTo(mandatoryInterface)) {
String annotationClassName = ((Class<T>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0]).getCanonicalName();
throw new Mvp4gAnnotationException(c.getQualifiedSourceName(),
null,
"this class must implement " + mandatoryInterface.getQualifiedSourceName() + " since it is annoted with " + annotationClassName + ".");
}
}
示例8: loadHandler
import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
@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();
}
示例9: buildPresentersAndEventHandlers
import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
/**
* Build handler of the events. If the class name of the handler is given, try to find if an
* instance of this class exists, otherwise throw an error.
*
* @param c annoted class
* @param method method that defines the event
* @param event Event Annotation of the method
* @param configuration configuration containing loaded elements of the application
* @return array of handlers' names
* @throws Mvp4gAnnotationException if no instance of a given handler class can be found
*/
private String[] buildPresentersAndEventHandlers(JClassType c,
JMethod method,
Class<? extends EventHandlerInterface<? extends EventBus>>[] presenterAndEventHandlerClasses,
String[] presenterAndEventHandlerNames,
Mvp4gConfiguration configuration)
throws Mvp4gAnnotationException {
Set<EventHandlerElement> presentersAndEventHandlers = new HashSet<EventHandlerElement>(configuration.getPresenters());
presentersAndEventHandlers.addAll(configuration.getEventHandlers());
String[] handlers = new String[presenterAndEventHandlerNames.length + presenterAndEventHandlerClasses.length];
String handlerName = null;
int index = 0;
for (Class<?> handler : presenterAndEventHandlerClasses) {
handlerName = getElementName(presentersAndEventHandlers,
handler.getCanonicalName());
if (handlerName == null) {
String err = "No instance of " + handler.getCanonicalName() + " is defined. Have you forgotten to annotate your event handler with @Presenter or @EventHandler?";
throw new Mvp4gAnnotationException(c.getQualifiedSourceName(),
method.getName(),
err);
}
handlers[index] = handlerName;
index++;
}
for (String h : presenterAndEventHandlerNames) {
handlers[index] = h;
index++;
}
return handlers;
}
示例10: loadElement
import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
@Override
protected void loadElement(JClassType c,
Service annotation,
Mvp4gConfiguration configuration)
throws Mvp4gAnnotationException {
String className = c.getQualifiedSourceName();
String serviceName = buildElementNameIfNeeded(annotation.name(),
className,
"");
String path = annotation.path();
Class<?> generatedClass = annotation.generatedClass();
ServiceElement service = new ServiceElement();
service.setName(serviceName);
service.setClassName(className);
if ((path != null) && (path.length() > 0)) {
service.setPath(annotation.path());
}
if (!Void.class.equals(generatedClass)) {
service.setGeneratedClassName(generatedClass.getCanonicalName());
}
addElement(configuration.getServices(),
service,
c,
null);
}
示例11: testParentEventBusOtherModule
import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
@Test
public void testParentEventBusOtherModule()
throws Mvp4gAnnotationException {
List<JClassType> annotedClasses = new ArrayList<JClassType>();
annotedClasses.add(oracle.addClass(PresenterWithName.class));
new PresenterAnnotationsLoader().load(annotedClasses,
configuration);
annotedClasses.clear();
JClassType parentEventBus = oracle.addClass(Events.EventBusWithChildren.class);
annotedClasses.add(oracle.addClass(Events.EventBusForOtherModule.class));
annotedClasses.add(parentEventBus);
JClassType otherModule = oracle.addClass(Modules.Module01.class);
String otherModuleClassName = otherModule.getQualifiedSourceName();
configuration.setModule(otherModule);
loader.load(annotedClasses,
configuration);
Map<String, ChildModuleElement> othersParentEventBusClassMap = configuration.getModuleParentEventBusClassMap();
assertEquals(2,
othersParentEventBusClassMap.size());
ChildModuleElement element = othersParentEventBusClassMap.get(otherModuleClassName);
assertEquals(parentEventBus,
element.getParentEventBus());
assertEquals(otherModuleClassName,
element.getClassName());
assertEquals(Mvp4gModule.class.getCanonicalName(),
element.getParentModuleClass());
assertTrue(element.isAutoDisplay());
}
示例12: generateConstructor
import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
/**
* Generate constructor with dependencies added into field
*
* @param className
* @param extensions
* @param sw
* @throws UnableToCompleteException
*/
private void generateConstructor(String className, List<JClassType> extensions, SourceWriter sw)
throws UnableToCompleteException {
// constructor
sw.indent();
sw.print("public %s()", className);
sw.println("{");
sw.indent();
{
for (JClassType extension : extensions) {
sw.println("{");
sw.indent();
/*
Array<DependencyDescription> deps = Collections.<DependencyDescription> createArray();
*/
generateDependenciesForExtension(sw, extension);
Extension annotation = extension.getAnnotation(Extension.class);
/*
extensions.put("ide.ext.demo", new ExtensionDescription("ide.ext.demo", "1.0.0", "Demo extension", deps,
demoExtProvider));
*/
// the class's fqn
String extensionId = extension.getQualifiedSourceName();
sw.println(
"extensions.put(\"%s\", new ExtensionDescription(\"%s\",\"%s\",\"%s\",\"%s\",deps));",
escape(extensionId),
escape(extensionId),
escape(annotation.version()),
escape(annotation.title()),
escape(annotation.description()));
sw.outdent();
sw.println("}");
}
}
sw.outdent();
sw.println("}");
}
示例13: checkForDuplicates
import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
/**
* Check if an element is already present in a set
*
* @param <E>
* type of the elements
* @param loadedElements
* set of elements where the check is done
* @param element
* searched element
* @param c
* annoted class that asks for this element to be added (can be null, only for error
* information purpose)
* @param m
* annoted method that ask for this element to be added (can be null, only for error
* information purpose)
*
* @throws Mvp4gAnnotationException
* if the element is already in the set
*/
private <E extends Mvp4gElement> void checkForDuplicates(Set<E> loadedElements,
E element,
JClassType c,
JMethod m)
throws Mvp4gAnnotationException {
if (loadedElements.contains(element)) {
String err = "Duplicate " + element.getTagName() + " identified by " + "'" + element.getUniqueIdentifierName() + "' found in configuration file.";
throw new Mvp4gAnnotationException(c.getQualifiedSourceName(),
(m == null) ?
null :
m.getName(),
err);
}
}